Fixed Apple Clang detection

master
Christophe Riccio ago%!(EXTRA string=8 years)
parent eb8689b8b5
commit 1a973285f7
  1. 94
      CMakeLists.txt

@ -4,8 +4,6 @@ cmake_policy(VERSION 3.2)
set(GLM_VERSION "0.9.9") set(GLM_VERSION "0.9.9")
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX) project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
message("Compiler: ${CMAKE_CXX_COMPILER_ID}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs) include(GNUInstallDirs)
@ -66,15 +64,15 @@ option(GLM_TEST_ENABLE_FAST_MATH "Enable fast math optimizations" OFF)
if(GLM_TEST_ENABLE_FAST_MATH) if(GLM_TEST_ENABLE_FAST_MATH)
message(STATUS "GLM: Build with fast math optimizations") message(STATUS "GLM: Build with fast math optimizations")
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")) if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
add_compiler_options(-ffast-math) add_compile_options(-ffast-math)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compiler_options(/fp:fast) add_compile_options(/fp:fast)
endif() endif()
else() else()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compiler_options(/fp:precise) add_compile_options(/fp:precise)
endif() endif()
endif() endif()
@ -87,66 +85,74 @@ option(GLM_TEST_FORCE_PURE "Force 'pure' instructions" OFF)
if(GLM_TEST_FORCE_PURE) if(GLM_TEST_FORCE_PURE)
add_definitions(-DGLM_FORCE_PURE) add_definitions(-DGLM_FORCE_PURE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compiler_options(-mfpmath=387) add_compile_options(-mfpmath=387)
endif() endif()
message(STATUS "GLM: No SIMD instruction set") message(STATUS "GLM: No SIMD instruction set")
elseif(GLM_TEST_ENABLE_SIMD_AVX2) elseif(GLM_TEST_ENABLE_SIMD_AVX2)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compiler_options(-mavx2) add_compile_options(-mavx2)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compiler_options(/QxAVX2) add_compile_options(/QxAVX2)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compiler_options(/arch:AVX2) add_compile_options(/arch:AVX2)
endif() endif()
message(STATUS "GLM: AVX2 instruction set") message(STATUS "GLM: AVX2 instruction set")
elseif(GLM_TEST_ENABLE_SIMD_AVX) elseif(GLM_TEST_ENABLE_SIMD_AVX)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compiler_options(-mavx) add_compile_options(-mavx)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compiler_options(/QxAVX) add_compile_options(/QxAVX)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compiler_options(/arch:AVX) add_compile_options(/arch:AVX)
endif() endif()
message(STATUS "GLM: AVX instruction set") message(STATUS "GLM: AVX instruction set")
elseif(GLM_TEST_ENABLE_SIMD_SSE3) elseif(GLM_TEST_ENABLE_SIMD_SSE3)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compiler_options(-msse3) add_compile_options(-msse3)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compiler_options(/QxSSE3) add_compile_options(/QxSSE3)
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64) elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compiler_options(/arch:SSE2) # VC doesn't support /arch:SSE3 add_compile_options(/arch:SSE2) # VC doesn't support /arch:SSE3
endif() endif()
message(STATUS "GLM: SSE3 instruction set") message(STATUS "GLM: SSE3 instruction set")
elseif(GLM_TEST_ENABLE_SIMD_SSE2) elseif(GLM_TEST_ENABLE_SIMD_SSE2)
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")) if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
add_compiler_options(-msse2) add_compile_options(-msse2)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compiler_options(/QxSSE2) add_compile_options(/QxSSE2)
elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND NOT CMAKE_CL_64) elseif((CMAKE_CXX_COMPILER_ID MATCHES "MSVC") AND NOT CMAKE_CL_64)
add_compiler_options(/arch:SSE2) add_compile_options(/arch:SSE2)
endif() endif()
message(STATUS "GLM: SSE2 instruction set") message(STATUS "GLM: SSE2 instruction set")
endif() endif()
# Additional compiler options # 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")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_compile_options(-O2)
add_compiler_options(-Werror -Weverything) add_compile_options(-Wno-long-long)
add_compiler_options(-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) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compiler_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) message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_compiler_options(-O2) message("GLM: Visual C++ - ${CMAKE_CXX_COMPILER_ID} compiler")
add_compiler_options(-Wno-long-long)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_options(/FAs)
add_compiler_options(/FAs)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif() endif()

Loading…
Cancel
Save