Open Source Tomb Raider Engine
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CMakeLists.txt 5.0KB

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