diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a01b11..0f8e203b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,8 @@ IF( NOT VERSION ) endif(EXISTS ${PROJECT_SOURCE_DIR}/.git) ENDIF( NOT VERSION ) + + # Fill in SDLMAIN_LIBRARY on OS X manually to avoid using SDLMain.m # OS X users will have to compile and install SDL from source. if( APPLE AND ENABLE_SDL ) @@ -65,9 +67,40 @@ if( APPLE AND ENABLE_SDL ) SET(SDLMAIN_LIBRARY "-lSDLmain") endif( APPLE AND ENABLE_SDL ) +# Add support for MacPorts and Homebrew on OS X +# and ObjectiveC code +IF(APPLE) + SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/include;/opt/local/include") + SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/lib;/opt/local/lib") + SET(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/bin;/opt/local/bin") + + link_directories("/usr/local/lib") + include_directories("/usr/local/include") + + link_directories("/opt/local/lib") + include_directories("/opt/local/include") + + # and compile as Objective-C++ for ObjectiveC #ifdefs + SET(CMAKE_CXX_COMPILE_OBJECT " -x objective-c++ -o -c ") +ENDIF() + +# We do not support amd64 asm yet +IF((ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX) + AND CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64" + AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + MESSAGE(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on AMD64 yet.") +ENDIF() + # Check for nasm if( ENABLE_ASM_SCALERS ) - ENABLE_LANGUAGE( ASM_NASM ) + IF(EXISTS "/usr/local/bin/nasm") + SET(CMAKE_ASM_NASM_COMPILER "/usr/local/bin/nasm") + ELSEIF(EXISTS "/opt/local/bin/nasm") + SET(CMAKE_ASM_NASM_COMPILER "/opt/local/bin/nasm") + ELSE() + SET(CMAKE_ASM_NASM_COMPILER "/usr/bin/nasm") + ENDIF() + ENABLE_LANGUAGE(ASM_NASM) endif( ENABLE_ASM_SCALERS ) # Look for some dependencies using CMake scripts @@ -166,6 +199,14 @@ if( ENABLE_NLS ) ADD_DEFINITIONS ( -DENABLE_NLS ) ADD_DEFINITIONS ( -DLOCALEDIR=\\\"${LOCALEDIR}\\\" ) # for now, only GBALink.cpp uses gettext() directly + IF(APPLE) + # use Homebrew gettext if available + IF(EXISTS "/usr/local/opt/gettext") + SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};/usr/local/opt/gettext/include") + SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/local/opt/gettext/lib") + SET(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};/usr/local/opt/gettext/bin") + ENDIF() + ENDIF() IF(ENABLE_LINK) FIND_PATH(LIBINTL_INC libintl.h ) FIND_LIBRARY(LIBINTL_LIB intl ) @@ -176,18 +217,25 @@ if( ENABLE_NLS ) INCLUDE(CheckFunctionExists) CHECK_FUNCTION_EXISTS(gettext GETTEXT_FN) IF(NOT LIBINTL_INC OR NOT GETTEXT_FN) - message( SEND_ERROR "NLS requires libintl" ) + MESSAGE(FATAL_ERROR "NLS requires libintl/gettext") ENDIF(NOT LIBINTL_INC OR NOT GETTEXT_FN) INCLUDE_DIRECTORIES(${LIBINTL_INC}) ENDIF(ENABLE_LINK) endif( ENABLE_NLS ) # Compiler flags -IF ( WIN32 ) - SET( CMAKE_ASM_NASM_FLAGS "-I$(CMAKE_SOURCE_DIR)/src/filters/hq/asm/ -O1 -w-orphan-labels") -ELSE ( WIN32 ) - SET( CMAKE_ASM_NASM_FLAGS "-I$(CMAKE_SOURCE_DIR)/src/filters/hq/asm/ -O1 -DELF -w-orphan-labels") -ENDIF ( WIN32 ) +IF(WIN32) + SET( CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I$(CMAKE_SOURCE_DIR)/src/filters/hq/asm/ -O1 -w-orphan-labels") +ELSEIF(APPLE) + SET( CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I$(CMAKE_SOURCE_DIR)/src/filters/hq/asm/ -O1 -DMACHO -w-orphan-labels") +ELSEIF("${CMAKE_SYSTEM}" MATCHES "Linux") + SET( CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I$(CMAKE_SOURCE_DIR)/src/filters/hq/asm/ -O1 -DELF -w-orphan-labels") +ENDIF() + +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "[xX]86|[aA][mM][dD]64|[xX]64" AND CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + ADD_DEFINITIONS( -D__AMD64__ ) + SET(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -D__AMD64__") +ENDIF() SET( CMAKE_C_FLAGS_RELEASE "-O3") SET( CMAKE_CXX_FLAGS_RELEASE "-O3") diff --git a/CMakeScripts/CMakeASM_NASMInformation.cmake b/CMakeScripts/CMakeASM_NASMInformation.cmake index 6c394da1..56ff44d5 100644 --- a/CMakeScripts/CMakeASM_NASMInformation.cmake +++ b/CMakeScripts/CMakeASM_NASMInformation.cmake @@ -24,11 +24,19 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) SET(CMAKE_ASM_NASM_OBJECT_FORMAT win32) endif() elseif(APPLE) - if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) - SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) - else() - SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho32) - endif() + EXECUTE_PROCESS(COMMAND ${CMAKE_ASM_NASM_COMPILER} -v COMMAND awk "{print \$3}" OUTPUT_VARIABLE NASM_VERSION) + IF(NASM_VERSION VERSION_LESS 2.0) + IF(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + MESSAGE(FATAL_ERROR "Your nasm is too old to support AMD64, please install nasm from Homebrew or MacPorts.") + ENDIF() + SET(CMAKE_ASM_NAMS_OBJECT_FORMAT macho) + ELSE() + if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) + SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64) + else() + SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho32) + endif() + ENDIF() else() if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8) SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf64) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 540fdcdd..0b054f68 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -30,6 +30,10 @@ else(ENABLE_OPENAL) endif(ENABLE_OPENAL) +IF(CMAKE_BUILD_TYPE EQUAL "Debug") + SET(wxWidgets_USE_DEBUG ON) +ENDIF() +SET(wxWidgets_USE_UNICODE ON) # adv is for wxAboutBox # xml, html is for xrc SET( wxWidgets_USE_LIBS xrc xml html adv gl net core base ) @@ -175,13 +179,14 @@ ENDIF(NOT WIN32 AND NOT APPLE) if(APPLE) # this should set ROM file types correctly - SET_PROPERTY(TARGET wxvbam APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in) - # file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/icons/vbam.icns DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) + SET_PROPERTY(TARGET visualboyadvance-m APPEND PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/wxplist.in) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/icons/vbam.icns DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}) SET(MACOSX_BUNDLE_ICON_FILE vbam.icns) SET_SOURCE_FILES_PROPERTIES(${VBAM_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) endif(APPLE) -IF( WIN32 ) + +IF(WIN32 OR APPLE) SET(WX_EXE_NAME visualboyadvance-m${CMAKE_EXECUTABLE_SUFFIX}) -ELSE( WIN32 ) +ELSE() SET(WX_EXE_NAME vbam${CMAKE_EXECUTABLE_SUFFIX}) -ENDIF( WIN32 ) \ No newline at end of file +ENDIF() diff --git a/src/wx/wxplist.in b/src/wx/wxplist.in index 0ccce027..e1f1ad99 100644 --- a/src/wx/wxplist.in +++ b/src/wx/wxplist.in @@ -32,6 +32,12 @@ NSHumanReadableCopyright ${MACOSX_BUNDLE_COPYRIGHT} + + + + NSPrincipalClass + NSApplication + UTExportedTypeDeclarations diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 50212d8a..9fc5e6e5 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -65,6 +65,8 @@ static void tack_full_path(wxString &s, const wxString &app = wxEmptyString) wxString wxvbamApp::GetConfigurationPath() { + // first check if config files exists in reverse order + // (from system paths to more local paths.) if (data_path.empty()) { get_config_path(config_path); @@ -78,21 +80,25 @@ wxString wxvbamApp::GetConfigurationPath() data_path = config_path[i]; break; } - // Check if path is writeable - else if (wxIsWritable(config_path[i])) - { - data_path = config_path[i]; - break; - } } } - // if no config dir was found, search for writable parent to - // create it in in reverse order + // if no config file was not found, search for writable config + // dir or parent to create it in in OnInit in normal order + // (from user paths to system paths.) if (data_path.empty()) { for (int i = 0; i < config_path.size() ; i++) { + // Check if path is writeable + if (wxIsWritable(config_path[i])) + { + data_path = config_path[i]; + break; + } + + // check if parent of path is writable, so we can + // create the path in OnInit wxFileName parent_dir = wxFileName::DirName(config_path[i] + wxT("//..")); parent_dir.MakeAbsolute();