CMakeLists.txt 3.7 KB

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