StandardProjectSettings.cmake 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Set a default build type if none was specified
  2. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  3. message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
  4. set(CMAKE_BUILD_TYPE
  5. RelWithDebInfo
  6. CACHE STRING "Choose the type of build." FORCE)
  7. # Set the possible values of build type for cmake-gui, ccmake
  8. set_property(
  9. CACHE CMAKE_BUILD_TYPE
  10. PROPERTY STRINGS
  11. "Debug"
  12. "Release"
  13. "MinSizeRel"
  14. "RelWithDebInfo")
  15. endif()
  16. # Generate compile_commands.json to make it easier to work with clang based tools
  17. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  18. option(ENABLE_IPO "Enable Interprocedural Optimization, aka Link Time Optimization (LTO)" OFF)
  19. if(ENABLE_IPO)
  20. include(CheckIPOSupported)
  21. check_ipo_supported(
  22. RESULT
  23. result
  24. OUTPUT
  25. output)
  26. if(result)
  27. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
  28. else()
  29. message(SEND_ERROR "IPO is not supported: ${output}")
  30. endif()
  31. endif()
  32. if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
  33. add_compile_options(-fcolor-diagnostics)
  34. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  35. add_compile_options(-fdiagnostics-color=always)
  36. else()
  37. message(STATUS "No colored compiler diagnostic set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
  38. endif()