diff options
author | Be <be@mixxx.org> | 2020-12-16 18:01:17 -0600 |
---|---|---|
committer | Be <be@mixxx.org> | 2020-12-16 18:01:17 -0600 |
commit | b884f4f0622a2fdccdd8a41c87639fe603a24fd0 (patch) | |
tree | c08d64cc2cd73c274457389d12342491c0d6dcaa /CMakeLists.txt | |
parent | 648bc1d0433e67b94157f13fc7c2904d7cd8d5ec (diff) | |
parent | e80ce44df0f440e108ca1f0cecb1e16b26517c3e (diff) |
Merge remote-tracking branch 'upstream/2.3' into main
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bea844cdc3..c95899660e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,17 @@ endif() # set(OPTIMIZE "portable" CACHE STRING "Optimization and Tuning (set to off, portable, native, legacy, fastbuild)") message(STATUS "Optimization level: ${OPTIMIZE}") -if(NOT OPTIMIZE STREQUAL "off") - if(MSVC) + +if(MSVC) + # Microsoft Visual Studio Compiler + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # Target architecture is x64 -> x64 has alsways SSE and SSE2 instruction sets + message(STATUS "x64 Enabling SS2 CPU optimizations (>= Pentium 4)") + # Define gcc/clang style defines for SSE and SSE2 for compatibility + add_compile_definitions("__SSE__" "__SSE2__") + endif() + + if(NOT OPTIMIZE STREQUAL "off") # Use the fastest floating point math library # http://msdn.microsoft.com/en-us/library/e7s85ffb.aspx # http://msdn.microsoft.com/en-us/library/ms235601.aspx @@ -97,10 +106,6 @@ if(NOT OPTIMIZE STREQUAL "off") add_compile_options(/Gy) add_link_options(/OPT:REF /OPT:ICF) - # Don't worry about aligning code on 4KB boundaries - # ALBERT: NOWIN98 is not supported in MSVC 2010. - #add_link_options(mixxx-lib PUBLIC "/OPT:NOWIN98") - # http://msdn.microsoft.com/en-us/library/59a3b321.aspx # In general, you should pick /O2 over /Ox add_compile_options($<$<NOT:$<CONFIG:Debug>>:/O2>) @@ -130,22 +135,39 @@ if(NOT OPTIMIZE STREQUAL "off") endif() if(OPTIMIZE STREQUAL "portable" OR OPTIMIZE STREQUAL "fastbuild") - message(STATUS "Enabling SS2 CPU optimizations (>= Pentium 4)") - # SSE and SSE2 are core instructions on x64 - # and consequently raise a warning message from compiler with this flag on x64. if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + # Target architecture is x86 with SSE and SSE2 + message(STATUS "x86 Enabling SS2 CPU optimizations (>= Pentium 4)") + # Define gcc/clang style defines for SSE and SSE2 for compatibility + add_compile_definitions("__SSE__" "__SSE2__") + # Set compiler option for SSE/SSE2 add_compile_options(/arch:SSE2) endif() - add_compile_definitions("__SSE__" "__SSE2__") elseif(OPTIMIZE STREQUAL "native") - message("Enabling native optimizations for ${CMAKE_SYSTEM_PROCESSOR}") + message("Enabling optimizations for native system, specified by user") + if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + # Target architecture is x86 with SSE and SSE2 + message(STATUS "x86 Enabling SS2 CPU optimizations (>= Pentium 4)") + # Define gcc/clang style defines for SSE and SSE2 for compatibility + add_compile_definitions("__SSE__" "__SSE2__") + endif() + # Define the target processor instruction and other compiler optimization flags here: + # https://docs.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-160 + # add_compile_options(/arch:AVX512) + message(FATAL_ERROR "User need to set the MSVC compiler flags for the native processor here!") add_compile_options("/favor:${CMAKE_SYSTEM_PROCESSOR}") elseif(OPTIMIZE STREQUAL "legacy") - message("Enabling pure i386 code") + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + message("Enabling pure x64 instruction set (without AVX etc.)") + else() + message("Enabling pure i386 instruction set (without SSE/SSE2 etc.)") + endif() else() message(FATAL_ERROR "Invalid value passed to OPTIMIZE option: ${OPTIMIZE}") endif() - elseif(GNU_GCC OR LLVM_CLANG) + endif() +elseif(GNU_GCC OR LLVM_CLANG) + if(NOT OPTIMIZE STREQUAL "off") # Common flags to all optimizations. # -ffast-math will prevent a performance penalty by denormals # (floating point values almost Zero are treated as Zero) |