Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -431,7 +431,7 @@ "Major version number that will be appended to the clang executable name") set(LIBCLANG_LIBRARY_VERSION "${CLANG_VERSION_MAJOR}" CACHE STRING - "Major version number that will be appended to the libclang library") + "Major version number that will be appended to the libclang, libclang_cxx libraries") mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION) option(CLANG_INCLUDE_TESTS Index: tools/CMakeLists.txt =================================================================== --- tools/CMakeLists.txt +++ tools/CMakeLists.txt @@ -35,3 +35,4 @@ # libclang may require clang-tidy in clang-tools-extra. add_clang_subdirectory(libclang) +add_clang_subdirectory(libclang-cxx) Index: tools/libclang-cxx/CMakeLists.txt =================================================================== --- /dev/null +++ tools/libclang-cxx/CMakeLists.txt @@ -0,0 +1,74 @@ +set(LIBS + clangBasic + clangCodeGen + clangDriver + clangFrontend + clangFrontendTool +) + +if (CLANG_ENABLE_ARCMT) + list(APPEND LIBS clangARCMigrate) +endif () + +if (TARGET clangTidyPlugin) + add_definitions(-DCLANG_TOOL_EXTRA_BUILD) + list(APPEND LIBS clangTidyPlugin) + list(APPEND LIBS clangIncludeFixerPlugin) + if(LLVM_ENABLE_MODULES) + list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD") + endif() +endif () + +find_library(DL_LIBRARY_PATH dl) +if (DL_LIBRARY_PATH) + list(APPEND LIBS dl) +endif() + +if( LLVM_ENABLE_PIC ) + set(ENABLE_SHARED SHARED) +endif() + +if(NOT LLVM_ENABLE_PIC AND NOT WIN32) + set(ENABLE_STATIC STATIC) +endif() + +if(WIN32) + set(output_name "libclang_cxx") +else() + set(output_name "clang_cxx") +endif() + +set(LIBS -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive) + +add_clang_library(libclang_cxx ${ENABLE_SHARED} ${ENABLE_STATIC} + OUTPUT_NAME ${output_name} + + LINK_LIBS + ${LIBS} + ) + +if(ENABLE_SHARED) + if(WIN32) + set_target_properties(libclang_cxx + PROPERTIES + VERSION ${LIBCLANG_LIBRARY_VERSION} + DEFINE_SYMBOL _CINDEX_LIB_) + elseif(APPLE) + set(LIBCLANG_CXX_LINK_FLAGS " -Wl,-compatibility_version -Wl,1") + set(LIBCLANG_CXX_LINK_FLAGS "${LIBCLANG_CXX_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}") + + set_property(TARGET libclang_cxx APPEND_STRING PROPERTY + LINK_FLAGS ${LIBCLANG_CXX_LINK_FLAGS}) + else() + set_target_properties(libclang_cxx + PROPERTIES + VERSION ${LIBCLANG_LIBRARY_VERSION} + DEFINE_SYMBOL _CINDEX_LIB_) + # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32. + if(LLVM_ENABLE_MODULES AND NOT WIN32) + target_compile_options(libclang_cxx PRIVATE + "-fmodules-ignore-macro=_CINDEX_LIB_" + ) + endif() + endif() +endif()