Skip to content

Commit e4cdf81

Browse files
committed
Simplify CMake compiler flags and remove global warning suppression
- Replace string(APPEND) with set() for per-config flags; add RelWithDebInfo config and mirror C flags from CXX flags. - Remove the global add_compile_options(-Wno-...) block and the per-target re-enable block — dependencies handle their own warnings. - Remove MSVC-specific workarounds now handled in dependencies (_USE_MATH_DEFINES, /FI complex, BLAS_FORTRAN_ADD_, -Wno-implicit-function-declaration). - Update gauxc hash containing clang-cl fixes. - Enable MACIS_ENABLE_TESTS by default (overridable via -D).
1 parent 971941a commit e4cdf81

5 files changed

Lines changed: 35 additions & 142 deletions

File tree

.pipelines/pip-scripts/windows-build-clang-cmake.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# windows-build-clang-cmake.ps1
2-
# Local script to build and test the QDK Chemistry Python package on Windows using Clang and CMake.
2+
# Local script to build and test the QDK Chemistry Python package on Windows using clang-cl and CMake.
33
# Run from the repo root in an elevated PowerShell (admin) if VS Build Tools need installing.
44
#
55
# Usage:
@@ -197,7 +197,7 @@ if (-not $SkipPrereqs) {
197197

198198
# --- 0d. Install vcpkg packages ---
199199
Write-Host ""
200-
Write-Host "Installing vcpkg dependencies (this may take a while on first run)..."
200+
Write-Host "Installing vcpkg dependencies with triplet '$VcpkgTriplet' (this may take a while on first run)..."
201201
& "$vcpkgRoot\vcpkg.exe" install `
202202
--triplet $VcpkgTriplet `
203203
--x-manifest-root="$RepoRoot" `
@@ -249,6 +249,8 @@ if (-not $SkipPrereqs) {
249249
}
250250
}
251251
Assert-Command "clang-cl"
252+
Assert-Command "cmake"
253+
Assert-Command "ninja"
252254

253255
# Set up MSVC env
254256
$vcvarsall = "$vsPath\VC\Auxiliary\Build\vcvarsall.bat"
@@ -310,6 +312,7 @@ if (-not $SkipCpp) {
310312
-DQDK_CHEMISTRY_ENABLE_COVERAGE=OFF `
311313
-DQDK_CHEMISTRY_ENABLE_MPI=OFF `
312314
-DQDK_ENABLE_OPENMP=ON `
315+
-DMACIS_ENABLE_TESTS=OFF `
313316
-DBUILD_SHARED_LIBS=OFF `
314317
-DBUILD_TESTING=ON `
315318
-DCMAKE_BUILD_TYPE=Release `
@@ -318,7 +321,8 @@ if (-not $SkipCpp) {
318321
-DCMAKE_INSTALL_PREFIX="$InstallDir" `
319322
-DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" `
320323
-DVCPKG_TARGET_TRIPLET="$env:VCPKG_TARGET_TRIPLET" `
321-
-DVCPKG_INSTALLED_DIR="$env:VCPKG_INSTALLED_DIR"
324+
-DVCPKG_INSTALLED_DIR="$env:VCPKG_INSTALLED_DIR" `
325+
-DFETCHCONTENT_QUIET=OFF
322326
if ($LASTEXITCODE -ne 0) { Write-Error "CMake configure failed"; exit 1 }
323327
} else {
324328
Write-Host "=== Step 1: Skipping configure (incremental build) ===" -ForegroundColor DarkGray

.pipelines/pip-scripts/windows-build-clang-pip.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ if (-not $SkipPrereqs) {
244244
}
245245
}
246246
Assert-Command "clang-cl"
247+
Assert-Command "cmake"
248+
Assert-Command "ninja"
247249

248250
# Set up MSVC env
249251
$vcvarsall = "$vsPath\VC\Auxiliary\Build\vcvarsall.bat"

cpp/CMakeLists.txt

Lines changed: 17 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -42,95 +42,25 @@ if(NOT CMAKE_BUILD_TYPE)
4242
endif()
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")
4953
elseif(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")
10859
endif()
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
13666
option(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
214144
add_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()
265145
add_subdirectory(src/qdk/chemistry/data)
266146
add_subdirectory(src/qdk/chemistry/algorithms)
267147
add_subdirectory(src/qdk/chemistry/utils)

cpp/cmake/third_party.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ else()
8181
endif()
8282

8383
handle_dependency(gauxc
84-
GIT_REPOSITORY https://github.com/wavefunction91/gauxc.git
85-
GIT_TAG 2c4a2bd785eae44ae0049f06057c23ca0239ae33
84+
GIT_REPOSITORY https://github.com/lorisercole/gauxc.git
85+
GIT_TAG 4e18eb1c4fc3b7bc1d2f91c59d8a4826b0997a4f
8686
BUILD_TARGET gauxc::gauxc
8787
INSTALL_TARGET gauxc::gauxc
8888
${DEPENDENCY_BUILD_FLAGS}

cpp/include/qdk/chemistry/data/structure.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ class Structure : public DataClass,
114114
*/
115115
Structure(Structure&& other) noexcept = default;
116116

117+
/**
118+
* @brief Copy assignment operator
119+
*/
117120
Structure& operator=(const Structure&) = delete;
121+
122+
/**
123+
* @brief Move assignment operator
124+
*/
118125
Structure& operator=(Structure&&) = delete;
119126

120127
/**

0 commit comments

Comments
 (0)