Sim

CMakeLists.txt

Sim
Sep 6th, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 4.07 KB | None | 0 0
  1. cmake_minimum_required(VERSION 2.6)
  2.  
  3. ##
  4. ## Project name
  5. ##
  6. PROJECT(ja2smp)
  7.  
  8. ##
  9. ## basic directories
  10. ##
  11. set(SMP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  12. set(SMP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
  13.  
  14. # ==================================================================================================
  15. # Dependencies | defines variables : SMP_DEFINITIONS, SMP_INCLUDE_DIRS, SMP_LIBRARY_DIRS, SMP_LIBRARIES
  16. include( ExternalLibraries.cmake )
  17.  
  18. #if(NOT LIBRARY_OUTPUT_PATH)
  19.   set(LIBRARY_OUTPUT_PATH    ${SMP_BINARY_DIR}/lib)
  20. #endif()
  21.  
  22. #if(NOT EXECUTABLE_OUTPUT_PATH)
  23.   set(EXECUTABLE_OUTPUT_PATH ${SMP_BINARY_DIR}/bin)
  24. #endif()
  25.  
  26. option(SMP_CMAKE_DEBUG "Debug cmake file" OFF)
  27. mark_as_advanced(SMP_CMAKE_DEBUG)
  28.  
  29. set(SMP_DEFINITIONS ${SMP_DEFINITIONS} -DJA2)
  30.  
  31. # ==================================================================================================
  32. # Language
  33.  
  34. ## supported languages
  35. set(SMP_LANGUAGES "Dutch" "English" "French" "German" "Italian" "Polish" "Russian" "Russian Gold")
  36.  
  37. # ask user to select a language from a list
  38. set(SMP_LANGUAGE "English" CACHE STRING "Select language")
  39. set_property(CACHE SMP_LANGUAGE PROPERTY STRINGS ${SMP_LANGUAGES})
  40.  
  41. ## < language , #define > map
  42. set(SMP_LANGUAGE_DEFINES
  43.   "Dutch"        "DUTCH"
  44.   "English"      "ENGLISH"
  45.   "French"       "FRENCH"
  46.   "German"       "GERMAN"
  47.   "Italian"      "ITALIAN"
  48.   "Polish"       "POLISH"
  49.   "Russian"      "RUSSIAN"
  50.   "Russian Gold" "RUSSIAN_GOLD"
  51. )
  52.  
  53. ## set language
  54. set(_next_define false)
  55. set(_current_language "")
  56. foreach(lang ${SMP_LANGUAGE_DEFINES})
  57.     if(_next_define)
  58.         set(_def "-D${lang}")
  59.         message("language : " ${_current_language} ", " ${_def})
  60.         add_definitions( ${_def} )
  61.         break()
  62.     endif()
  63.     string(COMPARE EQUAL ${SMP_LANGUAGE} ${lang} _selected_language)
  64.     if(_selected_language)
  65.         set(_next_define true)
  66.         set(_current_language ${lang})
  67.     endif()
  68. endforeach()
  69. # --------------------------------------------------------------------------------------------------
  70.  
  71. ## MSVC compatibility settings
  72. if(MSVC)
  73.   set(SMP_DEFINITIONS ${SMP_DEFINITIONS} -D_CRT_SECURE_NO_WARNINGS)
  74. endif()
  75.  
  76. ## SMP options
  77. option(JA2_BETA_VERSION "Build BETA version" OFF)
  78. option(SMP_BUILD_EDITOR "Build editor" OFF)
  79. if(SMP_BUILD_EDITOR)
  80.   set(SMP_DEFINITIONS ${SMP_DEFINITIONS}
  81.     -DJA2EDITOR
  82.     -DJA2BETAVERSION
  83.     -DSGP_DEBUG
  84.   )
  85. endif()
  86.  
  87.  
  88. ## define base SMP source directories
  89. set(SMP_SGP_SOURCE_DIR   ${SMP_SOURCE_DIR}/sgp)
  90. set(SMP_BUILD_SOURCE_DIR ${SMP_SOURCE_DIR}/Build)
  91.  
  92. ## define SMP include directories
  93. set( SMP_INCLUDE_DIRS ${SMP_INCLUDE_DIRS}
  94.   ${SMP_SGP_SOURCE_DIR}
  95.   ${SMP_SGP_SOURCE_DIR}/mod_manager
  96.   ${SMP_SGP_SOURCE_DIR}/utils
  97.   ${SMP_SGP_SOURCE_DIR}/xml
  98.   ${SMP_BUILD_SOURCE_DIR}
  99. )
  100.  
  101. ## setup subdirectories of Build
  102. set(SMP_BUILD_DIRS
  103.   "Editor" "Laptop" "Strategic" "Tactical" "TacticalAI" "TileEngine" "Utils"
  104. )
  105.  
  106. ## add "Build" directories to the include directory list
  107. foreach( dir ${SMP_BUILD_DIRS} )
  108.   set( SMP_INCLUDE_DIRS ${SMP_INCLUDE_DIRS} ${SMP_BUILD_SOURCE_DIR}/${dir} )
  109. endforeach()
  110.  
  111. include_directories( ${SMP_INCLUDE_DIRS} )
  112.  
  113. ## setup definitions
  114. add_definitions( ${SMP_DEFINITIONS} )
  115.  
  116. ## setup libraries
  117. link_directories( ${SMP_LIBRARY_DIRS} ${LIBRARY_OUTPUT_PATH})
  118.  
  119. ## fix MinGW linker error
  120. if(MINGW)
  121.   option(SMP_MINGW_AUTO_IMPORT "Activate automatic import of libary symbols" OFF)
  122.   if(SMP_MINGW_AUTO_IMPORT)
  123.     set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-enable-auto-import")
  124.   endif()
  125. endif()
  126.  
  127. ## fix MSVC debug compiler flags
  128. if(MSVC)
  129.   string (REPLACE "/D_DEBUG" "/D_DEBUG /DSGP_DEBUG" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )
  130.   if(JA2_BETA_VERSION)
  131.     string (REPLACE "/D_DEBUG" "/D_DEBUG /DSGP_DEBUG /DJA2BETAVERSION" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} )
  132.   endif()
  133. else()
  134.   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSGP_DEBUG")
  135.   if(JA2_BETA_VERSION)
  136.     set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSGP_DEBUG -DJA2BETAVERSION")
  137.   endif()
  138. endif()
  139.  
  140. ## go into subdirectories
  141. add_subdirectory(${SMP_SGP_SOURCE_DIR})
  142. add_subdirectory(${SMP_BUILD_SOURCE_DIR})
Advertisement
Add Comment
Please, Sign In to add comment