зеркало из https://github.com/microsoft/clang-1.git
Build libclang as a static library too. Now tested on Windows!
On Windows only the shared library is created. The reason for this is that clang.lib the static library would clash with clang.lib the export library of the dll. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d9e9b8f195
Коммит
0b34dbaafe
|
@ -1,5 +1,3 @@
|
|||
set(SHARED_LIBRARY TRUE)
|
||||
|
||||
set(LLVM_USED_LIBS
|
||||
clangFrontend
|
||||
clangDriver
|
||||
|
@ -15,7 +13,7 @@ set( LLVM_LINK_COMPONENTS
|
|||
mc
|
||||
)
|
||||
|
||||
add_clang_library(libclang
|
||||
set(SOURCES
|
||||
CIndex.cpp
|
||||
CIndexCXX.cpp
|
||||
CIndexCodeCompletion.cpp
|
||||
|
@ -27,34 +25,44 @@ add_clang_library(libclang
|
|||
CXString.cpp
|
||||
CXType.cpp
|
||||
../../include/clang-c/Index.h
|
||||
)
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
# Darwin-specific linker flags
|
||||
|
||||
set(LIBCLANG_LINK_FLAGS "-Wl,-compatibility_version -Wl,1")
|
||||
|
||||
set(LIBCLANG_LINK_FLAGS
|
||||
"${LIBCLANG_LINK_FLAGS} -Wl,-dead_strip -Wl,-seg1addr -Wl,0xE0000000")
|
||||
if( LLVM_ENABLE_PIC )
|
||||
set(SHARED_LIBRARY TRUE)
|
||||
add_clang_library(libclang ${SOURCES})
|
||||
|
||||
set_target_properties(libclang
|
||||
PROPERTIES
|
||||
LINK_FLAGS "${LIBCLANG_LINK_FLAGS}"
|
||||
INSTALL_NAME_DIR "@executable_path/../lib")
|
||||
OUTPUT_NAME "clang"
|
||||
VERSION ${LIBCLANG_LIBRARY_VERSION}
|
||||
DEFINE_SYMBOL _CINDEX_LIB_)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(LIBCLANG_LINK_FLAGS "-Wl,-compatibility_version -Wl,1"
|
||||
" -Wl,-dead_strip -Wl,-seg1addr -Wl,0xE0000000")
|
||||
set_target_properties(libclang
|
||||
PROPERTIES
|
||||
LINK_FLAGS "${LIBCLANG_LINK_FLAGS}"
|
||||
INSTALL_NAME_DIR "@executable_path/../lib")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# windows.h doesn't compile with /Za
|
||||
get_target_property(NON_ANSI_COMPILE_FLAGS libclang COMPILE_FLAGS)
|
||||
string(REPLACE "/Za" "" NON_ANSI_COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
|
||||
set_target_properties(libclang PROPERTIES
|
||||
COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
|
||||
endif()
|
||||
|
||||
set(LIBCLANG_STATIC_TARGET_NAME libclang_static)
|
||||
else()
|
||||
set(LIBCLANG_STATIC_TARGET_NAME libclang)
|
||||
endif()
|
||||
|
||||
# Versioning information
|
||||
set_target_properties(libclang PROPERTIES VERSION ${LIBCLANG_LIBRARY_VERSION})
|
||||
if( NOT BUILD_SHARED_LIBS AND NOT WIN32 )
|
||||
add_clang_library(${LIBCLANG_STATIC_TARGET_NAME} STATIC ${SOURCES})
|
||||
|
||||
if(MSVC)
|
||||
# windows.h doesn't compile with /Za
|
||||
get_target_property(NON_ANSI_COMPILE_FLAGS libclang COMPILE_FLAGS)
|
||||
string(REPLACE /Za "" NON_ANSI_COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
|
||||
set_target_properties(libclang PROPERTIES COMPILE_FLAGS ${NON_ANSI_COMPILE_FLAGS})
|
||||
endif(MSVC)
|
||||
|
||||
set_target_properties(libclang
|
||||
PROPERTIES
|
||||
PREFIX "" # Otherwise we get liblibclang.so
|
||||
LINKER_LANGUAGE CXX
|
||||
DEFINE_SYMBOL _CINDEX_LIB_)
|
||||
set_target_properties(${LIBCLANG_STATIC_TARGET_NAME}
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "clang")
|
||||
endif()
|
||||
|
|
Загрузка…
Ссылка в новой задаче