glm/CMakeLists.txt

236 lines
8.2 KiB
CMake
Raw Normal View History

2010-04-29 10:56:52 +00:00
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
2016-02-09 00:18:24 +00:00
cmake_policy(VERSION 2.6)
if (NOT CMAKE_VERSION VERSION_LESS "3.1")
cmake_policy(SET CMP0054 NEW)
endif()
2010-04-29 10:56:52 +00:00
project(glm)
2016-07-16 21:18:23 +00:00
set(GLM_VERSION "0.9.9")
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
2017-07-24 09:10:20 +00:00
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
2011-05-31 16:41:21 +00:00
option(GLM_STATIC_LIBRARY_ENABLE "GLM static library" OFF)
if(GLM_STATIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_STATIC_LIBRARY_ENABLE with ON to build an optional static library")
endif()
option(GLM_DYNAMIC_LIBRARY_ENABLE "GLM dynamic library" OFF)
if(GLM_DYNAMIC_LIBRARY_ENABLE)
message(STATUS "GLM is a header only library, no need to build it. Set the option GLM_DYNAMIC_LIBRARY_ENABLE with ON to build an optional dynamic library")
endif()
option(GLM_INSTALL_ENABLE "GLM install" ON)
2012-04-14 17:19:28 +00:00
option(GLM_TEST_ENABLE "GLM test" OFF)
if(NOT GLM_TEST_ENABLE)
message(STATUS "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")
2012-04-14 17:19:28 +00:00
endif()
option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND UNIX))
option(GLM_TEST_ENABLE_CXX_98 "Enable C++ 98" OFF)
option(GLM_TEST_ENABLE_CXX_0X "Enable C++ 0x" OFF)
option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF)
option(GLM_TEST_ENABLE_CXX_1Y "Enable C++ 1y" OFF)
option(GLM_TEST_ENABLE_CXX_14 "Enable C++ 14" OFF)
option(GLM_TEST_ENABLE_CXX_1Z "Enable C++ 1z" OFF)
2013-01-31 23:45:24 +00:00
if(GLM_TEST_ENABLE_CXX_1Z)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1z")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++1z")
message(STATUS "Build with C++1z features")
elseif(GLM_TEST_ENABLE_CXX_14)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++14")
message(STATUS "Build with C++14 features")
elseif(GLM_TEST_ENABLE_CXX_1Y)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1y")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++1y")
message(STATUS "Build with C++1y features")
elseif(GLM_TEST_ENABLE_CXX_11)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++11")
message(STATUS "Build with C++11 features")
elseif(GLM_TEST_ENABLE_CXX_0X)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++0x")
message(STATUS "Build with C++0x features")
elseif(GLM_TEST_ENABLE_CXX_98)
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "-std=c++98")
message(STATUS "Build with C++98 features")
2016-03-05 21:29:52 +00:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions(-Wno-long-long)
endif()
2017-08-06 14:30:41 +00:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-Wno-c++11-long-long)
endif()
2012-04-14 17:19:28 +00:00
endif()
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2017-08-08 21:19:16 +00:00
add_definitions(-Weverything -Wpedantic -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-documentation -Wno-gnu-anonymous-struct -Wno-nested-anon-types)
2017-08-08 21:35:46 +00:00
add_definitions(-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)
endif()
option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF)
2012-04-14 17:19:28 +00:00
if(GLM_TEST_ENABLE_LANG_EXTENSIONS)
if(GLM_TEST_ENABLE_FAST_MATH)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-ffast-math)
endif()
2012-04-14 17:19:28 +00:00
if(MSVC)
add_definitions(/fp:fast)
endif()
elseif(NOT GLM_TEST_ENABLE_FAST_MATH)
if(MSVC)
add_definitions(/fp:precise)
endif()
endif()
else()
2014-10-29 09:28:25 +00:00
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32))
add_definitions(/Za)
2014-10-29 09:28:25 +00:00
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
add_definitions(-pedantic)
2012-04-14 17:19:28 +00:00
endif()
endif()
2016-05-09 08:36:22 +00:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_definitions(/FAs)
endif()
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)
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)
add_definitions(-DGLM_FORCE_PURE)
2012-09-20 08:17:03 +00:00
2012-04-14 17:19:28 +00:00
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-mfpmath=387)
endif()
message(STATUS "GLM: No SIMD instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_AVX2)
if(CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions(-mavx2)
elseif(GLM_USE_INTEL)
add_definitions(/QxAVX2)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
2014-11-22 20:26:22 +00:00
add_definitions(/arch:AVX2)
endif()
message(STATUS "GLM: AVX2 instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_AVX)
if(CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions(-mavx)
2013-01-31 23:45:24 +00:00
elseif(GLM_USE_INTEL)
add_definitions(/QxAVX)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
2014-11-22 20:26:22 +00:00
add_definitions(/arch:AVX)
endif()
message(STATUS "GLM: AVX instruction set")
2014-11-22 20:26:22 +00:00
elseif(GLM_TEST_ENABLE_SIMD_SSE3)
if(CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions(-msse3)
elseif(GLM_USE_INTEL)
add_definitions(/QxSSE3)
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64)
add_definitions(/arch:SSE2) # VC doesn't support /arch: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)
if(CMAKE_COMPILER_IS_GNUCXX OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
add_definitions(-msse2)
elseif(GLM_USE_INTEL)
add_definitions(/QxSSE2)
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64)
add_definitions(/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()
2011-05-31 16:41:21 +00:00
if(CMAKE_COMPILER_IS_GNUCXX)
#add_definitions(-S)
#add_definitions(-s)
2015-02-13 23:19:47 +00:00
add_definitions(-O2)
2012-10-09 18:36:02 +00:00
#add_definitions(-fprofile-arcs -ftest-coverage) gcov
#ctest_enable_coverage()
2011-05-31 16:41:21 +00:00
endif()
2010-04-29 10:56:52 +00:00
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_definitions(/FAs)
endif()
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/test/external")
2010-12-17 01:33:17 +00:00
2010-04-29 10:56:52 +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")
if (GLM_INSTALL_ENABLE)
install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
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)
if (GLM_INSTALL_ENABLE)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake"
DESTINATION ${GLM_INSTALL_CONFIGDIR})
endif()
2015-05-01 18:40:45 +00:00
if (NOT CMAKE_VERSION VERSION_LESS "3.0")
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")
if (GLM_INSTALL_ENABLE)
install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR})
endif()
endif()
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
if (GLM_INSTALL_ENABLE)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
2016-05-30 10:50:00 +00:00
2015-04-09 03:20:58 +00:00
export(PACKAGE glm)