forked from qt-creator/qt-creator
CMake build: Support building clang tooling without static libs
Create a FindClang.cmake and move all Clang configuration there. Find Clang and choose static libraries if available, otherwise use clang-cpp if available. Add option to link to clang-cpp even if static libraries are available. Fixes: QTCREATORBUG-23172 Change-Id: If40304d174469df0c786259e724cbee8de0e2d0e Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -43,12 +43,11 @@ find_package(Qt5
|
|||||||
QuickWidgets Sql Widgets Xml ${QT_TEST_COMPONENT}
|
QuickWidgets Sql Widgets Xml ${QT_TEST_COMPONENT}
|
||||||
REQUIRED
|
REQUIRED
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS LinguistTools)
|
find_package(Qt5 COMPONENTS LinguistTools)
|
||||||
|
find_package(Qt5 COMPONENTS Designer DesignerComponents Help SerialPort Svg QUIET)
|
||||||
|
|
||||||
find_package(Threads)
|
find_package(Threads)
|
||||||
|
find_package(Clang QUIET)
|
||||||
find_package(Qt5 COMPONENTS Designer DesignerComponents Help SerialPort Svg QUIET)
|
|
||||||
|
|
||||||
function (set_if_target var target)
|
function (set_if_target var target)
|
||||||
if (TARGET "${target}")
|
if (TARGET "${target}")
|
||||||
@@ -75,15 +74,6 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
install(TARGETS OptionalSvg EXPORT QtCreator)
|
install(TARGETS OptionalSvg EXPORT QtCreator)
|
||||||
|
|
||||||
find_package(Clang COMPONENTS libclang QUIET)
|
|
||||||
# silence a lot of warnings from building against llvm
|
|
||||||
# this would better fit inside a central libclang detection/include cmake file, but since we do not
|
|
||||||
# have one put it temporary here
|
|
||||||
if(MSVC AND TARGET libclang)
|
|
||||||
target_compile_options(libclang INTERFACE /wd4100 /wd4141 /wd4146 /wd4244 /wd4267 /wd4291)
|
|
||||||
endif()
|
|
||||||
find_package(LLVM QUIET)
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
find_library(FWCoreFoundation CoreFoundation)
|
find_library(FWCoreFoundation CoreFoundation)
|
||||||
find_library(FWCoreServices CoreServices)
|
find_library(FWCoreServices CoreServices)
|
||||||
|
14
cmake/FindClang.cmake
Normal file
14
cmake/FindClang.cmake
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
find_package(Clang CONFIG)
|
||||||
|
|
||||||
|
# silence a lot of warnings from building against llvm
|
||||||
|
if(MSVC AND TARGET libclang)
|
||||||
|
target_compile_options(libclang INTERFACE /wd4100 /wd4141 /wd4146 /wd4244 /wd4267 /wd4291)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(CLANGTOOLING_LINK_CLANG_DYLIB "Force linking of Clang tooling against clang-cpp" NO)
|
||||||
|
|
||||||
|
if (TARGET clangTooling AND NOT CLANGTOOLING_LINK_CLANG_DYLIB)
|
||||||
|
set(CLANG_TOOLING_LIBS libclang clangTooling clangQuery clangIndex)
|
||||||
|
elseif (TARGET clang-cpp)
|
||||||
|
set(CLANG_TOOLING_LIBS libclang clang-cpp)
|
||||||
|
endif()
|
@@ -3,7 +3,8 @@ add_subdirectory(source)
|
|||||||
add_qtc_executable(clangpchmanagerbackend
|
add_qtc_executable(clangpchmanagerbackend
|
||||||
DEPENDS
|
DEPENDS
|
||||||
clangrefactoringbackend_lib clangpchmanagerbackend_lib
|
clangrefactoringbackend_lib clangpchmanagerbackend_lib
|
||||||
clangTooling libclang Sqlite ClangSupport clangQuery clangIndex
|
Sqlite ClangSupport
|
||||||
|
${CLANG_TOOLING_LIBS}
|
||||||
SOURCES
|
SOURCES
|
||||||
clangpchmanagerbackendmain.cpp
|
clangpchmanagerbackendmain.cpp
|
||||||
)
|
)
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
add_qtc_library(clangrefactoringbackend_lib STATIC
|
add_qtc_library(clangrefactoringbackend_lib STATIC
|
||||||
PUBLIC_DEPENDS
|
PUBLIC_DEPENDS
|
||||||
Threads::Threads
|
Threads::Threads
|
||||||
LLVMCore libclang
|
${CLANG_TOOLING_LIBS}
|
||||||
clangAST clangASTMatchers clangBasic clangDynamicASTMatchers clangFrontend
|
|
||||||
clangHandleCXX clangIndex clangLex
|
|
||||||
clangSerialization clangTooling clangQuery
|
|
||||||
ClangSupport
|
ClangSupport
|
||||||
PUBLIC_DEFINES CLANGSUPPORT_BUILD_LIB
|
PUBLIC_DEFINES CLANGSUPPORT_BUILD_LIB
|
||||||
PUBLIC_INCLUDES
|
PUBLIC_INCLUDES
|
||||||
|
Reference in New Issue
Block a user