Browse Source

Fixed Apple Clang detection

Christophe Riccio 8 years ago
parent
commit
1a973285f7
1 changed files with 50 additions and 44 deletions
  1. 50 44
      CMakeLists.txt

+ 50 - 44
CMakeLists.txt

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