diff --git a/CMakeLists.txt b/CMakeLists.txt index 47f8ebdca8581..b6462c698aefa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,10 +165,12 @@ cmake_dependent_option(ENABLE_FUZZ "Build for fuzzing. Enabling this will disabl option(INSTALL_MAN "Install man pages." ON) -set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the flags added by the build system.") -set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the flags added by the build system.") -set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the flags added by the build system.") -set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the flags added by the build system.") +set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") +set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") +set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") +set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the command line after all other flags added by the build system. This variable is intended for debugging and special builds.") +# Appending to this low-level rule variables is the only way to +# guarantee that the flags appear at the end of the command line. string(APPEND CMAKE_CXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}") string(APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}") string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")