# HG changeset patch # User koda # Date 1352847410 -3600 # Node ID c82b68016c680858161c5f1f47adda054846209f # Parent 25a4daa6473cef3a0a62617171176867c8df7284 link main on osx diff -r 25a4daa6473c -r c82b68016c68 project_files/hwc/CMakeLists.txt --- a/project_files/hwc/CMakeLists.txt Tue Nov 13 23:39:49 2012 +0100 +++ b/project_files/hwc/CMakeLists.txt Tue Nov 13 23:56:50 2012 +0100 @@ -35,7 +35,6 @@ include_directories("${GLEW_INCLUDE_PATH}") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/rtl") - configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc) #get the list of pas files that are going to be converted and compiled @@ -80,5 +79,25 @@ #TODO: add other libraries ) +#TODO: move this away in its proper findxxx.cmake +if(APPLE) + #let's look for the installed sdlmain file; if it is not found, let's build our own + find_package(SDL REQUIRED) + #remove the ";-framework Cocoa" from the SDL_LIBRARY variable + string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}") + #find libsdmain.a + find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/) + + if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") + include_directories(${SDL_INCLUDE_DIR}) + add_library (SDLmain STATIC ${CMAKE_SOURCE_DIR}/hedgewars/sdlmain_osx/SDLMain.m) + #add a dependency to the hwengine target + set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a") + endif() + + target_link_libraries(hwengine ${SDLMAIN_LIB}) +endif(APPLE) + + install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) diff -r 25a4daa6473c -r c82b68016c68 project_files/hwc/rtl/fpcrtl.h --- a/project_files/hwc/rtl/fpcrtl.h Tue Nov 13 23:39:49 2012 +0100 +++ b/project_files/hwc/rtl/fpcrtl.h Tue Nov 13 23:56:50 2012 +0100 @@ -14,6 +14,9 @@ #include "pmath.h" #ifndef EMSCRIPTEN +#if __APPLE__ +#define main SDL_main +#endif #include "GL/glew.h" #endif