Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CMakeLists.txt 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # Include directory
  2. include_directories ("${PROJECT_SOURCE_DIR}/include")
  3. # Include External Modules
  4. set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
  5. # Warnings
  6. set (WARNINGS "${WARNINGS} -Weverything -Wno-padded -Wno-packed")
  7. set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
  8. set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
  9. set (WARNINGS "${WARNINGS} -Wno-missing-prototypes -Wno-missing-variable-declarations")
  10. set (WARNINGS "${WARNINGS} -Wno-disabled-macro-expansion")
  11. set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
  12. # Flags for all builds
  13. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
  14. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -g -O0 ${WARNINGS}")
  15. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DDEBUG")
  16. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUNIT_TEST")
  17. #################################################################
  18. # TGA Test
  19. set (TGASRCS "${PROJECT_SOURCE_DIR}/test/tga.cpp" "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp")
  20. add_executable (TGATest EXCLUDE_FROM_ALL ${TGASRCS})
  21. set_target_properties (TGATest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  22. #################################################################
  23. # Add OpenAL Library
  24. find_package (OpenAL REQUIRED)
  25. include_directories (SYSTEM ${OPENAL_INCLUDE_DIRS})
  26. set (SOUNDLIBS ${SOUNDLIBS} ${OPENAL_LIBRARIES})
  27. # Add ALUT Library
  28. find_package (ALUT REQUIRED)
  29. include_directories (SYSTEM ${ALUT_INCLUDE_DIRS})
  30. set (SOUNDLIBS ${SOUNDLIBS} ${ALUT_LIBRARIES})
  31. # Sound Test
  32. set (SOUNDSRCS "${PROJECT_SOURCE_DIR}/test/Sound.cpp" "${PROJECT_SOURCE_DIR}/src/Sound.cpp")
  33. add_executable (SoundTest EXCLUDE_FROM_ALL ${SOUNDSRCS})
  34. set_target_properties (SoundTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  35. target_link_libraries (SoundTest ${SOUNDLIBS})
  36. #################################################################
  37. # Add Thread Library
  38. find_package (Threads REQUIRED)
  39. set (THREADLIBS ${THREADLIBS} ${CMAKE_THREAD_LIBS_INIT})
  40. # Network Test
  41. set (NETWORKSRCS "${PROJECT_SOURCE_DIR}/test/Network.cpp" "${PROJECT_SOURCE_DIR}/src/Network.cpp")
  42. set (NETWORKSRCS ${NETWORKSRCS} "${PROJECT_SOURCE_DIR}/src/utils/math.cpp" "${PROJECT_SOURCE_DIR}/src/Vector3d.cpp")
  43. add_executable (NetworkTest EXCLUDE_FROM_ALL ${NETWORKSRCS})
  44. set_target_properties (NetworkTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  45. target_link_libraries (NetworkTest m ${THREADLIBS})
  46. #################################################################
  47. # Math Test
  48. set (MATHSRCS "${PROJECT_SOURCE_DIR}/test/math.cpp" "${PROJECT_SOURCE_DIR}/src/utils/math.cpp" "${PROJECT_SOURCE_DIR}/src/Vector3d.cpp")
  49. add_executable (MathTest EXCLUDE_FROM_ALL ${MATHSRCS})
  50. set_target_properties (MathTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  51. #################################################################
  52. # Matrix Test
  53. set (MATRIXSRCS "${PROJECT_SOURCE_DIR}/test/Matrix.cpp" "${PROJECT_SOURCE_DIR}/src/Matrix.cpp")
  54. set (MATRIXSRCS ${MATRIXSRCS} "${PROJECT_SOURCE_DIR}/src/Vector3d.cpp" "${PROJECT_SOURCE_DIR}/src/utils/math.cpp")
  55. set (MATRIXSRCS ${MATRIXSRCS} "${PROJECT_SOURCE_DIR}/src/Quaternion.cpp")
  56. add_executable (MatrixTest EXCLUDE_FROM_ALL ${MATRIXSRCS})
  57. set_target_properties (MatrixTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  58. target_link_libraries (MatrixTest m)
  59. #################################################################
  60. # Add SDL2 Library
  61. find_package (SDL2 REQUIRED)
  62. include_directories (SYSTEM ${SDL2_INCLUDE_DIR})
  63. set (GLLIBS ${GLLIBS} ${SDL2_LIBRARY})
  64. # Add SDL2_ttf Library
  65. find_package (SDL2TTF REQUIRED)
  66. include_directories (SYSTEM ${SDL2TTF_INCLUDE_DIR})
  67. set (GLLIBS ${GLLIBS} ${SDL2TTF_LIBRARY})
  68. # Add OpenGL Library
  69. find_package (OpenGL REQUIRED)
  70. include_directories (SYSTEM ${OPENGL_INCLUDE_DIRS})
  71. set (GLLIBS ${GLLIBS} ${OPENGL_LIBRARIES})
  72. # GLString Test
  73. set (GLSTRINGSRCS "${PROJECT_SOURCE_DIR}/test/GLString.cpp" "${PROJECT_SOURCE_DIR}/src/GLString.cpp")
  74. set (GLSTRINGSRCS ${GLSTRINGSRCS} "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp" "${PROJECT_SOURCE_DIR}/src/Texture.cpp")
  75. add_executable (GLStringTest EXCLUDE_FROM_ALL ${GLSTRINGSRCS})
  76. set_target_properties (GLStringTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  77. target_link_libraries (GLStringTest m ${GLLIBS})
  78. #################################################################
  79. # Add Z Library
  80. find_package (ZLIB REQUIRED)
  81. include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS})
  82. set (ZLIBS ${ZLIBS} ${ZLIB_LIBRARIES})
  83. # TombRaider Test
  84. set (TOMB_FLAGS "-D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES")
  85. set (TOMBSRCS "${PROJECT_SOURCE_DIR}/test/TombRaider.cpp" "${PROJECT_SOURCE_DIR}/src/TombRaider.cpp")
  86. set (TOMBSRCS ${TOMBSRCS} "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp")
  87. add_executable (TombRaiderTest EXCLUDE_FROM_ALL ${TOMBSRCS})
  88. set_target_properties (TombRaiderTest PROPERTIES COMPILE_FLAGS "${OpenRaider_CXX_FLAGS} ${TOMB_FLAGS}")
  89. target_link_libraries (TombRaiderTest ${ZLIBS})
  90. #################################################################
  91. # Add test build target
  92. add_custom_target (tests)
  93. add_dependencies (tests GLStringTest MathTest MatrixTest NetworkTest SoundTest TGATest TombRaiderTest)
  94. # Add test run target
  95. add_custom_target (testRun echo "Running Unit Tests..."
  96. COMMAND TGATest
  97. COMMAND SoundTest
  98. COMMAND MatrixTest
  99. COMMAND MathTest
  100. COMMAND GLStringTest
  101. )
  102. add_dependencies (testRun tests)
  103. # Add TombRaider regression test target
  104. set (REGTEST_TR1 "~/.OpenRaider/paks/tr1/level1.phd")
  105. set (REGTEST_TR2 "~/.OpenRaider/paks/tr2/unwater.tr2")
  106. #set (REGTEST_TR3 "~/.OpenRaider/paks/tr3/scotland.tr2")
  107. set (REGTEST_TR3 "~/.OpenRaider/paks/tr3/HOUSE.TR2")
  108. set (REGTEST_TR4 "~/.OpenRaider/paks/tr4/angkor1.tr4")
  109. #set (REGTEST_TR5 "~/.OpenRaider/paks/tr5/demo.trc")
  110. set (REGTEST_TR5 "~/.OpenRaider/paks/tr5/andy1.trc")
  111. add_custom_target (testReg echo "Running TombRaider 1 Regression Test..."
  112. COMMAND TombRaiderTest load ${REGTEST_TR1} > ../log.tr1
  113. COMMAND echo "Running TombRaider 2 Regression Test..."
  114. COMMAND TombRaiderTest load ${REGTEST_TR2} > ../log.tr2
  115. COMMAND echo "Running TombRaider 3 Regression Test..."
  116. COMMAND TombRaiderTest load ${REGTEST_TR3} > ../log.tr3
  117. COMMAND echo "Running TombRaider 4 Regression Test..."
  118. COMMAND TombRaiderTest load ${REGTEST_TR4} > ../log.tr4
  119. COMMAND echo "Running TombRaider 5 Regression Test..."
  120. COMMAND TombRaiderTest load ${REGTEST_TR5} > ../log.tr5
  121. )
  122. add_dependencies (testReg TombRaiderTest)
  123. # Clean regression test logs
  124. set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
  125. "../log.tr1;../log.tr2;../log.tr3;../log.tr4;../log.tr5")