Add CMake options for disabling ObjC++ entirely and for forcing the build of a separate libobjcxx.so.

main
theraven 13 years ago
parent 95204ad094
commit c37fdd98ad

@ -174,34 +174,52 @@ set_source_files_properties(
# C++ Runtime interaction # C++ Runtime interaction
# #
# Try to find libcxxrt.so. We can link to this to provide the C++ ABI layer, set(ENABLE_OBJCXX true CACHE BOOL
# if it exists. "Enable support for Objective-C++")
find_library(CXX_RUNTIME cxxrt) set(FORCE_LIBOBJCXX false CACHE BOOL
# If it doesn't, then look for GNU libsupc++.so instead (either works, they're "Force building a separate Objective-C++ runtime library")
# ABI compatible). if (ENABLE_OBJCXX)
if (NOT CXX_RUNTIME) # Try to find libcxxrt.so. We can link to this to provide the C++ ABI
find_library(CXX_RUNTIME supc++) # layer, if it exists.
endif (NOT CXX_RUNTIME) find_library(CXX_RUNTIME cxxrt)
# If it doesn't, then look for GNU libsupc++.so instead (either works,
# If we have a C++ ABI library, then we can produce a single libobjc that works # they're ABI compatible).
# for Objective-C and Objective-C++. If not, then we need to provide a if (NOT CXX_RUNTIME)
# separate libobjcxx. find_library(CXX_RUNTIME supc++)
if (CXX_RUNTIME) endif (NOT CXX_RUNTIME)
message(STATUS "Using ${CXX_RUNTIME} as the C++ runtime library")
set(libobjc_CXX_SRCS ${libobjcxx_CXX_SRCS}) # If we have a C++ ABI library, then we can produce a single libobjc that
# We don't want to link the STL implementation (e.g. libstdc++) if we have # works for Objective-C and Objective-C++. If not, then we need to provide
# a separate C++ runtime. # a separate libobjcxx.
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") if (CXX_RUNTIME)
else (CXX_RUNTIME) message(STATUS "Using ${CXX_RUNTIME} as the C++ runtime library")
message(STATUS "No C++ runtime library found") if (FORCE_LIBOBJCXX)
add_library(objcxx SHARED ${libobjcxx_CXX_SRCS}) message(STATUS "Forcing build of stand-alone libobjcxx")
set_target_properties(objcxx PROPERTIES add_library(objcxx SHARED ${libobjcxx_CXX_SRCS})
LINKER_LANGUAGE C set_target_properties(objcxx PROPERTIES
SOVERSION ${libobjc_VERSION} LINKER_LANGUAGE C
) SOVERSION ${libobjc_VERSION}
set(CXX_RUNTIME "") )
list(APPEND INSTALL_TARGETS objcxx) target_link_libraries(objcxx ${CXX_RUNTIME})
endif (CXX_RUNTIME) set(CXX_RUNTIME "")
list(APPEND INSTALL_TARGETS objcxx)
else ()
set(libobjc_CXX_SRCS ${libobjcxx_CXX_SRCS})
# We don't want to link the STL implementation (e.g. libstdc++) if
# we have a separate C++ runtime.
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
endif ()
else ()
message(STATUS "No C++ runtime library found")
add_library(objcxx SHARED ${libobjcxx_CXX_SRCS})
set_target_properties(objcxx PROPERTIES
LINKER_LANGUAGE C
SOVERSION ${libobjc_VERSION}
)
set(CXX_RUNTIME "")
list(APPEND INSTALL_TARGETS objcxx)
endif ()
endif (ENABLE_OBJCXX)

Loading…
Cancel
Save