@@ -13,6 +13,18 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
+# Give to CMake the {C,CXX}FLAGS to append in case the project's logic
+# falls back on a build type or another (i.e. set CMAKE_{C,CXX}_FLAGS_*
+# variables).
+#
+# Note:
+# if the project forces some of these flag variables, Buildroot is
+# screwed up and there is nothing Buildroot can do about that :(
+set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Debug CFLAGS")
+set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
+set(CMAKE_C_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CFLAGS")
+set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")
+
# Build type from the Buildroot configuration
set(CMAKE_BUILD_TYPE @@BR_CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
The toolchainfile.cmake file already sets the build type to get close to the Buildroot configuration. This change sets the per-config compiler flags CMake appends, so CMake does not mess up with the compilation flags Buildroot sets. This change still allows overriding the these variables from the configure command line. Note: If a CMake-based project forces using a given build type and/or force the compiler and/or linker flag definitions (the default ones or the per-config ones - e.g. CMAKE_C_FLAGS/CMAKE_C_FLAGS_{DEBUG,RELEASE}), there is not much Buildroot can do about it. So, the flags will be overwritten anyway in these cases. Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com> Signed-off-by: Samuel Martin <s.martin49@gmail.com> --- changes v4->v5: - fix cmake set call changes v3->v4: - new patch --- support/misc/toolchainfile.cmake.in | 12 ++++++++++++ 1 file changed, 12 insertions(+)