diff --git a/dlib/cmake b/dlib/cmake index c50807397..f1c4351c2 100644 --- a/dlib/cmake +++ b/dlib/cmake @@ -12,9 +12,9 @@ if (NOT TARGET dlib) add_definitions("-Wreturn-type") endif() + # Setup some options to allow a user to enable SSE and AVX instruction use. option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF) option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF) if(USE_AVX_INSTRUCTIONS) @@ -30,7 +30,12 @@ if (NOT TARGET dlib) if(USE_AVX_INSTRUCTIONS) add_definitions(/arch:AVX) elseif (USE_SSE4_INSTRUCTIONS) - add_definitions(/arch:SSE2) # There isn't an /arch:SSE4 flag in visual studio. + # There isn't an /arch:SSE4 flag in visual studio. But we can tell + # dlib to use those instructions anyway with the DLIB_HAVE_SSE3 and + # DLIB_HAVE_SSE41 #defines. + add_definitions(/arch:SSE2) + add_definitions(-DDLIB_HAVE_SSE3) + add_definitions(-DDLIB_HAVE_SSE41) elseif(USE_SSE2_INSTRUCTIONS) add_definitions(/arch:SSE2) endif()