From bb9cc43a6dd7b0373c7387409ebce7ba56cd7bd4 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 15 Sep 2013 03:09:10 +0200 Subject: [PATCH] Updated CMake instruction set selection --- CMakeLists.txt | 56 ++++++++++++++++++++++++++++++++++------------ glm/core/setup.hpp | 2 +- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6490caf1..469a7358 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,25 +49,53 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" endif() endif() -#set(GLM_SIMD_INSTRUCTION_SET "" CACHE STRING "Instruction set. Possible values are SSE1, SSE2") +option(GLM_TEST_ENABLE_SSE2 "Enable SSE2 optimizations" OFF) +option(GLM_TEST_ENABLE_SSE3 "Enable SSE3 optimizations" OFF) +option(GLM_TEST_ENABLE_AVX "Enable AVX optimizations" OFF) +option(GLM_TEST_ENABLE_AVX2 "Enable AVX2 optimizations" OFF) +option(GLM_TEST_FORCE_PURE "Force 'pure' instructions" OFF) -option(GLM_TEST_ENABLE_SIMD "Enable SIMD optimizations" OFF) -if(GLM_TEST_ENABLE_SIMD) - if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-msse2) - elseif(GLM_USE_INTEL) - add_definitions(/QxAVX) - elseif(MSVC10) - add_definitions(/arch:AVX) - elseif(MSVC) - add_definitions(/arch:SSE2) - endif() -elseif(NOT GLM_TEST_ENABLE_SIMD) - +if(GLM_TEST_FORCE_PURE) add_definitions(-DGLM_FORCE_PURE) if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-mfpmath=387) + elseif(MSVC) + add_definitions(/arch:IA32) + endif() +elseif(GLM_TEST_ENABLE_AVX2) + if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-mavx2) + elseif(GLM_USE_INTEL) + add_definitions(/QxAVX2) + elseif(MSVC) + add_definitions(/arch:AVX2) + endif() +elseif(GLM_TEST_ENABLE_AVX) + if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-mavx) + elseif(GLM_USE_INTEL) + add_definitions(/QxAVX) + elseif(MSVC) + add_definitions(/arch:AVX) + endif() +elseif(GLM_TEST_ENABLE_SSE3) + if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-msse3) + elseif(GLM_USE_INTEL) + add_definitions(/QxSSE3) + elseif(MSVC) + add_definitions(/arch:SSE3) + endif() +elseif(GLM_TEST_ENABLE_SSE2) + if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-msse2) + elseif(GLM_USE_INTEL) + add_definitions(/QxSSE2) + elseif(MSVC) + if(NOT CMAKE_CL_64) + add_definitions(/arch:SSE2) + endif() endif() endif() diff --git a/glm/core/setup.hpp b/glm/core/setup.hpp index a0c0536f..511831ad 100644 --- a/glm/core/setup.hpp +++ b/glm/core/setup.hpp @@ -685,7 +685,7 @@ #if(defined(GLM_MESSAGES) && !defined(GLM_MESSAGE_SWIZZLE_DISPLAYED)) # define GLM_MESSAGE_SWIZZLE_DISPLAYED -# if defined(GLM_SWIZZL)E +# if defined(GLM_SWIZZL) # pragma message("GLM: Swizzling operators enabled") # else # pragma message("GLM: Swizzling operators disabled")