2017-08-17 08:54:16 +00:00
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" )
2017-08-17 08:54:16 +00:00
project ( glm VERSION ${ GLM_VERSION } LANGUAGES CXX )
2015-05-02 08:03:24 +00:00
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 )
2015-05-02 08:03:24 +00:00
include ( CMakePackageConfigHelpers )
enable_testing ( )
2014-04-15 09:26:28 +00:00
2016-03-12 00:32:40 +00:00
option ( GLM_STATIC_LIBRARY_ENABLE "GLM static library" OFF )
2016-03-14 21:29:55 +00:00
if ( GLM_STATIC_LIBRARY_ENABLE )
2016-03-12 00:32:40 +00:00
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 ( )
2016-12-07 15:22:44 +00:00
option ( GLM_DYNAMIC_LIBRARY_ENABLE "GLM dynamic library" OFF )
2016-03-14 21:29:55 +00:00
if ( GLM_DYNAMIC_LIBRARY_ENABLE )
2016-03-12 00:32:40 +00:00
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 ( )
2012-04-14 17:19:28 +00:00
option ( GLM_TEST_ENABLE "GLM test" OFF )
if ( NOT GLM_TEST_ENABLE )
2014-04-15 09:30:58 +00:00
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 ( )
2017-08-17 08:54:16 +00:00
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 )
2016-07-16 21:54:11 +00:00
2017-08-17 08:54:16 +00:00
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
2012-04-14 17:19:28 +00:00
2017-08-17 08:54:16 +00:00
if ( GLM_TEST_ENABLE_CXX_17 )
set ( CMAKE_CXX_STANDARD 17 )
message ( STATUS "GLM: Build with C++17 features" )
elseif ( GLM_TEST_ENABLE_CXX_14 )
set ( CMAKE_CXX_STANDARD 14 )
message ( STATUS "GLM: Build with C++14 features" )
elseif ( GLM_TEST_ENABLE_CXX_11 )
set ( CMAKE_CXX_STANDARD 11 )
message ( STATUS "GLM: Build with C++11 features" )
elseif ( GLM_TEST_ENABLE_CXX_98 )
set ( CMAKE_CXX_STANDARD 98 )
message ( STATUS "GLM: Build with C++98 features" )
2017-08-06 21:00:05 +00:00
endif ( )
2016-07-16 16:36:56 +00:00
option ( GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF )
2012-04-14 17:19:28 +00:00
2016-07-16 21:54:11 +00:00
if ( GLM_TEST_ENABLE_LANG_EXTENSIONS )
2017-08-17 08:54:16 +00:00
set ( CMAKE_CXX_EXTENSIONS ON )
message ( STATUS "GLM: Build with C++ language extensions" )
2014-11-16 17:18:11 +00:00
else ( )
2017-08-17 08:54:16 +00:00
set ( CMAKE_CXX_EXTENSIONS OFF )
2012-04-14 17:19:28 +00:00
endif ( )
2017-08-17 08:54:16 +00:00
option ( GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF )
if ( GLM_TEST_ENABLE_FAST_MATH )
message ( STATUS "GLM: Build with fast math optimizations" )
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 08:54:16 +00:00
2017-08-17 09:38:45 +00:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
add_compile_options ( /fp:fast )
2017-08-17 08:54:16 +00:00
endif ( )
else ( )
2017-08-17 09:38:45 +00:00
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
add_compile_options ( /fp:precise )
2017-08-17 08:54:16 +00:00
endif ( )
2016-05-09 08:36:22 +00:00
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 )
2013-09-15 01:09:10 +00:00
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
2017-08-17 09:38:45 +00:00
if ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
add_compile_options ( -mfpmath=387 )
2013-09-15 01:09:10 +00:00
endif ( )
2016-11-23 22:34:39 +00:00
message ( STATUS "GLM: No SIMD instruction set" )
2017-08-17 08:54:16 +00:00
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_AVX2 )
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 )
2013-09-15 01:09:10 +00:00
endif ( )
2016-11-23 22:34:39 +00:00
message ( STATUS "GLM: AVX2 instruction set" )
2017-08-17 08:54:16 +00:00
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_AVX )
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 )
2013-09-15 01:09:10 +00:00
endif ( )
2016-11-23 22:34:39 +00:00
message ( STATUS "GLM: AVX instruction set" )
2017-08-17 08:54:16 +00:00
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_SSE3 )
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 )
add_compile_options ( /arch:SSE2 ) # VC doesn't support /arch:SSE3
2012-04-14 17:19:28 +00:00
endif ( )
2016-11-23 22:34:39 +00:00
message ( STATUS "GLM: SSE3 instruction set" )
2017-08-17 08:54:16 +00:00
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_SSE2 )
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 ( )
2016-11-23 22:34:39 +00:00
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" ) )
message ( "GLM: Clang - ${CMAKE_CXX_COMPILER_ID} compiler" )
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" )
message ( "GLM: GCC - ${CMAKE_CXX_COMPILER_ID} compiler" )
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 08:54:16 +00:00
2017-08-17 09:38:45 +00:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
message ( "GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler" )
2017-08-17 08:54:16 +00:00
2017-08-17 09:38:45 +00:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
message ( "GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler" )
2010-04-29 10:56:52 +00:00
2017-08-17 09:38:45 +00:00
add_compile_options ( /FAs )
2017-08-17 08:54:16 +00:00
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
2016-05-22 11:16:55 +00:00
endif ( )
2014-04-15 09:54:03 +00:00
include_directories ( "${PROJECT_SOURCE_DIR}" )
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
2017-08-17 08:54:16 +00:00
option ( GLM_INSTALL_ENABLE "GLM install" ON )
2015-04-09 03:20:58 +00:00
set ( GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm" )
2016-12-07 15:22:44 +00:00
if ( GLM_INSTALL_ENABLE )
2017-01-04 21:31:25 +00:00
install ( DIRECTORY glm DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } )
2016-12-07 15:22:44 +00:00
endif ( )
2015-03-29 17:21:56 +00:00
2017-01-04 21:31:25 +00:00
write_basic_package_version_file ( "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" VERSION ${ GLM_VERSION } COMPATIBILITY AnyNewerVersion )
2015-05-02 08:03:24 +00:00
# build tree package config
2017-01-04 21:31:25 +00:00
configure_file ( cmake/glmBuildConfig.cmake.in glmConfig.cmake @ONLY )
2015-05-02 08:03:24 +00:00
# install tree package config
configure_package_config_file (
2017-01-04 21:31:25 +00:00
c m a k e / g l m C o n f i g . c m a k e . i n
$ { G L M _ I N S T A L L _ C O N F I G D I R } / g l m C o n f i g . c m a k e
I N S T A L L _ D E S T I N A T I O N $ { G L M _ I N S T A L L _ C O N F I G D I R }
P A T H _ V A R S C M A K E _ I N S T A L L _ I N C L U D E D I R
N O _ C H E C K _ R E Q U I R E D _ C O M P O N E N T S _ M A C R O )
2015-05-02 08:03:24 +00:00
2017-08-17 08:54:16 +00:00
if ( GLM_INSTALL_ENABLE )
2017-01-04 21:31:25 +00:00
install ( FILES
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { G L M _ I N S T A L L _ C O N F I G D I R } / g l m C o n f i g . c m a k e "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g l m C o n f i g V e r s i o n . c m a k e "
D E S T I N A T I O N $ { G L M _ I N S T A L L _ C O N F I G D I R } )
2016-12-07 15:22:44 +00:00
endif ( )
2015-05-01 18:40:45 +00:00
2017-08-17 08:54:16 +00:00
add_library ( glm INTERFACE )
target_include_directories ( glm INTERFACE
$ < I N S T A L L _ I N T E R F A C E : $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } >
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } > )
install ( TARGETS glm EXPORT glmTargets )
2017-01-04 21:31:25 +00:00
2017-08-17 08:54:16 +00:00
export ( EXPORT glmTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake" )
2017-01-04 21:31:25 +00:00
2017-08-17 08:54:16 +00:00
if ( GLM_INSTALL_ENABLE )
install ( EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${ GLM_INSTALL_CONFIGDIR } )
2015-03-29 02:41:09 +00:00
endif ( )
2015-04-09 03:20:58 +00:00
2016-05-30 10:50:00 +00:00
# build pkg-config file
2017-01-04 21:31:25 +00:00
configure_file ( "./cmake/glm.pc.in" "glm.pc" @ONLY )
2016-05-30 10:50:00 +00:00
# install pkg-config file
2016-12-07 15:22:44 +00:00
if ( GLM_INSTALL_ENABLE )
2017-01-04 21:31:25 +00:00
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" )
2016-12-07 15:22:44 +00:00
endif ( )
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 (
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e _ u n i n s t a l l . c m a k e . i n
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e
I M M E D I A T E @ O N L Y )
add_custom_target ( uninstall
C O M M A N D $ { C M A K E _ C O M M A N D } - P
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e )
2017-08-03 05:09:42 +00:00
endif ( )