hedgewars/CMakeLists.txt
branchwebgl
changeset 9521 8054d9d775fd
parent 9244 bb95e351270c
parent 9339 14f5f3a1e2f7
child 9950 2759212a27de
equal deleted inserted replaced
9282:92af50454cf2 9521:8054d9d775fd
    10 enable_language(Pascal)
    10 enable_language(Pascal)
    11 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
    11 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
    12 include_directories(${CMAKE_CURRENT_BINARY_DIR})
    12 include_directories(${CMAKE_CURRENT_BINARY_DIR})
    13 
    13 
    14 
    14 
       
    15 #set the sources with the correct order of dependencies so that cmake won't be confused
    15 set(engine_sources
    16 set(engine_sources
    16     SDLh.pas
    17     SDLh.pas
    17     uSinTable.pas
    18     uSinTable.pas
    18     uFloat.pas
    19     uFloat.pas
    19     uConsts.pas
    20     uConsts.pas
    20     LuaPas.pas
    21     LuaPas.pas
    21     PNGh.pas
       
    22     uTypes.pas
    22     uTypes.pas
       
    23     uVariables.pas
    23     uUtils.pas
    24     uUtils.pas
    24     uVariables.pas
       
    25     uMisc.pas
    25     uMisc.pas
    26     uConsole.pas
    26     uConsole.pas
       
    27     uCommands.pas
    27     uDebug.pas
    28     uDebug.pas
    28     uCommands.pas
       
    29     uInputHandler.pas
    29     uInputHandler.pas
    30     uTextures.pas
    30     uTextures.pas
    31     uRenderUtils.pas
    31     uRenderUtils.pas
    32     uRender.pas
    32     uRender.pas
    33     uCaptions.pas
    33     uCaptions.pas
    34     uLandTexture.pas
       
    35     uIO.pas
    34     uIO.pas
    36     uChat.pas
    35     uChat.pas
    37     uPhysFSLayer.pas
    36     uPhysFSLayer.pas
    38     uStore.pas
       
    39     uSound.pas
    37     uSound.pas
       
    38     ArgParsers.pas
    40     uRandom.pas
    39     uRandom.pas
    41     uLocale.pas
    40     uLocale.pas
    42     uStats.pas
    41     uStats.pas
    43     uCursor.pas
    42     uCursor.pas
    44     uVideoRec.pas
    43     uVideoRec.pas
    45     uAILandMarks.pas
    44     uAILandMarks.pas
    46     adler32.pas
    45     adler32.pas
    47     uLandTemplates.pas
    46     uLandTemplates.pas
       
    47     uLandTexture.pas
    48     uLandGraphics.pas
    48     uLandGraphics.pas
    49     uLandPainted.pas
    49     uLandPainted.pas
    50     uLandOutline.pas
    50     uLandOutline.pas
    51     uLandGenMaze.pas
    51     uLandGenMaze.pas
       
    52 
       
    53     #this is where dependency tracking becomes hard
       
    54     uStore.pas
       
    55     uAmmos.pas
    52     uLandObjects.pas
    56     uLandObjects.pas
    53     uLand.pas
    57     uLand.pas
    54     uAmmos.pas
    58     uGearsList.pas
    55 
    59     uCollisions.pas
    56     uAIMisc.pas
    60     uAIMisc.pas
    57     uAIActions.pas
    61     uAIActions.pas
       
    62     uAIAmmoTests.pas
    58     uAI.pas
    63     uAI.pas
    59     uWorld.pas
    64     uWorld.pas
       
    65     uVisualGearsList.pas
       
    66     uVisualGearsHandlers.pas
    60     uVisualGears.pas
    67     uVisualGears.pas
    61     uTeams.pas
       
    62 
    68 
    63     uGearsList.pas
       
    64     uCollisions.pas
       
    65     uAIAmmoTests.pas
       
    66     uGears.pas
    69     uGears.pas
    67     uGame.pas
    70     uGame.pas
    68     uCommandHandlers.pas
    71     uCommandHandlers.pas
       
    72     uGearsRender.pas
       
    73     uGearsHedgehog.pas
    69     uGearsHandlers.pas
    74     uGearsHandlers.pas
    70     uGearsHandlersRope.pas
    75     uGearsHandlersRope.pas
    71     uGearsHedgehog.pas
    76     uGearsHandlersMess.pas
    72     uGearsRender.pas
       
    73     uGearsUtils.pas
    77     uGearsUtils.pas
       
    78     uTeams.pas
       
    79 
       
    80     #these interact with everything, so compile last
    74     uScript.pas
    81     uScript.pas
    75     hwengine.pas
    82     hwengine.pas
    76 
    83 
    77     GSHandlers.inc
    84     #we also have uTouch.pas
    78     VGSHandlers.inc
       
    79     ArgParsers.inc
       
    80     options.inc
    85     options.inc
    81     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    86     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    82     )
    87     )
    83 
    88 
    84 
    89 
    97     add_flag_prepend(CMAKE_Pascal_FLAGS_RELEASE -Si)
   102     add_flag_prepend(CMAKE_Pascal_FLAGS_RELEASE -Si)
    98 endif()
   103 endif()
    99 
   104 
   100 
   105 
   101 #DEPENDECIES AND EXECUTABLES SECTION
   106 #DEPENDECIES AND EXECUTABLES SECTION
   102 if(APPLE)
   107 if(NOT ${BUILD_ENGINE_LIBRARY} AND APPLE)
   103     if(CMAKE_OSX_ARCHITECTURES)
       
   104         #parse this system variable and adjust only the powerpc syntax to be compatible with -P
       
   105         string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
       
   106         string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}")
       
   107         string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}")
       
   108         if(x86_64_build)
       
   109             add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64)
       
   110         elseif(i386_build)
       
   111             add_flag_prepend(CMAKE_Pascal_FLAGS -Pi386)
       
   112         elseif(powerpc_build)
       
   113             add_flag_prepend(CMAKE_Pascal_FLAGS -Ppowerpc)
       
   114         else()
       
   115             message(FATAL_ERROR "Unknown architecture present in CMAKE_OSX_ARCHITECTURES (${CMAKE_OSX_ARCHITECTURES})")
       
   116         endif()
       
   117         list(LENGTH CMAKE_OSX_ARCHITECTURES num_of_archs)
       
   118         if(num_of_archs GREATER 1)
       
   119             message("*** Only one architecture in CMAKE_OSX_ARCHITECTURES is currently supported, picking the first one ***")
       
   120         endif()
       
   121     elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
       
   122         #if that variable is not set check if we are on x86_64 and if so force it, else use default
       
   123         add_flag_prepend(CMAKE_Pascal_FLAGS -Px86_64)
       
   124     endif()
       
   125 
       
   126     #on OSX we need to provide the SDL_main() function when building as executable
   108     #on OSX we need to provide the SDL_main() function when building as executable
   127     if(NOT BUILD_ENGINE_LIBRARY)
   109     add_subdirectory(sdlmain)
   128         list(APPEND HW_LINK_LIBS SDLmain)
   110     list(APPEND HW_LINK_LIBS SDLmain)
   129         add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   111     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   130     endif()
   112 endif()
   131 
       
   132     #when sysroot is set, make sure that fpc picks it
       
   133     if(CMAKE_OSX_SYSROOT)
       
   134         set(add_flag_append "-XD${CMAKE_OSX_SYSROOT}")
       
   135     endif(CMAKE_OSX_SYSROOT)
       
   136 endif(APPLE)
       
   137 
   113 
   138 if(FFMPEG_FOUND)
   114 if(FFMPEG_FOUND)
   139     add_subdirectory(avwrapper)
   115     add_subdirectory(avwrapper)
   140     list(APPEND HW_LINK_LIBS avwrapper)
   116     list(APPEND HW_LINK_LIBS avwrapper)
   141     add_definitions(-dUSE_VIDEO_RECORDING)
   117     add_definitions(-dUSE_VIDEO_RECORDING)
   142     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   118     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
       
   119     #only for SDL < 2, linking carried out by fpc
       
   120     find_package_or_disable_msg(GLUT NOVIDEOREC "Video recording will not be built")
   143 endif()
   121 endif()
   144 
   122 
   145 find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
   123 find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
   146 if(PNG_FOUND)
   124 if(PNG_FOUND)
       
   125     list(INSERT engine_sources 0 PNGh.pas)
   147     list(REMOVE_AT PNG_LIBRARIES 1) #removing the zlib library path
   126     list(REMOVE_AT PNG_LIBRARIES 1) #removing the zlib library path
   148     get_filename_component(PNG_LIBRARY_DIR ${PNG_LIBRARIES} PATH)
   127     get_filename_component(PNG_LIBRARY_DIR ${PNG_LIBRARIES} PATH)
   149     add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIBRARY_DIR})
   128     add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIBRARY_DIR})
   150 endif()
   129 endif()
   151 
   130 
   187 #needs to be last
   166 #needs to be last
   188 add_definitions(-dDEBUGFILE)
   167 add_definitions(-dDEBUGFILE)
   189 
   168 
   190 #SOURCE AND PROGRAMS SECTION
   169 #SOURCE AND PROGRAMS SECTION
   191 if(BUILD_ENGINE_LIBRARY)
   170 if(BUILD_ENGINE_LIBRARY)
   192     message(${WARNING} "Engine will be built as library (experimental)")
   171     message("***Engine will be built as library (experimental)***")
   193     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
   172     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
   194         # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
   173         # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
   195         add_flag_prepend(CMAKE_Pascal_FLAGS "-k-no_order_inits")
   174         add_flag_prepend(CMAKE_Pascal_FLAGS "-k-no_order_inits")
   196     endif()
   175     endif()
   197 
   176