CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. option(GLM_QUIET "No CMake Message" OFF)
  2. option(GLM_TEST_ENABLE "Build unit tests" ON)
  3. option(GLM_PERF_TEST_ENABLE "Build perf tests" OFF)
  4. # Compiler and default options
  5. if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  6. if(NOT GLM_QUIET)
  7. message("GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler")
  8. endif()
  9. if(NOT GLM_DISABLE_AUTO_DETECTION)
  10. add_compile_options(-Werror -Weverything)
  11. endif()
  12. elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  13. if(NOT GLM_QUIET)
  14. message("GLM: GCC - ${CMAKE_CXX_COMPILER_ID} compiler")
  15. endif()
  16. if(NOT GLM_DISABLE_AUTO_DETECTION)
  17. add_compile_options(-Werror)
  18. # add_compile_options(-Wpedantic)
  19. # add_compile_options(-Wall)
  20. # add_compile_options(-Wextra)
  21. endif()
  22. add_compile_options(-O2)
  23. #add_compile_options(-Wno-long-long)
  24. elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
  25. if(NOT GLM_QUIET)
  26. message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler")
  27. endif()
  28. elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  29. if(NOT GLM_QUIET)
  30. message("GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler")
  31. endif()
  32. if(NOT GLM_DISABLE_AUTO_DETECTION)
  33. add_compile_options(/Wall /WX)
  34. add_compile_options(/wd4464) # warning C4464: relative include path contains '..'
  35. add_compile_options(/wd4514) # warning C4514: unreferenced inline function has been removed
  36. add_compile_options(/wd4365) # warning C4365: signed/unsigned mismatch
  37. add_compile_options(/wd5045) # warning C5045: Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
  38. add_compile_options(/wd5029) # warning C5029: nonstandard extension used: alignment attributes in C++ apply to variables, data members and tag types only
  39. add_compile_options(/wd4820) # warning C4820: 'test_decl::S1': '3' bytes padding added after data member 'test_decl::S1::A'
  40. add_compile_options(/wd4710) # warning C4710: 'std::string glm::detail::format(const char *,...)': function not inlined
  41. add_compile_options(/wd4626) # warning C4626: 'glm::io::format_punct<CTy>': assignment operator was implicitly defined as deleted
  42. add_compile_options(/wd4711) # warning C4711: function 'int __cdecl test_vec1(void)' selected for automatic inline expansion
  43. add_compile_options(/wd4571) # warning C4571: Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
  44. add_compile_options(/wd4625) # warning C4625: 'std::codecvt_base': copy constructor was implicitly defined as deleted
  45. add_compile_options(/wd5026) # warning C5026: 'std::_Generic_error_category': move constructor was implicitly defined as deleted
  46. add_compile_options(/wd5027) # warning C5027: 'std::_Generic_error_category': move assignment operator was implicitly defined as deleted
  47. add_compile_options(/wd4774) # warning C4774: 'sprintf_s' : format string expected in argument 3 is not a string literal
  48. endif()
  49. # add_compile_options(/wd4309 /wd4324 /wd4389 /wd4127 /wd4267 /wd4146 /wd4201 /wd4464 /wd4514 /wd4701 /wd4820 /wd4365)
  50. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  51. endif()
  52. function(glmCreateTestGTC NAME)
  53. set(SAMPLE_NAME test-${NAME})
  54. add_executable(${SAMPLE_NAME} ${NAME}.cpp)
  55. add_test(
  56. NAME ${SAMPLE_NAME}
  57. COMMAND $<TARGET_FILE:${SAMPLE_NAME}> )
  58. target_link_libraries(${SAMPLE_NAME} PRIVATE glm::glm)
  59. endfunction()
  60. if(GLM_TEST_ENABLE)
  61. add_subdirectory(bug)
  62. add_subdirectory(core)
  63. add_subdirectory(ext)
  64. add_subdirectory(gtc)
  65. add_subdirectory(gtx)
  66. endif()
  67. if(GLM_PERF_TEST_ENABLE)
  68. add_subdirectory(perf)
  69. endif()