@@ -42,95 +42,25 @@ if(NOT CMAKE_BUILD_TYPE)
4242endif ()
4343
4444# Set per-config compile flags.
45- # We append to CMAKE_CXX_FLAGS_<CONFIG> (rather than replacing) to preserve toolchain defaults like /EHsc, /MD, etc.
46- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
47- string (APPEND CMAKE_CXX_FLAGS_DEBUG " -g -O0 -Wall -Wextra" )
48- string (APPEND CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG" )
45+ if (MSVC ) # clang-cl and cl
46+ set (CMAKE_CXX_FLAGS_DEBUG "/Zi /Od /W3 /RTC1" )
47+ set (CMAKE_CXX_FLAGS_RELEASE "/O2 /W1 /DNDEBUG" )
48+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Zi /O2 /W1 /DNDEBUG" )
49+ elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
50+ set (CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra" )
51+ set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" )
52+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 -DNDEBUG" )
4953elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang" )
50- string (APPEND CMAKE_CXX_FLAGS_DEBUG " -g -O0 -Wall -Wextra" )
51- if (MSVC )
52- # clang-cl: CMake already sets /O2 /DNDEBUG; just suppress warnings
53- string (APPEND CMAKE_CXX_FLAGS_RELEASE " -Wno-all -Wno-extra" )
54- else ()
55- string (APPEND CMAKE_CXX_FLAGS_RELEASE " -O3 -DNDEBUG -Wno-all -Wno-extra" )
56- endif ()
57- # Suppress noisy clang warnings from FetchContent dependencies.
58- add_compile_options (
59- -Wno-c++98-compat
60- -Wno-c++98-compat-extra-semi
61- -Wno-c++98-compat-pedantic
62- -Wno-cast-function-type-strict
63- -Wno-cast-qual
64- -Wno-covered-switch-default
65- -Wno-defaulted-function-deleted
66- -Wno-deprecated-copy-with-dtor
67- -Wno-deprecated-declarations
68- -Wno-disabled-macro-expansion
69- -Wno-documentation
70- -Wno-documentation-pedantic
71- -Wno-documentation-unknown-command
72- -Wno-double-promotion
73- -Wno-exit-time-destructors
74- -Wno-extra-semi
75- -Wno-extra-semi-stmt
76- -Wno-float-conversion
77- -Wno-float-equal
78- -Wno-format-nonliteral
79- -Wno-global-constructors
80- -Wno-implicit-float-conversion
81- -Wno-implicit-int-float-conversion
82- -Wno-inconsistent-missing-destructor-override
83- -Wno-inconsistent-missing-override
84- -Wno-macro-redefined
85- -Wno-missing-noreturn
86- -Wno-missing-prototypes
87- -Wno-newline-eof
88- -Wno-old-style-cast
89- -Wno-reserved-identifier
90- -Wno-reserved-macro-identifier
91- -Wno-shorten-64-to-32
92- -Wno-sign-conversion
93- -Wno-sign-compare
94- -Wno-suggest-override
95- -Wno-suggest-destructor-override
96- -Wno-switch-default
97- -Wno-switch-enum
98- -Wno-undefined-func-template
99- -Wno-unsafe-buffer-usage
100- -Wno-unsafe-buffer-usage-in-libc-call
101- -Wno-unused-macros
102- -Wno-unused-parameter
103- -Wno-unused-variable
104- )
105- elseif (MSVC )
106- string (APPEND CMAKE_CXX_FLAGS_DEBUG " /Zi /Od /W3" )
107- string (APPEND CMAKE_CXX_FLAGS_RELEASE " /O2 /W1 /DNDEBUG" )
54+ set (CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra" )
55+ set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" )
56+ set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3 -DNDEBUG" )
57+ else ()
58+ message (WARNING "Unknown compiler ${CMAKE_CXX_COMPILER_ID} , using default CMAKE_CXX_FLAGS" )
10859endif ()
60+ set (CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} " )
61+ set (CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} " )
62+ set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )
10963
110- if (MSVC )
111- # MSVC CRT doesn't define M_PI etc. without this.
112- add_compile_definitions (_USE_MATH_DEFINES )
113-
114- # lapackpp's lartg.cc uses std::complex without #include <complex>.
115- # On libstdc++ it's transitively included; on MSVC STL it isn't.
116- # Use CMAKE_CXX_FLAGS (not add_compile_options) so it only applies to C++ files,
117- # avoiding STL1003 errors when C files get the C++ <complex> header.
118- # Force-include <complex> for C++ only — GauXC has C files that would break.
119- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI complex" )
120-
121- # gau2grid_helper.c calls exit() without #include <stdlib.h>.
122- # Clang-cl treats implicit function declarations as errors in C99+.
123- # Native MSVC cl.exe allows them by default, so no flag needed there.
124- if (CMAKE_C_COMPILER_ID MATCHES "Clang" )
125- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-function-declaration" )
126- endif ()
127-
128- # blaspp's BLASFinder.cmake uses try_run() to detect Fortran name mangling,
129- # but on Windows the test executable can't find openblas.dll at runtime,
130- # leaving blas/defines.h empty and breaking lapackpp.
131- # OpenBLAS uses lowercase + trailing underscore (see OPENBLAS_FUNDERSCORE).
132- add_compile_definitions (BLAS_FORTRAN_ADD_ )
133- endif ()
13464
13565# Options
13666option (QDK_CHEMISTRY_ENABLE_COVERAGE "Enable coverage build" OFF )
@@ -185,7 +115,7 @@ if(NOT macis_FOUND)
185115 set (MACIS_ENABLE_MPI OFF CACHE BOOL "MACIS enable MPI" FORCE )
186116 set (MACIS_ENABLE_PYTHON OFF CACHE BOOL "MACIS Enable Python" FORCE )
187117 set (MACIS_ENABLE_EXAMPLES OFF CACHE BOOL "MACIS Build Examples" FORCE )
188- set (MACIS_ENABLE_TESTS OFF CACHE BOOL "MACIS Build Tests" )
118+ set (MACIS_ENABLE_TESTS ON CACHE BOOL "MACIS Build Tests" )
189119 set (MACIS_ENABLE_OPENMP ${QDK_ENABLE_OPENMP} CACHE BOOL "MACIS Enable OpenMP" FORCE )
190120 if (DEFINED QDK_UARCH_USED)
191121 set (MACIS_UARCH ${QDK_UARCH_USED} CACHE STRING "MACIS Microarchitecture" FORCE )
@@ -212,56 +142,6 @@ endif()
212142
213143# Create library
214144add_library (chemistry )
215-
216- # Re-enable warnings for our own code that were globally suppressed for FetchContent dependencies.
217- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang" )
218- target_compile_options (chemistry PRIVATE
219- -Wcast-function-type-strict
220- -Wcast-qual
221- # -Wcovered-switch-default
222- -Wdisabled-macro-expansion
223- # -Wdefaulted-function-deleted
224- -Wdeprecated-copy-with-dtor
225- -Wdeprecated-declarations
226- # -Wdocumentation
227- # -Wdocumentation-pedantic
228- # -Wdocumentation-unknown-command
229- # -Wdouble-promotion
230- # -Wexit-time-destructors
231- # -Wextra-semi
232- # -Wextra-semi-stmt
233- # -Wfloat-conversion
234- # -Wfloat-equal
235- # -Wformat-nonliteral
236- # -Wglobal-constructors
237- # -Wimplicit-float-conversion
238- # -Wimplicit-int-float-conversion
239- # -Winconsistent-missing-destructor-override
240- # -Winconsistent-missing-override
241- # -Wmacro-redefined
242- # -Wmissing-noreturn
243- # -Wmissing-prototypes
244- # -Wnewline-eof
245- # -Wold-style-cast
246- -Wreserved-identifier
247- -Wreserved-macro-identifier
248- # -Wshorten-64-to-32
249- # -Wsign-compare
250- # -Wsign-conversion
251- # -Wsuggest-override
252- # -Wsuggest-destructor-override
253- # -Wswitch-default
254- # -Wswitch-enum
255- -Wundefined-func-template
256- -Wunreachable-code
257- -Wunreachable-code-return
258- # -Wunsafe-buffer-usage
259- # -Wunsafe-buffer-usage-in-libc-call
260- # -Wunused-macros
261- # -Wunused-parameter
262- # -Wunused-variable
263- )
264- endif ()
265145add_subdirectory (src/qdk/chemistry/data )
266146add_subdirectory (src/qdk/chemistry/algorithms )
267147add_subdirectory (src/qdk/chemistry/utils )
0 commit comments