CMakeLists.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. cmake_minimum_required(VERSION 3.10)
  2. set(TARGET lynarmoon)
  3. project(${TARGET})
  4. message("Building ${TARGET}:")
  5. ######################################################
  6. # detect architecture, set ARCHITECTURE to X86 or X64
  7. ######################################################
  8. set(X86 "1")
  9. set(X64 "2")
  10. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  11. set(ARCHITECTURE X64)
  12. elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
  13. set(ARCHITECTURE X86)
  14. endif()
  15. message("Selected architecture: ${ARCHITECTURE}")
  16. ######################################################
  17. # specify OS
  18. ######################################################
  19. if(NOT UNIX AND NOT APPLE OR CYGWIN)
  20. set(WIN32 TRUE)
  21. message("Selected OS: Windows")
  22. else(NOT APPLE)
  23. set(LINUX TRUE)
  24. message("Selected OS: Linux")
  25. endif()
  26. ######################################################
  27. # set SDL paths
  28. ######################################################
  29. set(SDL_MINGW64_PATH ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/bin_lib/MinGW/x64)
  30. set(SDL_MINGW32_PATH ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/bin_lib/MinGW/x86)
  31. set(SDL_VC64_PATH ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/bin_lib/VisualStudio/x64)
  32. set(SDL_VC32_PATH ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/bin_lib/VisualStudio/x86)
  33. ######################################################
  34. # compiler flags
  35. ######################################################
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
  37. message("Building with flags: ${CMAKE_CXX_FLAGS}")
  38. ######################################################
  39. #include directories
  40. ######################################################
  41. if(LINUX)
  42. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/dirhandler/linux)
  43. endif()
  44. if(WIN32)
  45. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/dirhandler/windows)
  46. endif()
  47. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/lynarmath/LynarMath)
  48. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/tfhandler/include)
  49. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/clock/include)
  50. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/src/SDL2/include)
  51. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/src/SDL2_image)
  52. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/src/SDL2_mixer)
  53. include_directories(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/SDL/src/SDL2_ttf)
  54. message("adding include directories...")
  55. ######################################################
  56. # include other CMakeLists.txt
  57. ######################################################
  58. include(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/lynarmath/CMakeLists.txt)
  59. include(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/tfhandler/CMakeLists.txt)
  60. include(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/dirhandler/CMakeLists.txt)
  61. include(${CMAKE_CURRENT_LIST_DIR}/LynarMoon/lib/clock/CMakeLists.txt)
  62. ######################################################
  63. # build library
  64. ######################################################
  65. message("build library...")
  66. add_library(${TARGET}
  67. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/LynarMoon.h
  68. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/LynarMoon.cpp
  69. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorCodes.h
  70. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Global.h
  71. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/OperatingSystem.h
  72. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/BuildMode.h
  73. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Date/DateHandler.h
  74. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Date/DateHandler.cpp
  75. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Date/MonthDaysList.h
  76. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/DateFormatHandler/DateFormatHandler.h
  77. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/DateFormatHandler/DateFormatHandler.cpp
  78. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/File/FileCreator.h
  79. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/File/FileCreator.cpp
  80. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/File/LogFileHandler.h
  81. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/File/LogFileHandler.cpp
  82. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/File/tinydir.h
  83. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/ThreadSafety/ThreadSafeSharedPtr.h
  84. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Window.cpp
  85. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorMessage.h
  86. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorList.cpp
  87. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorList.h
  88. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorHandler.h
  89. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/MessageBox/MessageBox.h
  90. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/MessageBox/MessageBox.cpp
  91. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Error/ErrorHandler.cpp
  92. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Mouse/MouseModule.h
  93. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Mouse/MouseModule.cpp
  94. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Keyboard/KeyboardModule.h
  95. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Keyboard/KeyboardModule.cpp
  96. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Keyboard/KeyboardKeys.h
  97. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Color/Color.h
  98. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Color/ColorValue.h
  99. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Color/Color.cpp
  100. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/TimeEvent/TimeEventModule.h
  101. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/TimeEvent/TimeEventModule.cpp
  102. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/List/SmartList.h
  103. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Interface/IdentifiedObject.h
  104. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/TimeEventLayer.cpp
  105. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Sound/SoundModule.cpp
  106. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Sound/SoundModule.h
  107. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/SoundLayer.cpp
  108. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Music/MusicModule.h
  109. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Music/MusicModule.cpp
  110. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/MusicLayer.cpp
  111. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Font/FontModule.h
  112. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Font/FontModule.cpp
  113. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/FontLayer.cpp
  114. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Zindex/ZindexInfo.h
  115. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Module.h
  116. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Zindex/Zindex.h
  117. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Zindex/Zindex.cpp
  118. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Line/LineModule.h
  119. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Line/LineModule.cpp
  120. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/LineLayer.cpp
  121. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Renderer/LineRendererInfo.h
  122. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Point/PointModule.h
  123. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Renderer/PointRendererInfo.h
  124. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Point/PointModule.cpp
  125. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Transformation/Direction.h
  126. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Transformation/Direction.cpp
  127. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/PointLayer.cpp
  128. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Renderer/TextRendererInfo.h
  129. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Texture/Texture.h
  130. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Texture/Texture.cpp
  131. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Text/TextModule.h
  132. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Text/TextModule.cpp
  133. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/TextLayer.cpp
  134. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Model/ModelModule.h
  135. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Renderer/ModelRendererInfo.h
  136. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Model/ModelModule.cpp
  137. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/ModuleLayer/ModelLayer.cpp
  138. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SetUp/SetUp.h
  139. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SetUp/SetUp.cpp
  140. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Sort/Sort.h
  141. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Texture/PartialTextureArea.h
  142. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Texture/PartialTextureArea.cpp
  143. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SDLCommunicator/SDLCommunicator.h
  144. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SDLCommunicator/SDLCommunicator.cpp
  145. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Model/ModelCloneModule.h
  146. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Module/Model/ModelCloneModule.cpp
  147. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/Renderer/ModelCloneRendererInfo.h
  148. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SDLHandler/SDLHandler.h
  149. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/engine/SDLHandler/SDLHandler.cpp
  150. ${CMAKE_CURRENT_LIST_DIR}/LynarMoon/tools/Color/ColorMask.h)
  151. ######################################################
  152. # link engine libraries
  153. ######################################################
  154. message("link ${TARGET} libraries...")
  155. target_link_libraries(${TARGET} PUBLIC atomic lynarmath dirhandler tfhandler clock)
  156. message("link SDL libraries...")
  157. ######################################################
  158. # x86
  159. ######################################################
  160. if(${ARCHITECTURE} STREQUAL ${X86})
  161. message("\tSDL x86...")
  162. if(MINGW)
  163. message("\t\tlinking MinGW...")
  164. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW32_PATH}/libSDL2.dll.a")
  165. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW32_PATH}/libSDL2main.a")
  166. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW32_PATH}/libSDL2_image.dll.a")
  167. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW32_PATH}/libSDL2_mixer.dll.a")
  168. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW32_PATH}/libSDL2_ttf.dll.a")
  169. endif()
  170. if(MSVC)
  171. message("\t\tlinking Visual Studio...")
  172. target_link_libraries(${TARGET} PUBLIC "${SDL_VC32_PATH}/SDL2.lib")
  173. target_link_libraries(${TARGET} PUBLIC "${SDL_VC32_PATH}/SDL2main.lib")
  174. target_link_libraries(${TARGET} PUBLIC "${SDL_VC32_PATH}/SDL2_image.lib")
  175. target_link_libraries(${TARGET} PUBLIC "${SDL_VC32_PATH}/SDL2_mixer.lib")
  176. target_link_libraries(${TARGET} PUBLIC "${SDL_VC32_PATH}/SDL2_ttf.lib")
  177. endif()
  178. else()
  179. message("\tx86 skipped!")
  180. endif()
  181. ######################################################
  182. # x64
  183. ######################################################
  184. if(${ARCHITECTURE} STREQUAL ${X64})
  185. message("\tSDL x64...")
  186. if(MINGW)
  187. message("\t\tlinking MinGW...")
  188. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW64_PATH}/libSDL2.dll.a")
  189. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW64_PATH}/libSDL2main.a")
  190. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW64_PATH}/libSDL2_image.dll.a")
  191. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW64_PATH}/libSDL2_mixer.dll.a")
  192. target_link_libraries(${TARGET} PUBLIC "${SDL_MINGW64_PATH}/libSDL2_ttf.dll.a")
  193. endif()
  194. if(MSVC)
  195. message("\t\tlinking Visual Studio...")
  196. target_link_libraries(${TARGET} PUBLIC "${SDL_VC64_PATH}/SDL2.lib")
  197. target_link_libraries(${TARGET} PUBLIC "${SDL_VC64_PATH}/SDL2main.lib")
  198. target_link_libraries(${TARGET} PUBLIC "${SDL_VC64_PATH}/SDL2_image.lib")
  199. target_link_libraries(${TARGET} PUBLIC "${SDL_VC64_PATH}/SDL2_mixer.lib")
  200. target_link_libraries(${TARGET} PUBLIC "${SDL_VC64_PATH}/SDL2_ttf.lib")
  201. endif()
  202. else()
  203. message("\tx64 skipped!")
  204. endif()
  205. ######################################################
  206. # Linux
  207. ######################################################
  208. if(LINUX)
  209. message("\t\tlinking Linux...")
  210. target_link_libraries(${TARGET} PUBLIC SDL2 SDL2main SDL2_image SDL2_mixer SDL2_ttf)
  211. endif()