hedgewars/CMakeLists.txt
branchwebgl
changeset 9521 8054d9d775fd
parent 9244 bb95e351270c
parent 9339 14f5f3a1e2f7
child 9950 2759212a27de
--- a/hedgewars/CMakeLists.txt	Fri Oct 11 11:55:31 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Fri Oct 11 17:43:13 2013 +0200
@@ -12,31 +12,30 @@
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 
+#set the sources with the correct order of dependencies so that cmake won't be confused
 set(engine_sources
     SDLh.pas
     uSinTable.pas
     uFloat.pas
     uConsts.pas
     LuaPas.pas
-    PNGh.pas
     uTypes.pas
+    uVariables.pas
     uUtils.pas
-    uVariables.pas
     uMisc.pas
     uConsole.pas
+    uCommands.pas
     uDebug.pas
-    uCommands.pas
     uInputHandler.pas
     uTextures.pas
     uRenderUtils.pas
     uRender.pas
     uCaptions.pas
-    uLandTexture.pas
     uIO.pas
     uChat.pas
     uPhysFSLayer.pas
-    uStore.pas
     uSound.pas
+    ArgParsers.pas
     uRandom.pas
     uLocale.pas
     uStats.pas
@@ -45,38 +44,44 @@
     uAILandMarks.pas
     adler32.pas
     uLandTemplates.pas
+    uLandTexture.pas
     uLandGraphics.pas
     uLandPainted.pas
     uLandOutline.pas
     uLandGenMaze.pas
+
+    #this is where dependency tracking becomes hard
+    uStore.pas
+    uAmmos.pas
     uLandObjects.pas
     uLand.pas
-    uAmmos.pas
-
+    uGearsList.pas
+    uCollisions.pas
     uAIMisc.pas
     uAIActions.pas
+    uAIAmmoTests.pas
     uAI.pas
     uWorld.pas
+    uVisualGearsList.pas
+    uVisualGearsHandlers.pas
     uVisualGears.pas
-    uTeams.pas
 
-    uGearsList.pas
-    uCollisions.pas
-    uAIAmmoTests.pas
     uGears.pas
     uGame.pas
     uCommandHandlers.pas
+    uGearsRender.pas
+    uGearsHedgehog.pas
     uGearsHandlers.pas
     uGearsHandlersRope.pas
-    uGearsHedgehog.pas
-    uGearsRender.pas
+    uGearsHandlersMess.pas
     uGearsUtils.pas
+    uTeams.pas
+
+    #these interact with everything, so compile last
     uScript.pas
     hwengine.pas
 
-    GSHandlers.inc
-    VGSHandlers.inc
-    ArgParsers.inc
+    #we also have uTouch.pas
     options.inc
     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
     )
@@ -99,51 +104,25 @@
 
 
 #DEPENDECIES AND EXECUTABLES SECTION
-if(APPLE)
-    if(CMAKE_OSX_ARCHITECTURES)
-        #parse this system variable and adjust only the powerpc syntax to be compatible with -P
-        string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
-        string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}")
-        string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}")
-        if(x86_64_build)
-            add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64)
-        elseif(i386_build)
-            add_flag_prepend(CMAKE_Pascal_FLAGS -Pi386)
-        elseif(powerpc_build)
-            add_flag_prepend(CMAKE_Pascal_FLAGS -Ppowerpc)
-        else()
-            message(FATAL_ERROR "Unknown architecture present in CMAKE_OSX_ARCHITECTURES (${CMAKE_OSX_ARCHITECTURES})")
-        endif()
-        list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs)
-        if(num_of_archs GREATER 1)
-            message("*** Only one architecture in CMAKE_OSX_ARCHITECTURES is currently supported, picking the first one ***")
-        endif()
-    elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
-        #if that variable is not set check if we are on x86_64 and if so force it, else use default
-        add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64)
-    endif()
-
+if(NOT ${BUILD_ENGINE_LIBRARY} AND APPLE)
     #on OSX we need to provide the SDL_main() function when building as executable
-    if(NOT BUILD_ENGINE_LIBRARY)
-        list(APPEND HW_LINK_LIBS SDLmain)
-        add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
-    endif()
-
-    #when sysroot is set, make sure that fpc picks it
-    if(CMAKE_OSX_SYSROOT)
-        set(add_flag_append "-XD${CMAKE_OSX_SYSROOT}")
-    endif(CMAKE_OSX_SYSROOT)
-endif(APPLE)
+    add_subdirectory(sdlmain)
+    list(APPEND HW_LINK_LIBS SDLmain)
+    add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
+endif()
 
 if(FFMPEG_FOUND)
     add_subdirectory(avwrapper)
     list(APPEND HW_LINK_LIBS avwrapper)
     add_definitions(-dUSE_VIDEO_RECORDING)
     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
+    #only for SDL < 2, linking carried out by fpc
+    find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built")
 endif()
 
 find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
 if(PNG_FOUND)
+    list(INSERT engine_sources 0 PNGh.pas)
     list(REMOVE_AT PNG_LIBRARIES 1) #removing the zlib library path
     get_filename_component(PNG_LIBRARY_DIR ${PNG_LIBRARIES} PATH)
     add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIBRARY_DIR})
@@ -189,7 +168,7 @@
 
 #SOURCE AND PROGRAMS SECTION
 if(BUILD_ENGINE_LIBRARY)
-    message(${WARNING} "Engine will be built as library (experimental)")
+    message("***Engine will be built as library (experimental)***")
     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
         # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
         add_flag_prepend(CMAKE_Pascal_FLAGS "-k-no_order_inits")