CMakeSetCompilerOptions.cmake 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Require C++14
  2. set( CMAKE_CXX_STANDARD 14 )
  3. set( CMAKE_CXX_STANDARD_REQUIRED ON )
  4. set( CMAKE_CXX_EXTENSIONS NO )
  5. # ccache
  6. # https://crascit.com/2016/04/09/using-ccache-with-cmake/
  7. find_program( CCACHE_PROGRAM ccache )
  8. if ( CCACHE_PROGRAM )
  9. set( CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM} )
  10. set( CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM} )
  11. endif()
  12. #silence all the Qt 5 deprecation warnings
  13. set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
  14. if ( UNIX )
  15. set( CMAKE_POSITION_INDEPENDENT_CODE ON )
  16. add_definitions(-Wno-deprecated-declarations)
  17. elseif( MSVC )
  18. add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D__STDC_LIMIT_MACROS)
  19. option( OPTION_MP_BUILD "Check to activate multithreaded compilation with MSVC" OFF )
  20. if( ${OPTION_MP_BUILD} )
  21. set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}\ /MP)
  22. endif()
  23. #disable SECURE_SCL (see http://channel9.msdn.com/shows/Going+Deep/STL-Iterator-Debugging-and-Secure-SCL/)
  24. set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D _SECURE_SCL=0" ) # disable checked iterators
  25. #use VLD for mem leak checking
  26. option( OPTION_USE_VISUAL_LEAK_DETECTOR "Check to activate compilation (in debug) with Visual Leak Detector" OFF )
  27. if( ${OPTION_USE_VISUAL_LEAK_DETECTOR} )
  28. set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D USE_VLD" )
  29. endif()
  30. endif()