Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CMakeLists.txt 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. # Flags for all builds
  6. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11")
  7. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -g -O0 ${WARNINGS}")
  8. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DDEBUG")
  9. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUNIT_TEST")
  10. #################################################################
  11. # TGA Test
  12. set (TGASRCS "${PROJECT_SOURCE_DIR}/test/tga.cpp" "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp")
  13. add_executable (TGATest EXCLUDE_FROM_ALL ${TGASRCS})
  14. set_target_properties (TGATest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  15. #################################################################
  16. # Add OpenAL Library
  17. find_package (OpenAL REQUIRED)
  18. include_directories (SYSTEM ${OPENAL_INCLUDE_DIRS})
  19. set (SOUNDLIBS ${SOUNDLIBS} ${OPENAL_LIBRARIES})
  20. # Add ALUT Library
  21. find_package (ALUT REQUIRED)
  22. include_directories (SYSTEM ${ALUT_INCLUDE_DIRS})
  23. set (SOUNDLIBS ${SOUNDLIBS} ${ALUT_LIBRARIES})
  24. # Sound Test
  25. set (SOUNDSRCS "${PROJECT_SOURCE_DIR}/test/Sound.cpp" "${PROJECT_SOURCE_DIR}/src/Sound.cpp")
  26. add_executable (SoundTest EXCLUDE_FROM_ALL ${SOUNDSRCS})
  27. set_target_properties (SoundTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  28. target_link_libraries (SoundTest ${SOUNDLIBS})
  29. #################################################################
  30. # Math Test
  31. set (MATHSRCS "${PROJECT_SOURCE_DIR}/test/math.cpp" "${PROJECT_SOURCE_DIR}/src/utils/math.cpp" "${PROJECT_SOURCE_DIR}/src/Vector3d.cpp")
  32. add_executable (MathTest EXCLUDE_FROM_ALL ${MATHSRCS})
  33. set_target_properties (MathTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  34. #################################################################
  35. # Matrix Test
  36. set (MATRIXSRCS "${PROJECT_SOURCE_DIR}/test/Matrix.cpp" "${PROJECT_SOURCE_DIR}/src/Matrix.cpp")
  37. set (MATRIXSRCS ${MATRIXSRCS} "${PROJECT_SOURCE_DIR}/src/Vector3d.cpp" "${PROJECT_SOURCE_DIR}/src/utils/math.cpp")
  38. set (MATRIXSRCS ${MATRIXSRCS} "${PROJECT_SOURCE_DIR}/src/Quaternion.cpp")
  39. add_executable (MatrixTest EXCLUDE_FROM_ALL ${MATRIXSRCS})
  40. set_target_properties (MatrixTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  41. target_link_libraries (MatrixTest m)
  42. #################################################################
  43. # Add SDL2 Library
  44. find_package (SDL2 REQUIRED)
  45. include_directories (SYSTEM ${SDL2_INCLUDE_DIR})
  46. set (GLLIBS ${GLLIBS} ${SDL2_LIBRARY})
  47. # Add SDL2_ttf Library
  48. find_package (SDL2TTF REQUIRED)
  49. include_directories (SYSTEM ${SDL2TTF_INCLUDE_DIR})
  50. set (GLLIBS ${GLLIBS} ${SDL2TTF_LIBRARY})
  51. # Add OpenGL Library
  52. find_package (OpenGL REQUIRED)
  53. include_directories (SYSTEM ${OPENGL_INCLUDE_DIRS})
  54. set (GLLIBS ${GLLIBS} ${OPENGL_LIBRARIES})
  55. # GLString Test
  56. set (GLSTRINGSRCS "${PROJECT_SOURCE_DIR}/test/GLString.cpp" "${PROJECT_SOURCE_DIR}/src/GLString.cpp")
  57. set (GLSTRINGSRCS ${GLSTRINGSRCS} "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp" "${PROJECT_SOURCE_DIR}/src/Texture.cpp")
  58. add_executable (GLStringTest EXCLUDE_FROM_ALL ${GLSTRINGSRCS})
  59. set_target_properties (GLStringTest PROPERTIES COMPILE_FLAGS ${OpenRaider_CXX_FLAGS})
  60. target_link_libraries (GLStringTest m ${GLLIBS})
  61. #################################################################
  62. # Add Z Library
  63. find_package (ZLIB REQUIRED)
  64. include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS})
  65. set (ZLIBS ${ZLIBS} ${ZLIB_LIBRARIES})
  66. # TombRaider Test
  67. set (TOMB_FLAGS "-D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES")
  68. set (TOMBSRCS "${PROJECT_SOURCE_DIR}/test/TombRaider.cpp" "${PROJECT_SOURCE_DIR}/src/TombRaider.cpp")
  69. set (TOMBSRCS ${TOMBSRCS} "${PROJECT_SOURCE_DIR}/src/utils/tga.cpp")
  70. add_executable (TombRaiderTest EXCLUDE_FROM_ALL ${TOMBSRCS})
  71. set_target_properties (TombRaiderTest PROPERTIES COMPILE_FLAGS "${OpenRaider_CXX_FLAGS} ${TOMB_FLAGS}")
  72. target_link_libraries (TombRaiderTest ${ZLIBS})
  73. #################################################################
  74. # Add test build target
  75. add_custom_target (tests)
  76. add_dependencies (tests GLStringTest MathTest MatrixTest SoundTest TGATest TombRaiderTest)
  77. # Add test run target
  78. add_custom_target (testRun echo "Running Unit Tests..."
  79. COMMAND TGATest
  80. COMMAND SoundTest
  81. COMMAND MatrixTest
  82. COMMAND MathTest
  83. COMMAND GLStringTest
  84. )
  85. add_dependencies (testRun tests)
  86. # Add TombRaider regression test target
  87. set (REGTEST_TR1 "~/.OpenRaider/paks/tr1/level1.phd")
  88. set (REGTEST_TR2 "~/.OpenRaider/paks/tr2/unwater.tr2")
  89. #set (REGTEST_TR3 "~/.OpenRaider/paks/tr3/scotland.tr2")
  90. set (REGTEST_TR3 "~/.OpenRaider/paks/tr3/HOUSE.TR2")
  91. set (REGTEST_TR4 "~/.OpenRaider/paks/tr4/angkor1.tr4")
  92. #set (REGTEST_TR5 "~/.OpenRaider/paks/tr5/demo.trc")
  93. set (REGTEST_TR5 "~/.OpenRaider/paks/tr5/andy1.trc")
  94. add_custom_target (testReg echo "Running TombRaider 1 Regression Test..."
  95. COMMAND TombRaiderTest load ${REGTEST_TR1} > ../log.tr1
  96. COMMAND echo "Running TombRaider 2 Regression Test..."
  97. COMMAND TombRaiderTest load ${REGTEST_TR2} > ../log.tr2
  98. COMMAND echo "Running TombRaider 3 Regression Test..."
  99. COMMAND TombRaiderTest load ${REGTEST_TR3} > ../log.tr3
  100. COMMAND echo "Running TombRaider 4 Regression Test..."
  101. COMMAND TombRaiderTest load ${REGTEST_TR4} > ../log.tr4
  102. COMMAND echo "Running TombRaider 5 Regression Test..."
  103. COMMAND TombRaiderTest load ${REGTEST_TR5} > ../log.tr5
  104. )
  105. add_dependencies (testReg TombRaiderTest)
  106. # Clean regression test logs
  107. set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
  108. "../log.tr1;../log.tr2;../log.tr3;../log.tr4;../log.tr5")