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-01-03 17:01:56 +00:00
set ( GLM_VERSION "0.9.8" )
2015-03-29 02:41:09 +00:00
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
2010-04-29 10:56:52 +00:00
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
2011-05-31 16:41:21 +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 ( )
option ( GLM_DYNAMIC_LIBRARY_ENABLE "GLM static 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 ( )
2016-07-16 21:54:11 +00:00
option ( GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF )
2013-08-20 21:07:04 +00:00
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 )
2014-12-10 00:55:26 +00:00
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
2014-12-10 00:55:26 +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" )
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" )
elseif ( GLM_TEST_ENABLE_CXX_1Y )
2013-09-10 17:58:02 +00:00
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" )
2013-08-20 21:07:04 +00:00
elseif ( GLM_TEST_ENABLE_CXX_11 )
2013-09-10 17:58:02 +00:00
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" )
2013-08-20 21:07:04 +00:00
elseif ( GLM_TEST_ENABLE_CXX_0X )
2013-09-10 17:58:02 +00:00
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" )
2013-08-20 21:07:04 +00:00
elseif ( GLM_TEST_ENABLE_CXX_98 )
2013-09-10 17:58:02 +00:00
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" )
2016-07-17 09:53:47 +00:00
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
add_definitions ( -Wno-long-long )
endif ( )
2012-04-14 17:19:28 +00:00
endif ( )
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 )
if ( GLM_TEST_ENABLE_FAST_MATH )
if ( CMAKE_COMPILER_IS_GNUCXX )
add_definitions ( -ffast-math )
endif ( )
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 ) )
2013-08-20 21:07:04 +00:00
add_definitions ( /Za )
2016-07-16 16:36:56 +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 ( )
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
2012-04-14 17:19:28 +00:00
if ( CMAKE_COMPILER_IS_GNUCXX )
2013-09-15 01:09:10 +00:00
add_definitions ( -mfpmath=387 )
endif ( )
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_AVX2 )
2013-09-15 01:09:10 +00:00
if ( CMAKE_COMPILER_IS_GNUCXX )
add_definitions ( -mavx2 )
elseif ( GLM_USE_INTEL )
add_definitions ( /QxAVX2 )
elseif ( MSVC )
2014-11-22 20:26:22 +00:00
add_definitions ( /arch:AVX2 )
2013-09-15 01:09:10 +00:00
endif ( )
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_AVX )
2013-09-15 01:09:10 +00:00
if ( CMAKE_COMPILER_IS_GNUCXX )
add_definitions ( -mavx )
2013-01-31 23:45:24 +00:00
elseif ( GLM_USE_INTEL )
add_definitions ( /QxAVX )
2013-09-15 01:09:10 +00:00
elseif ( MSVC )
2014-11-22 20:26:22 +00:00
add_definitions ( /arch:AVX )
2013-09-15 01:09:10 +00:00
endif ( )
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_SSE3 )
2013-09-15 01:09:10 +00:00
if ( CMAKE_COMPILER_IS_GNUCXX )
add_definitions ( -msse3 )
elseif ( GLM_USE_INTEL )
add_definitions ( /QxSSE3 )
2016-05-02 21:32:19 +00:00
elseif ( MSVC AND NOT CMAKE_CL_64 )
2013-12-18 17:45:02 +00:00
add_definitions ( /arch:SSE2 ) # VC doesn't support /arch:SSE3
2012-04-14 17:19:28 +00:00
endif ( )
2014-11-22 20:26:22 +00:00
elseif ( GLM_TEST_ENABLE_SIMD_SSE2 )
2012-04-14 17:19:28 +00:00
if ( CMAKE_COMPILER_IS_GNUCXX )
2013-09-15 01:09:10 +00:00
add_definitions ( -msse2 )
elseif ( GLM_USE_INTEL )
add_definitions ( /QxSSE2 )
2016-05-02 21:32:19 +00:00
elseif ( MSVC AND NOT CMAKE_CL_64 )
add_definitions ( /arch:SSE2 )
2012-04-14 17:19:28 +00:00
endif ( )
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
2016-05-22 11:16:55 +00:00
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" )
add_definitions ( /FAs )
endif ( )
2014-04-15 09:54:03 +00:00
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" )
install ( DIRECTORY glm DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } )
2015-03-29 17:21:56 +00:00
2015-05-02 08:03:24 +00:00
write_basic_package_version_file (
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g l m V e r s i o n . c m a k e "
V E R S I O N $ { G L M _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
# build tree package config
configure_file (
c m a k e / g l m B u i l d C o n f i g . c m a k e . i n
g l m C o n f i g . c m a k e
@ O N L Y
)
# install tree package config
configure_package_config_file (
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
)
install (
F I L E S
" $ { 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 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 }
)
2015-05-01 18:40:45 +00:00
2015-07-06 11:37:08 +00:00
if ( NOT CMAKE_VERSION VERSION_LESS "3.0" )
2015-03-29 02:41:09 +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 } >
2015-04-09 03:20:58 +00:00
$ < 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 } >
2015-03-29 02:41:09 +00:00
)
install ( TARGETS glm EXPORT glmTargets )
export (
E X P O R T g l m T a r g e t s
F I L 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 T a r g e t s . c m a k e "
)
2015-04-09 03:20:58 +00:00
2015-03-29 02:41:09 +00:00
install (
E X P O R T g l m T a r g e t s F I L E g l m T a r g e t s . c m a k e
2015-04-09 03:20:58 +00:00
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 }
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
configure_file (
2016-05-30 22:36:21 +00:00
" . / c m a k e / g l m . p c . i n "
2016-05-30 10:50:00 +00:00
" g l m . p c "
@ O N L Y
)
# install pkg-config file
install (
F I L E S " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / g l m . p c "
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ L I B D I R } / p k g c o n f i g "
)
2015-04-09 03:20:58 +00:00
export ( PACKAGE glm )