-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build with Clang 12 and install the native lib #244
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,12 +18,6 @@ set(SOURCES | |
CXType.h | ||
) | ||
|
||
set(LIBS | ||
clangAST | ||
clangFrontend | ||
libclang | ||
) | ||
|
||
set(LLVM_SEARCH_PATHS | ||
${PATH_TO_LLVM} | ||
${PATH_TO_LLVM}/lib/cmake | ||
|
@@ -37,12 +31,25 @@ find_package(Clang REQUIRED CONFIG | |
PATHS ${LLVM_SEARCH_PATHS} | ||
NO_DEFAULT_PATH) | ||
|
||
if(WIN32) | ||
add_library(libClangSharp SHARED ${SOURCES}) | ||
target_include_directories(libClangSharp PUBLIC ${LLVM_INCLUDE_DIRS}) | ||
target_link_libraries(libClangSharp ${LIBS}) | ||
add_library(ClangSharp SHARED ${SOURCES}) | ||
|
||
if (TARGET clang-cpp) # Linux packages install libclang and clang-cpp | ||
target_link_libraries(ClangSharp PRIVATE clang-cpp libclang) | ||
else() | ||
add_library(ClangSharp SHARED ${SOURCES}) | ||
target_include_directories(ClangSharp PUBLIC ${LLVM_INCLUDE_DIRS}) | ||
target_link_libraries(ClangSharp ${LIBS}) | ||
target_link_libraries(ClangSharp PRIVATE clangAST clangFrontend libclang) | ||
endif() | ||
|
||
target_include_directories(ClangSharp PRIVATE ${CLANG_INCLUDE_DIRS}) | ||
set_target_properties(ClangSharp PROPERTIES | ||
PREFIX lib | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION} | ||
) | ||
|
||
include(GNUInstallDirs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the behavior of this on Windows and is it going to do the "right" thing where Windows considers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Windows _BINDIR is "bin", _LIBDIR is "lib", .dll files are |
||
|
||
install(TARGETS ClangSharp | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide more details about how you built such that you didn't have
clangAST
orclangFrontend
?These exist in both the official release binaries (https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0, see `lib/libclangAST.a and friends) and in the binaries produced if built locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CMake was also used to succesfully build libClangSharp for 12.0.0 on all supported platforms, so things were resolving correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sys-devel/clang version 12.0.0 from the Gentoo main tree. Neither it nor the clang package from Arch provide those libraries. You can view the file list for the Arch package here.
The clang package here installs no static (.a) archives at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gentoo configure
Arch build script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like its going to break windows as there is no
clang-cpp
produced.I'm fine with taking it for Unix given it looks like the official binaries do create and ship
clang-cpp
by default.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated adding library check.