Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 8.63 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.7)
  2.  
  3. include(CMake/out_of_tree.cmake)
  4.  
  5. project(devilutionX
  6.   VERSION 0.0.1
  7.   LANGUAGES C CXX)
  8.  
  9. list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake")
  10.  
  11. if(NOT CMAKE_BUILD_TYPE)
  12.   set(CMAKE_BUILD_TYPE "Debug")
  13. endif()
  14.  
  15. option(ASAN "Enable address sanitizer" ON)
  16. option(DEBUG "Enable debug mode in engine" ON)
  17. option(DIST "Dynamically link only glibc and SDL2" OFF)
  18. option(FASTER "Enable FASTER in engine" ON)
  19. option(BINARY_RELEASE "Enable options for binary release" OFF)
  20. option(NIGHTLY_BUILD "Enable options for nightly build" OFF)
  21.  
  22. if(BINARY_RELEASE)
  23.   set(CMAKE_BUILD_TYPE "Release")
  24.   set(ASAN OFF)
  25.   set(DEBUG OFF)
  26.   set(DIST ON)
  27.   set(FASTER OFF)
  28. endif()
  29.  
  30. if(NIGHTLY_BUILD)
  31.   set(CMAKE_BUILD_TYPE "Debug")
  32.   set(ASAN OFF)
  33.   set(DEBUG ON)
  34.   set(DIST ON)
  35.   set(FASTER ON)
  36. endif()
  37.  
  38. if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
  39.   set(ASAN OFF)
  40.   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate")
  41. endif()
  42.  
  43. if(WIN32)
  44.   set(ASAN OFF)
  45.   set(DIST ON)
  46. endif()
  47.  
  48. if(HAIKU)
  49.   set(ASAN OFF)
  50. endif()
  51.  
  52. if(DIST)
  53.   set(sodium_USE_STATIC_LIBS ON)
  54. endif()
  55.  
  56. set(CMAKE_CXX_STANDARD 14)
  57. set(CMAKE_CXX_EXTENSIONS OFF)
  58. set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
  59. set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  60. set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  61.  
  62. if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
  63.   message(WARNING "sizeof(void*) == ${CMAKE_SIZEOF_VOID_P}.")
  64.   message(WARNING [[Not 32-bit, highly experimental!]])
  65. endif()
  66.  
  67. find_package(Threads REQUIRED)
  68. # find_package(SDL CONFIG QUIET)
  69. find_package(SDL REQUIRED)
  70. if (NOT SDL_FOUND)
  71.     find_package(SDL REQUIRED)
  72. endif()
  73. find_package(SDL_ttf REQUIRED)
  74. find_package(SDL_mixer REQUIRED)
  75. #find_package(sodium REQUIRED)
  76.  
  77. link_directories( /home/klaus/Sources/devilutionX/ )
  78. set(PROJECT_LINK_LIBS libSDL.so)
  79.  
  80. add_library(smacker STATIC
  81.   3rdParty/libsmacker/smk_bitstream.c
  82.   3rdParty/libsmacker/smk_hufftree.c
  83.   3rdParty/libsmacker/smacker.c)
  84.  
  85. add_library(Radon STATIC
  86.   3rdParty/Radon/Radon/source/File.cpp
  87.   3rdParty/Radon/Radon/source/Key.cpp
  88.   3rdParty/Radon/Radon/source/Named.cpp
  89.   3rdParty/Radon/Radon/source/Section.cpp)
  90.  
  91. add_library(StormLib STATIC
  92.   3rdParty/StormLib/src/FileStream.cpp
  93.   3rdParty/StormLib/src/SBaseCommon.cpp
  94.   3rdParty/StormLib/src/SBaseFileTable.cpp
  95.   3rdParty/StormLib/src/SBaseSubTypes.cpp
  96.   3rdParty/StormLib/src/SCompression.cpp
  97.   3rdParty/StormLib/src/SFileExtractFile.cpp
  98.   3rdParty/StormLib/src/SFileFindFile.cpp
  99.   3rdParty/StormLib/src/SFileGetFileInfo.cpp
  100.   3rdParty/StormLib/src/SFileOpenArchive.cpp
  101.   3rdParty/StormLib/src/SFileOpenFileEx.cpp
  102.   3rdParty/StormLib/src/SFileReadFile.cpp)
  103.  
  104. add_library(PKWare STATIC
  105.   3rdParty/PKWare/explode.cpp
  106.   3rdParty/PKWare/implode.cpp)
  107.  
  108. add_library(devilution STATIC
  109.   Source/appfat.cpp
  110.   Source/automap.cpp
  111.   Source/capture.cpp
  112.   Source/codec.cpp
  113.   Source/control.cpp
  114.   Source/cursor.cpp
  115.   Source/dead.cpp
  116.   Source/debug.cpp
  117.   Source/diablo.cpp
  118.   Source/doom.cpp
  119. # Source/dx.cpp
  120.   Source/drlg_l1.cpp
  121.   Source/drlg_l2.cpp
  122.   Source/drlg_l3.cpp
  123.   Source/drlg_l4.cpp
  124.   Source/dthread.cpp
  125.   Source/effects.cpp
  126.   Source/encrypt.cpp
  127.   Source/engine.cpp
  128.   Source/error.cpp
  129.   Source/fault.cpp
  130.   Source/gamemenu.cpp
  131.   Source/gendung.cpp
  132.   Source/gmenu.cpp
  133.   Source/help.cpp
  134.   Source/init.cpp
  135.   Source/interfac.cpp
  136.   Source/inv.cpp
  137.   Source/itemdat.cpp
  138.   Source/items.cpp
  139.   Source/lighting.cpp
  140.   Source/loadsave.cpp
  141.   Source/logging.cpp
  142.   Source/mainmenu.cpp
  143.   Source/minitext.cpp
  144.   Source/misdat.cpp
  145.   Source/missiles.cpp
  146.   Source/monstdat.cpp
  147.   Source/monster.cpp
  148.   Source/movie.cpp
  149.   Source/mpqapi.cpp
  150.   Source/msgcmd.cpp
  151.   Source/msg.cpp
  152.   Source/multi.cpp
  153.   Source/nthread.cpp
  154.   Source/objdat.cpp
  155.   Source/objects.cpp
  156.   Source/pack.cpp
  157.   Source/palette.cpp
  158.   Source/path.cpp
  159.   Source/pfile.cpp
  160.   Source/player.cpp
  161.   Source/plrmsg.cpp
  162.   Source/portal.cpp
  163.   Source/spelldat.cpp
  164.   Source/quests.cpp
  165.   Source/render.cpp
  166.   Source/restrict.cpp
  167.   Source/scrollrt.cpp
  168.   Source/setmaps.cpp
  169.   Source/sha.cpp
  170. # Source/sound.cpp
  171.   Source/spells.cpp
  172.   Source/stores.cpp
  173.   Source/sync.cpp
  174.   Source/textdat.cpp
  175.   Source/themes.cpp
  176.   Source/tmsg.cpp
  177.   Source/town.cpp
  178.   Source/towners.cpp
  179.   Source/track.cpp
  180.   Source/trigs.cpp
  181.   Source/wave.cpp)
  182.  
  183. add_executable(devilutionx
  184.   SourceX/dx.cpp
  185.   SourceX/miniwin/misc.cpp
  186.   SourceX/miniwin/misc_io.cpp
  187.   SourceX/miniwin/misc_msg.cpp
  188.   SourceX/miniwin/misc_dx.cpp
  189.   SourceX/miniwin/rand.cpp
  190.   SourceX/miniwin/thread.cpp
  191. #  SourceX/miniwin/dsound.cpp
  192.   SourceX/miniwin/ddraw.cpp
  193. #  SourceX/sound.cpp
  194.   SourceX/storm/storm.cpp
  195.   SourceX/storm/storm_net.cpp
  196.   SourceX/storm/storm_dx.cpp
  197. #   SourceX/dvlnet/abstract_net.cpp
  198. #   SourceX/dvlnet/loopback.cpp
  199. #   SourceX/dvlnet/packet.cpp
  200. #   SourceX/dvlnet/base.cpp
  201. #   SourceX/dvlnet/frame_queue.cpp
  202. #   SourceX/dvlnet/tcp_client.cpp
  203. #   SourceX/dvlnet/tcp_server.cpp
  204. #   SourceX/dvlnet/udp_p2p.cpp
  205.   SourceX/DiabloUI/credits.cpp
  206.   SourceX/DiabloUI/diabloui.cpp
  207.   SourceX/DiabloUI/dialogs.cpp
  208.   SourceX/DiabloUI/mainmenu.cpp
  209.   SourceX/DiabloUI/progress.cpp
  210.   SourceX/DiabloUI/selconn.cpp
  211.   SourceX/DiabloUI/selgame.cpp
  212.   SourceX/DiabloUI/selhero.cpp
  213.   SourceX/DiabloUI/title.cpp
  214.   SourceX/main.cpp)
  215.  
  216. target_include_directories(devilution PUBLIC Source SourceS )
  217.  
  218. target_include_directories(devilutionx PRIVATE
  219.   SourceX
  220.   3rdParty/asio/include
  221.   3rdParty/Radon/Radon/include
  222.   3rdParty/libsmacker
  223.   ${SDL_INCLUDE_DIRS})
  224.  
  225.  
  226. target_link_libraries(devilution PUBLIC Threads::Threads)
  227. target_link_libraries(devilutionx PRIVATE
  228.   devilution
  229.   PKWare
  230.   StormLib
  231.   smacker
  232.   Radon
  233.   ${SDL_LIBRARY}
  234.   )
  235.   # ${PROJECT_SOURCE_DIR}/libSDLmain.a)
  236.   # /usr/lib/x86_64-linux-gnu/libSDLmain.a
  237.   # ${SDL_LIBRARY}
  238.   # `sdl-config --libs`
  239.   # ${`sdl-config --libs`}
  240.   # SDL2::SDL2main
  241.   # SDL2::SDL2_ttf
  242.   # SDL2::SDL2_mixer
  243.   # sodium)
  244.  
  245. target_compile_definitions(devilution PRIVATE DEVILUTION_ENGINE)
  246. target_compile_definitions(devilution PUBLIC
  247.   DEVILUTION_STUB
  248.   "$<$<BOOL:${DEBUG}>:_DEBUG>"
  249.   # Skip fades and other fluff
  250.   "$<$<BOOL:${FASTER}>:FASTER>")
  251. target_compile_definitions(devilutionx PRIVATE ASIO_STANDALONE)
  252.  
  253. if(ASAN)
  254.   target_compile_options(devilution PUBLIC -fsanitize=address -fsanitize-recover=address)
  255.   target_link_libraries(devilution PUBLIC -fsanitize=address -fsanitize-recover=address)
  256. endif()
  257.  
  258. if(DIST AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  259.   target_link_libraries(devilutionx PUBLIC -static-libgcc -static-libstdc++)
  260. endif()
  261.  
  262. if(WIN32)
  263.   target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet)
  264.  
  265.   if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  266.     target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-gstabs>)
  267.   endif()
  268. endif()
  269.  
  270. if(HAIKU)
  271.   target_link_libraries(devilutionx PRIVATE network)
  272. endif()
  273.  
  274. if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  275.   # Note: In Debug mode, GCC generates spurious memory references that upset Valgrind,
  276.   # these options fix that.
  277.   target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-fno-omit-frame-pointer>)
  278.   target_compile_options(devilution PUBLIC -Wno-unknown-pragmas)
  279.   # Ignore serious warnings due to "quality" of decompiled code
  280.   # Currently, disable ignore all warnings (-w), to be removed later
  281.   target_compile_options(devilution PRIVATE -fpermissive -Wno-write-strings -Wno-multichar -w)
  282.   # Disable optimizations that can break non-standards-conforming code
  283.   target_compile_options(devilution PRIVATE -fno-strict-aliasing)
  284.  
  285.   # Warnings for devilutionX
  286.   target_compile_options(devilutionx PRIVATE -Wall -Wextra -Wno-write-strings -Wno-multichar -Wno-unused-parameter)
  287.  
  288.   target_compile_options(devilution PRIVATE -fsigned-char)
  289.   target_compile_options(devilutionx PRIVATE -fsigned-char)
  290. endif()
  291.  
  292. if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  293.   target_compile_options(devilution PRIVATE "/W0")
  294. endif()
  295.  
  296. if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  297.   target_compile_options(devilution PRIVATE -fno-aggressive-loop-optimizations)
  298. endif()
  299.  
  300. if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  301.   # Style issues
  302.   target_compile_options(devilutionx PRIVATE -Wno-parentheses -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses)
  303.   # Silence warnings about __int64 alignment hack not always being applicable
  304.   target_compile_options(devilutionx PRIVATE -Wno-ignored-attributes)
  305.   # Fix: error: cast from pointer to smaller type 'unsigned char' loses information
  306.   target_compile_options(devilution PRIVATE -fms-extensions -fms-compatibility -fms-compatibility-version=19.00)
  307.     # Silence appfat.cpp warnings
  308.   set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wno-narrowing")
  309. endif()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement