git: c7532c276101 - main - devel/cmake-core: Respect user CFLAGS/CXXFLAGS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 03 May 2025 07:08:05 UTC
The branch main has been updated by jhale:
URL: https://cgit.FreeBSD.org/ports/commit/?id=c7532c276101c3ad3f9428b45c9d4b13c6cff395
commit c7532c276101c3ad3f9428b45c9d4b13c6cff395
Author: Jason E. Hale <jhale@FreeBSD.org>
AuthorDate: 2025-05-03 05:29:38 +0000
Commit: Jason E. Hale <jhale@FreeBSD.org>
CommitDate: 2025-05-03 07:07:57 +0000
devel/cmake-core: Respect user CFLAGS/CXXFLAGS
CMake has set a few compiler optimization flags for ages, depending upon
the build type. For Debug and Release build types, especially, these
flags are overridden in Mk/Uses/cmake.mk for projects that use CMake,
including other CMake components, i.e., devel/cmake-(doc|gui|man), but
not cmake-core, since it has to bootstrap itself.
This change makes the core component build with the same flags as the
rest of the cmake ports. For most users, this just means that cmake-core
will now build with -O2 instead of -O3 by default.
Not bumping PORTREVISION since nobody has really cared about this for the
past 15 years. To be clear, all other CFLAGS/CXXFLAGS have been
respected. This just elimitates the -O3 flag that CMake internally adds
for Release builds of cmake-core.
Based upon work by former FreeBSD committer koobs. [1]
[1] https://github.com/koobs/ports/commit/da342cfb3dd94f005e4a44d2ef9c863fc19b58e2 [1]
Co-authored-by: Daniel Engberg <diizzy@FreeBSD.org>
PR: 286494
---
devel/cmake-core/files/InitialCache.cmake.in | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/devel/cmake-core/files/InitialCache.cmake.in b/devel/cmake-core/files/InitialCache.cmake.in
index 15977658349d..8e251e632a23 100644
--- a/devel/cmake-core/files/InitialCache.cmake.in
+++ b/devel/cmake-core/files/InitialCache.cmake.in
@@ -13,3 +13,14 @@ set(LibArchive_INCLUDE_DIR "/usr/include" CACHE PATH
"Directory where LibArchive headers are located.")
set(LibArchive_LIBRARY "/usr/lib/libarchive.so" CACHE PATH
"LibArchive library to link against.")
+
+# Respect user CFLAGS/CXXFLAGS for DEBUG and RELEASE builds as in
+# Mk/Uses/cmake.mk.
+set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING
+ "Flags used by the C compiler during DEBUG builds.")
+set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
+ "Flags used by the C compiler during RELEASE builds.")
+set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING
+ "Flags used by the CXX compiler during DEBUG builds.")
+set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG" CACHE STRING
+ "Flags used by the CXX compiler during RELEASE builds.")