CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
  2. cmake_policy(VERSION 2.6)
  3. project(glm)
  4. enable_testing()
  5. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  6. option(GLM_TEST_ENABLE "GLM test" OFF)
  7. if(NOT GLM_TEST_ENABLE)
  8. message(FATAL_ERROR "GLM is a header only library, no need to build it. Set the option GLM_TEST_ENABLE with ON to build and run the test bench")
  9. endif()
  10. if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX))
  11. option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)
  12. option(GLM_TEST_ENABLE_CXX_0X "Enable C++ 0x" OFF)
  13. option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF)
  14. option(GLM_TEST_ENABLE_CXX_1Y "Enable C++ 1y" OFF)
  15. option(GLM_TEST_ENABLE_CXX_PEDANTIC "Pedantic" ON)
  16. if(GLM_TEST_ENABLE_CXX_PEDANTIC)
  17. add_definitions(-pedantic)
  18. endif()
  19. if(GLM_TEST_ENABLE_CXX_1Y)
  20. add_definitions(-std=c++1y)
  21. elseif(GLM_TEST_ENABLE_CXX_11)
  22. add_definitions(-std=c++11)
  23. elseif(GLM_TEST_ENABLE_CXX_0X)
  24. add_definitions(-std=c++0x)
  25. elseif(GLM_TEST_ENABLE_CXX_98)
  26. add_definitions(-std=c++98)
  27. endif()
  28. endif()
  29. if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32))
  30. option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF)
  31. if(NOT GLM_TEST_ENABLE_MS_EXTENSIONS)
  32. add_definitions(/Za)
  33. endif()
  34. endif()
  35. #set(GLM_SIMD_INSTRUCTION_SET "" CACHE STRING "Instruction set. Possible values are SSE1, SSE2")
  36. option(GLM_TEST_ENABLE_SIMD "Enable SIMD optimizations" OFF)
  37. if(GLM_TEST_ENABLE_SIMD)
  38. if(CMAKE_COMPILER_IS_GNUCXX)
  39. add_definitions(-msse2)
  40. elseif(MSVC10)
  41. add_definitions(/arch:AVX)
  42. elseif(MSVC)
  43. add_definitions(/arch:SSE2)
  44. endif()
  45. elseif(NOT GLM_TEST_ENABLE_SIMD)
  46. add_definitions(-DGLM_FORCE_PURE)
  47. if(CMAKE_COMPILER_IS_GNUCXX)
  48. add_definitions(-mfpmath=387)
  49. endif()
  50. endif()
  51. option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
  52. if(GLM_TEST_ENABLE_FAST_MATH)
  53. if(CMAKE_COMPILER_IS_GNUCXX)
  54. add_definitions(-ffast-math)
  55. endif()
  56. if(MSVC)
  57. add_definitions(/fp:fast)
  58. endif()
  59. elseif(NOT GLM_TEST_ENABLE_FAST_MATH)
  60. if(MSVC)
  61. add_definitions(/fp:precise)
  62. endif()
  63. endif()
  64. if(CMAKE_COMPILER_IS_GNUCXX)
  65. #add_definitions(-S)
  66. #add_definitions(-s)
  67. #add_definitions(-m32)
  68. #add_definitions(-O3)
  69. #add_definitions(-fprofile-arcs -ftest-coverage) gcov
  70. #ctest_enable_coverage()
  71. endif()
  72. include_directories(".")
  73. include_directories("./test/external")
  74. add_subdirectory(glm)
  75. add_subdirectory(test)
  76. install(DIRECTORY glm DESTINATION include)