Use URDE_VECTOR_ISA CMake variable instead of individual bools

This commit is contained in:
Jack Andersen 2017-12-27 12:23:21 -10:00
parent a01aa30e76
commit 1384197183
1 changed files with 21 additions and 13 deletions

View File

@ -17,22 +17,23 @@ set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
find_package(Sanitizers) find_package(Sanitizers)
option(URDE_SSE2 "Enable SSE2 flags." Off) set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
option(URDE_SSE3 "Enable SSE3 flags." On)
option(URDE_SSE41 "Enable SSE4.1 flags." Off)
option(URDE_AVX "Enable AVX flags." Off)
option(URDE_AVX2 "Enable AVX2 flags." Off)
if(MSVC) if(MSVC)
if(URDE_AVX2) if(${URDE_VECTOR_ISA} STREQUAL "avx2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 -D__SSE4_1__=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2 -D__SSE4_1__=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2 -D__SSE4_1__=1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX2 -D__SSE4_1__=1")
elseif(URDE_AVX) message(STATUS "Building with AVX2 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "avx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -D__SSE4_1__=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -D__SSE4_1__=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX -D__SSE4_1__=1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:AVX -D__SSE4_1__=1")
elseif(URDE_SSE41) message(STATUS "Building with AVX Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse41")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SSE4_1__=1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SSE4_1__=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__SSE4_1__=1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__SSE4_1__=1")
message(STATUS "Building with SSE4.1 Vector ISA")
else()
message(STATUS "Building with SSE2 Vector ISA")
endif() endif()
if(${CMAKE_GENERATOR} MATCHES "Visual Studio*") if(${CMAKE_GENERATOR} MATCHES "Visual Studio*")
@ -61,21 +62,28 @@ if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
else() else()
if(URDE_AVX2) if(${URDE_VECTOR_ISA} STREQUAL "avx2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx2")
elseif(URDE_AVX) message(STATUS "Building with AVX2 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "avx")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx")
elseif(URDE_SSE41) message(STATUS "Building with AVX Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse41")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
elseif(URDE_SSE3) message(STATUS "Building with SSE4.1 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
elseif(URDE_SSE2) message(STATUS "Building with SSE3 Vector ISA")
elseif(${URDE_VECTOR_ISA} STREQUAL "sse2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
message(STATUS "Building with SSE2 Vector ISA")
else()
message(STATUS "Building with x87 Vector ISA")
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\