File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,15 @@ else()
5252 endif ()
5353endif ()
5454
55+ # Add optimization flags to any configuration that is NOT Debug. Note: CMake
56+ # will automatically use the appropriate debug flags (e.g., /Od and /Zi for
57+ # MSVC, or -O0 -g for GCC/Clang), so there's no need to do that part.
58+ if (MSVC )
59+ add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
60+ else ()
61+ add_compile_options ($<$<NOT :$<CONFIG :Debug >>:-O3 >)
62+ endif ()
63+
5564find_package (OpenMP REQUIRED )
5665
5766# Always build the basic part.
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim)
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/arch:AVX2 /openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
23- elseif (LINUX )
24- add_compile_options (-mavx2 -mfma -O3 -flto=auto )
20+ else ()
21+ add_compile_options (-mavx2 -mfma -flto=auto )
2522 execute_process (
2623 COMMAND bash --noprofile -c "grep -qs bmi2 /proc/cpuinfo"
2724 RESULT_VARIABLE _EXIT_CODE
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim)
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/arch:AVX512 /openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-mavx512f -mbmi2 -O3 - flto=auto )
21+ add_compile_options (-mavx512f -mbmi2 -flto=auto )
2522endif ()
2623
2724if (APPLE )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim)
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-O3 - flto=auto )
21+ add_compile_options (-flto=auto )
2522endif ()
2623
2724if (APPLE )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim LANGUAGES CXX CUDA )
1717
18- if (WIN32 )
18+ if (MSVC )
1919 # Always apply AVX2 and openmp on Windows
2020 add_compile_options (/openmp )
21- # Add /O2 to any configuration that is NOT Debug.
22- # This prevents a conflict with /RTC1 in DEBUG builds.
23- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2421else ()
25- add_compile_options (-O3 - fno-lto )
22+ add_compile_options (-fno-lto )
2623endif ()
2724
2825if (APPLE )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim LANGUAGES CXX CUDA )
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-O3 - fno-lto )
21+ add_compile_options (-fno-lto )
2522endif ()
2623
2724if (APPLE )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim LANGUAGES CXX CUDA )
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-O3 - fno-lto )
21+ add_compile_options (-fno-lto )
2522endif ()
2623
2724if (APPLE )
Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ project(qsim LANGUAGES CXX)
1818include (CheckLanguage )
1919check_language (CUDA )
2020
21- if (WIN32 )
21+ if (MSVC )
2222 add_compile_options (/openmp )
23- # Add /O2 to any configuration that is NOT Debug.
24- # This prevents a conflict with /RTC1 in DEBUG builds.
25- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2623else ()
27- add_compile_options (-O3 - fno-lto )
24+ add_compile_options (-fno-lto )
2825endif ()
2926
3027if (APPLE )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim LANGUAGES CXX HIP )
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-O3 - fno-lto )
21+ add_compile_options (-fno-lto )
2522endif ()
2623
2724include (../GetPybind11.cmake )
Original file line number Diff line number Diff line change 1515cmake_minimum_required (VERSION 3.28 )
1616project (qsim)
1717
18- if (WIN32 )
18+ if (MSVC )
1919 add_compile_options (/openmp )
20- # Add /O2 to any configuration that is NOT Debug.
21- # This prevents a conflict with /RTC1 in DEBUG builds.
22- add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2320else ()
24- add_compile_options (-msse4 -O3 - flto=auto )
21+ add_compile_options (-msse4 -flto=auto )
2522endif ()
2623
2724if (APPLE )
You can’t perform that action at this time.
0 commit comments