Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. cmake_minimum_required (VERSION 2.8)
  2. project (OpenRaider)
  3. # Version Number
  4. set (OpenRaider_VERSION_MAJOR 0)
  5. set (OpenRaider_VERSION_MINOR 1)
  6. set (OpenRaider_VERSION_MICRO 2)
  7. set (OpenRaider_VERSION_RELEASE -git)
  8. # Build Host
  9. set (OpenRaider_BUILD_HOST ${CMAKE_HOST_SYSTEM})
  10. #################################################################
  11. # Set a default build type if none was specified
  12. if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  13. message(STATUS "Setting build type to 'Debug' as none was specified.")
  14. set(CMAKE_BUILD_TYPE Debug)
  15. endif()
  16. #################################################################
  17. # Configuration Header file
  18. configure_file (
  19. "${PROJECT_SOURCE_DIR}/cmake/Config.h.in"
  20. "${PROJECT_BINARY_DIR}/Config.h"
  21. )
  22. # Include directories
  23. include_directories ("${PROJECT_SOURCE_DIR}/include")
  24. include_directories ("${PROJECT_BINARY_DIR}")
  25. # Include External Modules
  26. set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
  27. #################################################################
  28. # Build warnings
  29. set (WARNINGS "${WARNINGS} -Weverything -Wno-padded -Wno-packed")
  30. set (WARNINGS "${WARNINGS} -Wno-global-constructors -Wno-exit-time-destructors")
  31. set (WARNINGS "${WARNINGS} -Wno-documentation-unknown-command -Wno-c++98-compat-pedantic")
  32. set (WARNINGS "${WARNINGS} -Wno-missing-prototypes -Wno-missing-variable-declarations")
  33. set (WARNINGS "${WARNINGS} -Wno-disabled-macro-expansion")
  34. set (WARNINGS "${WARNINGS} -Wno-shorten-64-to-32 -Wno-sign-conversion")
  35. # Flags for all builds
  36. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -std=c++11 ${WARNINGS}")
  37. set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_EMITTER")
  38. # Flags for Debug build
  39. set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -g -O0")
  40. set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DDEBUG")
  41. set (OpenRaider_CXX_FLAGS_DEBUG "${OpenRaider_CXX_FLAGS_DEBUG} -DEXPERIMENTAL")
  42. # Flags for Releasae builds
  43. set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  44. set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops")
  45. set (OpenRaider_CXX_FLAGS_RELEASE "${OpenRaider_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
  46. #################################################################
  47. # Add subdirectories
  48. add_subdirectory (src)
  49. add_subdirectory (test)
  50. #################################################################
  51. # Target for running the setup
  52. add_custom_target (setup "${PROJECT_SOURCE_DIR}/cmake/setup.sh"
  53. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  54. )
  55. #################################################################
  56. # Target for running cppcheck
  57. set (CHECK_STD "--std=c++11" "--std=posix")
  58. set (CHECK_FLAGS "--quiet" "--force")
  59. set (CHECK_NORMAL "--enable=information,warning,performance,portability")
  60. set (CHECK_FULL "--enable=all")
  61. set (CHECK_CONFIG "--check-config")
  62. add_custom_target (check echo "Running cppcheck..."
  63. COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_STD} ${CHECK_NORMAL} ${PROJECT_SOURCE_DIR}
  64. )
  65. add_custom_target (checkFull echo "Running full cppcheck..."
  66. COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_STD} ${CHECK_FULL} ${PROJECT_SOURCE_DIR}
  67. )
  68. add_custom_target (checkConfig echo "Checking cppcheck config..."
  69. COMMAND cppcheck ${CHECK_FLAGS} "-I${PROJECT_SOURCE_DIR}/include" ${CHECK_CONFIG} ${PROJECT_SOURCE_DIR}
  70. )
  71. #################################################################
  72. # Generate Doxygen Documentation
  73. find_package (Doxygen)
  74. if (DOXYGEN_FOUND)
  75. # Configure the Template Doxyfile for our specific project
  76. configure_file (cmake/Doxyfile.in
  77. ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE)
  78. # Add a custom target to run Doxygen when ever the project is built
  79. add_custom_target (doc
  80. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
  81. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
  82. # Add custom target to create local documentation without graphs
  83. add_custom_target (docLocal
  84. COMMAND sed -i '' "s/HAVE_DOT = YES/HAVE_DOT = NO/g" Doxyfile
  85. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
  86. COMMAND cp -R doc/html/* ${PROJECT_SOURCE_DIR}/../apache/
  87. COMMAND sed -i '' "s/HAVE_DOT = NO/HAVE_DOT = YES/g" Doxyfile
  88. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
  89. # Add custom target to create local documentation with call and caller graphs
  90. add_custom_target (docLocalFull
  91. COMMAND sed -i '' "s/CALL_GRAPH = NO/CALL_GRAPH = YES/g" Doxyfile
  92. COMMAND sed -i '' "s/CALLER_GRAPH = NO/CALLER_GRAPH = YES/g" Doxyfile
  93. COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
  94. COMMAND cp -R doc/html/* ${PROJECT_SOURCE_DIR}/../apache/
  95. COMMAND sed -i '' "s/CALL_GRAPH = YES/CALL_GRAPH = NO/g" Doxyfile
  96. COMMAND sed -i '' "s/CALLER_GRAPH = YES/CALLER_GRAPH = NO/g" Doxyfile
  97. SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
  98. endif (DOXYGEN_FOUND)
  99. # Clean doc files
  100. set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "doc")