Skip to content

Commit a8781c5

Browse files
committed
templates/cmake: manually add CPPFLAGS to compiler flags
CMake does not add ENV{CPPFLAGS} to CMAKE_${LANGUAGE}_FLAGS_INIT. We must either patch CMake or add CPPFLAGS to CFLAGS and CXXFLAGS manually.
1 parent 35caaed commit a8781c5

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

templates/11-cmakeninja.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ build_cmakeninja_configure() {
1818
fi
1919
BUILD_START
2020

21+
# NOTE: CMake does not add ENV{CPPFLAGS} to
22+
# CMAKE_${LANGUAGE}_FLAGS_INIT. We must either patch CMake or add
23+
# CPPFLAGS to CFLAGS and CXXFLAGS manually.
24+
export CFLAGS="$CPPFLAGS $CFLAGS"
25+
export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
2126
abinfo "Running CMakeLists.txt to generate Ninja Configuration ..."
22-
ab_tostringarray CMAKE_AFTER
27+
ab_tostringarray CMAKE_AFTER
2328
cmake "$SRCDIR" "${CMAKE_DEF[@]}" "${CMAKE_AFTER[@]}" -GNinja \
2429
|| abdie "Failed to run CMakeLists.txt: $?."
2530
}

templates/12-cmake.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ build_cmake_configure() {
1616
|| abdie "Failed to enter shadow build directory: $?."
1717
fi
1818

19-
BUILD_START
19+
BUILD_START
2020

21+
# NOTE: CMake does not add ENV{CPPFLAGS} to
22+
# CMAKE_${LANGUAGE}_FLAGS_INIT. We must either patch CMake or add
23+
# CPPFLAGS to CFLAGS and CXXFLAGS manually.
24+
export CFLAGS="$CPPFLAGS $CFLAGS"
25+
export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
2126
abinfo "Running CMakeLists.txt to generate Makefile ..."
22-
ab_tostringarray CMAKE_AFTER
27+
ab_tostringarray CMAKE_AFTER
2328
cmake "$SRCDIR" "${CMAKE_DEF[@]}" "${CMAKE_AFTER[@]}" \
2429
|| abdie "Failed to run CMakeLists.txt: $?."
2530
}

0 commit comments

Comments
 (0)