glm/CMakeLists.txt

294 lines
9.5 KiB
CMake
Raw Permalink Normal View History

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_policy(VERSION 3.2)
2010-04-29 10:56:52 +00:00
2016-07-16 21:18:23 +00:00
set(GLM_VERSION "0.9.9")
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2010-04-29 10:56:52 +00:00
2014-04-15 09:26:28 +00:00
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
enable_testing()
2014-04-15 09:26:28 +00:00
2018-08-19 15:42:30 +00:00
option(GLM_QUIET "No CMake Message" OFF)
option(BUILD_SHARED_LIBS "Build shared library" ON)
option(BUILD_STATIC_LIBS "Build static library" ON)
option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)
option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF)
option(GLM_TEST_ENABLE_CXX_14 "Enable C++ 14" OFF)
option(GLM_TEST_ENABLE_CXX_17 "Enable C++ 17" OFF)
option(GLM_TEST_ENABLE_CXX_20 "Enable C++ 20" OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2012-04-14 17:19:28 +00:00
if(GLM_TEST_ENABLE_CXX_20)
set(CMAKE_CXX_STANDARD 20)
2018-08-18 10:46:27 +00:00
add_definitions(-DGLM_FORCE_CXX2A)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with C++20 features")
endif()
elseif(GLM_TEST_ENABLE_CXX_17)
set(CMAKE_CXX_STANDARD 17)
2018-08-18 10:46:27 +00:00
add_definitions(-DGLM_FORCE_CXX17)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with C++17 features")
endif()
elseif(GLM_TEST_ENABLE_CXX_14)
set(CMAKE_CXX_STANDARD 14)
2018-08-18 10:46:27 +00:00
add_definitions(-DGLM_FORCE_CXX14)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with C++14 features")
endif()
elseif(GLM_TEST_ENABLE_CXX_11)
set(CMAKE_CXX_STANDARD 11)
2018-08-18 10:46:27 +00:00
add_definitions(-DGLM_FORCE_CXX11)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with C++11 features")
endif()
elseif(GLM_TEST_ENABLE_CXX_98)
set(CMAKE_CXX_STANDARD 98)
2018-08-18 10:46:27 +00:00
add_definitions(-DGLM_FORCE_CXX98)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with C++98 features")
endif()
endif()
option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
2012-04-14 17:19:28 +00:00
2018-08-22 19:43:32 +00:00
option(GLM_DISABLE_AUTO_DETECTION "Enable language extensions" OFF)
if(GLM_DISABLE_AUTO_DETECTION)
add_definitions(-DGLM_FORCE_PLATFORM_UNKNOWN -DGLM_FORCE_COMPILER_UNKNOWN -DGLM_FORCE_ARCH_UNKNOWN -DGLM_FORCE_CXX_UNKNOWN)
endif()
if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS ON)
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
add_compile_options(-fms-extensions)
2018-07-11 22:36:59 +00:00
endif()
message(STATUS "GLM: Build with C++ language extensions")
else()
set(CMAKE_CXX_EXTENSIONS OFF)
2018-07-14 14:22:17 +00:00
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/Za)
2018-07-19 22:40:49 +00:00
if(MSVC15)
add_compile_options(/permissive-)
endif()
2018-07-14 14:22:17 +00:00
endif()
2012-04-14 17:19:28 +00:00
endif()
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
if(GLM_TEST_ENABLE_FAST_MATH)
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message(STATUS "GLM: Build with fast math optimizations")
endif()
2017-08-17 09:38:45 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
add_compile_options(-ffast-math)
2017-08-17 09:38:45 +00:00
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/fp:fast)
endif()
else()
2017-08-17 09:38:45 +00:00
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/fp:precise)
endif()
2016-05-09 08:36:22 +00:00
endif()
option(GLM_TEST_ENABLE "Build unit tests" ON)
2013-10-19 10:13:38 +00:00
option(GLM_TEST_ENABLE_SIMD_SSE2 "Enable SSE2 optimizations" OFF)
option(GLM_TEST_ENABLE_SIMD_SSE3 "Enable SSE3 optimizations" OFF)
2018-08-19 01:19:07 +00:00
option(GLM_TEST_ENABLE_SIMD_SSSE3 "Enable SSSE3 optimizations" OFF)
option(GLM_TEST_ENABLE_SIMD_SSE4_1 "Enable SSE 4.1 optimizations" OFF)
option(GLM_TEST_ENABLE_SIMD_SSE4_2 "Enable SSE 4.2 optimizations" OFF)
2013-10-19 10:13:38 +00:00
option(GLM_TEST_ENABLE_SIMD_AVX "Enable AVX optimizations" OFF)
option(GLM_TEST_ENABLE_SIMD_AVX2 "Enable AVX2 optimizations" OFF)
option(GLM_TEST_FORCE_PURE "Force 'pure' instructions" OFF)
if(GLM_TEST_FORCE_PURE)
2018-10-01 09:23:26 +00:00
add_definitions(-DGLM_FORCE_PURE)
2012-09-20 08:17:03 +00:00
2017-08-17 09:38:45 +00:00
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-mfpmath=387)
endif()
message(STATUS "GLM: No SIMD instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_AVX2)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_PURE)
2017-08-17 09:38:45 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-mavx2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxAVX2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/arch:AVX2)
endif()
message(STATUS "GLM: AVX2 instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_AVX)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2017-08-17 09:38:45 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-mavx)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxAVX)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compile_options(/arch:AVX)
endif()
message(STATUS "GLM: AVX instruction set")
2018-08-19 01:19:07 +00:00
elseif(GLM_TEST_ENABLE_SIMD_SSE4_2)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2018-08-19 01:19:07 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-msse4.2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxSSE4.2)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compile_options(/arch:SSE2) # VC doesn't support SSE4.2
endif()
message(STATUS "GLM: SSE4.2 instruction set")
elseif(GLM_TEST_ENABLE_SIMD_SSE4_1)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2018-08-19 01:19:07 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-msse4.1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxSSE4.1)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compile_options(/arch:SSE2) # VC doesn't support SSE4.1
endif()
message(STATUS "GLM: SSE4.1 instruction set")
elseif(GLM_TEST_ENABLE_SIMD_SSSE3)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2018-08-19 01:19:07 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-mssse3)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxSSSE3)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compile_options(/arch:SSE2) # VC doesn't support SSSE3
endif()
message(STATUS "GLM: SSSE3 instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_SSE3)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2017-08-17 09:38:45 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-msse3)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxSSE3)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
2018-08-19 01:19:07 +00:00
add_compile_options(/arch:SSE2) # VC doesn't support SSE3
2012-04-14 17:19:28 +00:00
endif()
message(STATUS "GLM: SSE3 instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_SSE2)
2019-01-11 11:58:31 +00:00
add_definitions(-DGLM_FORCE_INTRINSICS)
2017-08-17 09:38:45 +00:00
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compile_options(-msse2)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(/QxSSE2)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compile_options(/arch:SSE2)
2012-04-14 17:19:28 +00:00
endif()
message(STATUS "GLM: SSE2 instruction set")
2012-04-14 17:19:28 +00:00
endif()
2017-08-17 09:38:45 +00:00
# Compiler and default options
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message("GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler")
endif()
2017-08-17 09:38:45 +00:00
add_compile_options(-Werror -Weverything)
add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-gnu-anonymous-struct -Wno-nested-anon-types)
add_compile_options(-Wno-undefined-reinterpret-cast -Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare -Wno-global-constructors -Wno-unused-macros -Wno-format-nonliteral)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message("GLM: GCC - ${CMAKE_CXX_COMPILER_ID} compiler")
endif()
2012-10-09 18:36:02 +00:00
2017-08-17 09:38:45 +00:00
add_compile_options(-O2)
add_compile_options(-Wno-long-long)
2017-08-17 09:38:45 +00:00
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler")
endif()
2017-08-17 09:38:45 +00:00
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
2018-08-19 15:42:30 +00:00
if(NOT GLM_QUIET)
message("GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler")
endif()
2010-04-29 10:56:52 +00:00
2018-07-23 18:05:12 +00:00
add_compile_options(/W4 /WX)
2017-09-23 21:06:27 +00:00
add_compile_options(/wd4309 /wd4324 /wd4389 /wd4127 /wd4267 /wd4146 /wd4201 /wd4464 /wd4514 /wd4701 /wd4820 /wd4365)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include_directories("${PROJECT_SOURCE_DIR}")
2010-12-17 01:33:17 +00:00
2019-03-13 08:44:10 +00:00
add_subdirectory(glm)
2010-12-17 01:33:17 +00:00
add_subdirectory(test)
2010-04-29 14:45:55 +00:00
2015-04-09 03:20:58 +00:00
set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm")
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
2015-03-29 17:21:56 +00:00
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" VERSION ${GLM_VERSION} COMPATIBILITY AnyNewerVersion)
# build tree package config
configure_file(cmake/glmBuildConfig.cmake.in glmConfig.cmake @ONLY)
# install tree package config
configure_package_config_file(
cmake/glmConfig.cmake.in
${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake
INSTALL_DESTINATION ${GLM_INSTALL_CONFIGDIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR})
2015-05-01 18:40:45 +00:00
add_library(glm INTERFACE)
target_include_directories(glm INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
install(TARGETS glm EXPORT glmTargets)
export(EXPORT glmTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake")
install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR})
2015-04-09 03:20:58 +00:00
2016-05-30 10:50:00 +00:00
# build pkg-config file
configure_file("./cmake/glm.pc.in" "glm.pc" @ONLY)
2016-05-30 10:50:00 +00:00
# install pkg-config file
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
2016-05-30 10:50:00 +00:00
2015-04-09 03:20:58 +00:00
export(PACKAGE glm)
2017-08-03 05:09:42 +00:00
if(NOT TARGET uninstall)
2017-08-17 13:21:13 +00:00
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
2017-08-03 05:09:42 +00:00
endif()