From a39a9b8eb9f56fb8c04112cf93df35ee1a61fd1e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 4 Jan 2017 22:31:25 +0100 Subject: [PATCH] Use new CMake approach to check Visual C++ --- CMakeLists.txt | 79 +++++++++++++++++--------------------------------- 1 file changed, 27 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b432363..f5c87550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,7 @@ elseif(GLM_TEST_ENABLE_SIMD_AVX2) add_definitions(-mavx2) elseif(GLM_USE_INTEL) add_definitions(/QxAVX2) - elseif(MSVC) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_definitions(/arch:AVX2) endif() message(STATUS "GLM: AVX2 instruction set") @@ -128,7 +128,7 @@ elseif(GLM_TEST_ENABLE_SIMD_AVX) add_definitions(-mavx) elseif(GLM_USE_INTEL) add_definitions(/QxAVX) - elseif(MSVC) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_definitions(/arch:AVX) endif() message(STATUS "GLM: AVX instruction set") @@ -137,7 +137,7 @@ elseif(GLM_TEST_ENABLE_SIMD_SSE3) add_definitions(-msse3) elseif(GLM_USE_INTEL) add_definitions(/QxSSE3) - elseif(MSVC AND NOT CMAKE_CL_64) + elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64) add_definitions(/arch:SSE2) # VC doesn't support /arch:SSE3 endif() message(STATUS "GLM: SSE3 instruction set") @@ -146,7 +146,7 @@ elseif(GLM_TEST_ENABLE_SIMD_SSE2) add_definitions(-msse2) elseif(GLM_USE_INTEL) add_definitions(/QxSSE2) - elseif(MSVC AND NOT CMAKE_CL_64) + elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64) add_definitions(/arch:SSE2) endif() message(STATUS "GLM: SSE2 instruction set") @@ -173,74 +173,49 @@ add_subdirectory(test) set(GLM_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/glm") if (GLM_INSTALL_ENABLE) - install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(DIRECTORY glm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" - VERSION ${GLM_VERSION} - COMPATIBILITY AnyNewerVersion -) +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 -) +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 -) + 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} - ) + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${GLM_INSTALL_CONFIGDIR}/glmConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/glmConfigVersion.cmake" + DESTINATION ${GLM_INSTALL_CONFIGDIR}) endif() if (NOT CMAKE_VERSION VERSION_LESS "3.0") - add_library(glm INTERFACE) - target_include_directories(glm INTERFACE - $ - $ - ) - install(TARGETS glm EXPORT glmTargets) + add_library(glm INTERFACE) + target_include_directories(glm INTERFACE + $ + $) + install(TARGETS glm EXPORT glmTargets) - export( - EXPORT glmTargets - FILE "${CMAKE_CURRENT_BINARY_DIR}/glmTargets.cmake" - ) + 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() + if (GLM_INSTALL_ENABLE) + install(EXPORT glmTargets FILE glmTargets.cmake DESTINATION ${GLM_INSTALL_CONFIGDIR}) + endif() endif() # build pkg-config file -configure_file( - "./cmake/glm.pc.in" - "glm.pc" - @ONLY -) +configure_file("./cmake/glm.pc.in" "glm.pc" @ONLY) # install pkg-config file if (GLM_INSTALL_ENABLE) - install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" - ) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/glm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() export(PACKAGE glm)