Skip to content

Commit 7a25de6

Browse files
committed
llvm-config: emit the C++ standard flag into CXXFLAGS
This recovers the now "missing" flag as this is controlled by CMake rather than injected into the user defined flags list. This is primarily needed by LDC and other out-of-tree users which do not correctly setup the C++ flags.
1 parent 21a518f commit 7a25de6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/tools/llvm-config/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,9 @@ string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
2929
# Fetch target specific compile options, e.g. RTTI option
3030
get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS)
3131

32-
# The language standard potentially affects the ABI/API of LLVM, so we want
33-
# to make sure it is reported by llvm-config.
3432
# NOTE: We don't want to start extracting any random C/CXX flags that the
3533
# user may add that could affect the ABI. We only want to extract flags
3634
# that have been added by the LLVM build system.
37-
string(REGEX MATCH "-std=[^ ]+" LLVM_CXX_STD_FLAG ${CMAKE_CXX_FLAGS})
3835
string(REGEX MATCH "-stdlib=[^ ]+" LLVM_CXX_STDLIB_FLAG ${CMAKE_CXX_FLAGS})
3936
string(REGEX MATCH "-std=[^ ]+" LLVM_C_STD_FLAG ${CMAKE_C_FLAGS})
4037

@@ -43,7 +40,9 @@ set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR})
4340
set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR})
4441
set(LLVM_CPPFLAGS "${LLVM_DEFINITIONS}")
4542
set(LLVM_CFLAGS "${LLVM_C_STD_FLAG} ${LLVM_DEFINITIONS}")
46-
set(LLVM_CXXFLAGS "${LLVM_CXX_STD_FLAG} ${LLVM_CXX_STDLIB_FLAG} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
43+
# The language standard potentially affects the ABI/API of LLVM, so we want
44+
# to make sure it is reported by llvm-config.
45+
set(LLVM_CXXFLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION} ${LLVM_CXX_STDLIB_FLAG} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
4746
set(LLVM_BUILD_SYSTEM cmake)
4847
set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
4948
set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}")

0 commit comments

Comments
 (0)