move sdlmain_osx aside in its own folder so its include path is not contaminated webgl
authorkoda
Tue, 04 Jun 2013 23:48:24 +0200
branchwebgl
changeset 9130 4f4b71da3559
parent 9127 e350500c4edb
child 9133 a269fe7090a0
move sdlmain_osx aside in its own folder so its include path is not contaminated
CMakeLists.txt
hedgewars/CMakeLists.txt
hedgewars/sdlmain_osx/CMakeLists.txt
project_files/hwc/CMakeLists.txt
--- a/CMakeLists.txt	Tue Jun 04 22:28:12 2013 +0200
+++ b/CMakeLists.txt	Tue Jun 04 23:48:24 2013 +0200
@@ -402,6 +402,7 @@
     if (NOT ghc_executable)
         message(FATAL_ERROR "A Haskell compiler is required to build engine in C")
     endif()
+    add_subdirectory(hedgewars/sdlmain_osx)
     #pascal to c converter
     add_subdirectory(tools/pas2c)
     add_subdirectory(project_files/hwc)
--- a/hedgewars/CMakeLists.txt	Tue Jun 04 22:28:12 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Tue Jun 04 23:48:24 2013 +0200
@@ -148,22 +148,8 @@
 
     #on OSX we need to provide the SDL_main() function when building as executable
     if(NOT ${LIBENGINE})
-        #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_library_only "${SDL_LIBRARY}")
-        #find libsdmain.a
-        find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_library_only}/Resources/)
-
-        if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
-            include_directories(${SDL_INCLUDE_DIR})
-            add_library (SDLmain STATIC sdlmain_osx/SDLMain.m)
-            #add a dependency to the hwengine target
-            list(APPEND engine_sources SDLmain)
-            set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
-        endif()
-
-        list(APPEND pascal_flags "-k${SDLMAIN_LIB}")
+        add_subdirectory(sdlmain_osx)
+        list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
     endif()
 
     #when you have multiple ld installation make sure you get the one bundled with the compiler
@@ -267,6 +253,10 @@
     add_dependencies(hwengine avwrapper)
 endif()
 
+if(APPLE)
+    add_dependencies(hwengine SDLmain)
+endif(APPLE)
+
 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
     add_dependencies(hwengine ENGINECLEAN)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/sdlmain_osx/CMakeLists.txt	Tue Jun 04 23:48:24 2013 +0200
@@ -0,0 +1,8 @@
+if(APPLE)
+    #let's look for the installed sdlmain file; if it is not found, let's build our own
+    find_package(SDL REQUIRED)
+
+    include_directories(${SDL_INCLUDE_DIR})
+    add_library (SDLmain STATIC ${CMAKE_CURRENT_SOURCE_DIR}/SDLMain.m)
+endif(APPLE)
+
--- a/project_files/hwc/CMakeLists.txt	Tue Jun 04 22:28:12 2013 +0200
+++ b/project_files/hwc/CMakeLists.txt	Tue Jun 04 23:48:24 2013 +0200
@@ -59,28 +59,8 @@
                                 #TODO: add other libraries
                             )
 if(APPLE)
-    target_link_libraries(hwengine IOKit)
+    target_link_libraries(hwengine IOKit SDLmain)
 endif()
 
-#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_binary_install_dir})