Skip to content

Commit 1b240a7

Browse files
committed
[CMake] Support alternative C++ ABI library
Do not assume that every platform has libsupc++. Differential Revision: https://reviews.llvm.org/D58598 llvm-svn: 354835
1 parent 40cb962 commit 1b240a7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,21 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TEST_SUITE_EXTRA_CXX_FLAGS}")
155155
set(CMAKE_EXE_LINKER_FLAGS
156156
"${CMAKE_EXE_LINKER_FLAGS} ${TEST_SUITE_EXTRA_EXE_LINKER_FLAGS}")
157157

158+
# This is either directly the C++ ABI library or the full C++ library
159+
# which pulls in the ABI transitively.
160+
set(TEST_SUITE_CXX_ABI "default" CACHE STRING "Specify C++ ABI library to use.")
161+
set(CXXABIS "none default libstdc++ libsupc++ libc++ libc++abi")
162+
set_property(CACHE TEST_SUITE_CXX_ABI PROPERTY STRINGS "${CXXABIS}")
163+
if (TEST_SUITE_CXX_ABI STREQUAL "default")
164+
if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD|Fuchsia")
165+
set(TEST_SUITE_CXX_ABI_LIBNAME "c++abi")
166+
else()
167+
set(TEST_SUITE_CXX_ABI_LIBNAME "supc++")
168+
endif()
169+
else()
170+
STRING(REGEX REPLACE "^lib" "" TEST_SUITE_CXX_ABI_LIBNAME ${TEST_SUITE_CXX_ABI})
171+
endif()
172+
158173
include(TestSuite)
159174
include(SingleMultiSource)
160175
find_package(TCL)

MultiSource/Applications/obsequi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ else()
66
list(APPEND CPPFLAGS -DHASHCODEBITS=23)
77
endif()
88
if(NOT "${ARCH}" STREQUAL "PowerPC")
9-
list(APPEND LDFLAGS -lsupc++)
9+
list(APPEND LDFLAGS -l${TEST_SUITE_CXX_ABI_LIBNAME})
1010
endif()
1111
set(RUN_OPTIONS < input)
1212
llvm_multisource(Obsequi)

0 commit comments

Comments
 (0)