hedgewars/CMakeLists.txt
branchwebgl
changeset 9130 4f4b71da3559
parent 9127 e350500c4edb
child 9160 fc46e75f6b72
--- 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)