summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-06-23 13:17:06 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-06-29 12:20:12 +0200
commit896cdd0e28a8dc4e03bb287fea5c71519297886e (patch)
tree88beb22d4819ae58780297f5e1f546513ad40c03
parentb31764887505df43d62013db2cb903b5c537a0bf (diff)
downloadqttools-896cdd0e28a8dc4e03bb287fea5c71519297886e.tar.gz
CMake: Fix configure.cmake usage for libclang
Now that the qmake situation of the configure.json files in regards to libclang is fixed, we need to adjust the CMake files to do the same. Remove the old stale configure.cmake files, create the top-level configure.cmake file, evaluate its features in src dir, and make sure to also create the forwarding headers in the global QtTools module as well. Change FindWrapLibClang to accept a version number, and modify configure.cmake to pass the minimum version to be "8". While libclang 6.x is enough to build Qt with qmake, for some reason CMake needs at least 8.x. Explicitly specifying the minimum version will prevent an old libclang library to be found in Coin, and thus breaking integrations during compilation. Once Coin is updated to include latest libclang, qdoc and lupdate will be built as usual. Change-Id: Iab8ec25d256358005850f25d6395d81e0068edfe Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r--cmake/FindWrapLibClang.cmake49
-rw-r--r--configure.cmake135
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/global/.prev_CMakeLists.txt13
-rw-r--r--src/global/CMakeLists.txt3
-rw-r--r--src/global/configure.cmake31
-rw-r--r--src/qdoc/configure.cmake27
7 files changed, 190 insertions, 74 deletions
diff --git a/cmake/FindWrapLibClang.cmake b/cmake/FindWrapLibClang.cmake
index df6c011f5..30be70b66 100644
--- a/cmake/FindWrapLibClang.cmake
+++ b/cmake/FindWrapLibClang.cmake
@@ -5,30 +5,47 @@ endif()
find_package(Clang CONFIG)
-if(TARGET libclang AND TARGET clangHandleCXX)
+set(WrapLibClang_FOUND FALSE)
+set(__wrap_lib_clang_requested_version_found FALSE)
+
+# Need to explicitly handle the version check, because the Clang package doesn't.
+if(WrapLibClang_FIND_VERSION AND LLVM_PACKAGE_VERSION
+ AND LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL "${WrapLibClang_FIND_VERSION}")
+ set(__wrap_lib_clang_requested_version_found TRUE)
+endif()
+
+if(TARGET libclang AND TARGET clangHandleCXX AND __wrap_lib_clang_requested_version_found)
+ set(WrapLibClang_FOUND TRUE)
+
get_target_property(type libclang TYPE)
if (MSVC AND type STREQUAL "STATIC_LIBRARY")
if (NOT CMAKE_BUILD_TYPE MATCHES "(Release|MinSizeRel|RelWithDebInfo)")
message(STATUS "Static linkage against libclang with MSVC was requested, but the build is not a release build, therefore libclang cannot be used.")
set(WrapLibClang_FOUND FALSE)
- return()
endif()
endif()
- add_library(WrapLibClang::WrapLibClang IMPORTED INTERFACE)
+ if(WrapLibClang_FOUND)
+ add_library(WrapLibClang::WrapLibClang IMPORTED INTERFACE)
- target_include_directories(WrapLibClang::WrapLibClang INTERFACE ${CLANG_INCLUDE_DIRS})
- if (NOT TARGET Threads::Threads)
- find_package(Threads)
- endif()
- target_link_libraries(WrapLibClang::WrapLibClang INTERFACE libclang clangHandleCXX Threads::Threads)
-
- foreach(version MAJOR MINOR PATCH)
- set(QT_LIB_CLANG_VERSION_${version} ${LLVM_VERSION_${version}} CACHE STRING "" FORCE)
- endforeach()
- set(QT_LIB_CLANG_VERSION ${LLVM_PACKAGE_VERSION} CACHE STRING "" FORCE)
- set(QT_LIB_CLANG_LIBDIR "${LLVM_LIBRARY_DIRS}" CACHE STRING "" FORCE)
- set(QT_LIBCLANG_RESOURCE_DIR "\"${QT_LIB_CLANG_LIBDIR}/clang/${QT_LIB_CLANG_VERSION}/include\"" CACHE STRING "" FORCE)
+ target_include_directories(WrapLibClang::WrapLibClang INTERFACE ${CLANG_INCLUDE_DIRS})
+ if (NOT TARGET Threads::Threads)
+ find_package(Threads)
+ endif()
+ target_link_libraries(WrapLibClang::WrapLibClang
+ INTERFACE libclang clangHandleCXX Threads::Threads)
- set(WrapLibClang_FOUND TRUE)
+ foreach(version MAJOR MINOR PATCH)
+ set(QT_LIB_CLANG_VERSION_${version} ${LLVM_VERSION_${version}} CACHE STRING "" FORCE)
+ endforeach()
+ set(QT_LIB_CLANG_VERSION ${LLVM_PACKAGE_VERSION} CACHE STRING "" FORCE)
+ set(QT_LIB_CLANG_LIBDIR "${LLVM_LIBRARY_DIRS}" CACHE STRING "" FORCE)
+ set(QT_LIBCLANG_RESOURCE_DIR
+ "\"${QT_LIB_CLANG_LIBDIR}/clang/${QT_LIB_CLANG_VERSION}/include\"" CACHE STRING "" FORCE)
+ endif()
endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WrapLibClang
+ REQUIRED_VARS WrapLibClang_FOUND
+ VERSION_VAR LLVM_PACKAGE_VERSION)
diff --git a/configure.cmake b/configure.cmake
new file mode 100644
index 000000000..7b48332f6
--- /dev/null
+++ b/configure.cmake
@@ -0,0 +1,135 @@
+
+
+#### Inputs
+
+
+
+#### Libraries
+
+
+
+#### Tests
+
+# libclang
+# special case begin
+# Even though Qt builds with qmake and libclang 6.0, it fails with CMake.
+# Presumably because 6.0 ClangConfig.cmake files are not good enough?
+# In any case explicitly request a minimum version of 8.x for now, otherwise
+# building with CMake will fail at compilation time.
+# special case end
+qt_find_package(WrapLibClang 8 PROVIDED_TARGETS WrapLibClang::WrapLibClang) # special case
+
+if(TARGET WrapLibClang::WrapLibClang)
+ set(TEST_libclang "ON" CACHE BOOL "Required libclang version found." FORCE)
+endif()
+
+
+
+#### Features
+
+qt_feature("assistant" PRIVATE
+ LABEL "Qt Assistant"
+ PURPOSE "Qt Assistant is a tool for viewing on-line documentation in Qt help file format."
+)
+qt_feature("clang" PRIVATE
+ LABEL "QDoc"
+ CONDITION TEST_libclang
+)
+qt_feature("clangcpp" PRIVATE
+ LABEL "Clang-based lupdate parser"
+ CONDITION QT_FEATURE_clang AND TEST_libclang
+)
+qt_feature("designer" PRIVATE
+ LABEL "Qt Designer"
+ PURPOSE "Qt Designer is the Qt tool for designing and building graphical user interfaces (GUIs) with Qt Widgets. You can compose and customize your windows or dialogs in a what-you-see-is-what-you-get (WYSIWYG) manner, and test them using different styles and resolutions."
+)
+qt_feature("distancefieldgenerator" PRIVATE
+ LABEL "Qt Distance Field Generator"
+ PURPOSE "The Qt Distance Field Generator tool can be used to pregenerate the font cache in order to optimize startup performance."
+)
+qt_feature("kmap2qmap" PRIVATE
+ LABEL "kmap2qmap"
+ PURPOSE "kmap2qmap is a tool to generate keymaps for use on Embedded Linux. The source files have to be in standard Linux kmap format that is e.g. understood by the kernel's loadkeys command."
+)
+qt_feature("linguist" PRIVATE
+ LABEL "Qt Linguist"
+ PURPOSE "Qt Linguist can be used by translator to translate text in Qt applications."
+)
+qt_feature("macdeployqt" PRIVATE
+ LABEL "Mac Deployment Tool"
+ PURPOSE "The Mac deployment tool automates the process of creating a deployable application bundle that contains the Qt libraries as private frameworks."
+ CONDITION APPLE
+)
+qt_feature("makeqpf" PRIVATE
+ LABEL "makeqpf"
+ PURPOSE "makeqpf is a tool to generate pre-rendered fonts in QPF2 format for use on Embedded Linux."
+)
+qt_feature("pixeltool" PRIVATE
+ LABEL "pixeltool"
+ PURPOSE "The Qt Pixel Zooming Tool is a graphical application that magnifies the screen around the mouse pointer so you can look more closely at individual pixels."
+)
+qt_feature("qdbus" PRIVATE
+ LABEL "qdbus"
+ PURPOSE "qdbus is a communication interface for Qt-based applications."
+)
+qt_feature("qev" PRIVATE
+ LABEL "qev"
+ PURPOSE "qev allows introspection of incoming events for a QWidget, similar to the X11 xev tool."
+)
+qt_feature("qtattributionsscanner" PRIVATE
+ LABEL "Qt Attributions Scanner"
+ PURPOSE "Qt Attributions Scanner generates attribution documents for third-party code in Qt."
+)
+qt_feature("qtdiag" PRIVATE
+ LABEL "qtdiag"
+ PURPOSE "qtdiag outputs information about the Qt installation it was built with."
+)
+qt_feature("qtpaths" PRIVATE
+ LABEL "qtpaths"
+ PURPOSE "qtpaths is a command line client to QStandardPaths."
+)
+qt_feature("qtplugininfo" PRIVATE
+ LABEL "qtplugininfo"
+ PURPOSE "qtplugininfo dumps metadata about Qt plugins in JSON format."
+)
+qt_feature("windeployqt" PRIVATE
+ LABEL "Windows deployment tool"
+ PURPOSE "The Windows deployment tool is designed to automate the process of creating a deployable folder containing the Qt-related dependencies (libraries, QML imports, plugins, and translations) required to run the application from that folder. It creates a sandbox for Universal Windows Platform (UWP) or an installation tree for Windows desktop applications, which can be easily bundled into an installation package."
+ CONDITION WIN32 OR WINRT
+)
+qt_feature("winrtrunner" PRIVATE
+ LABEL "WinRT Runner Tool"
+ PURPOSE "The WinRT Runner Tool installs, runs, and collects test results for packages made with Qt."
+ CONDITION WINRT
+)
+qt_configure_add_summary_section(NAME "Qt Tools")
+qt_configure_add_summary_entry(ARGS "assistant")
+qt_configure_add_summary_entry(ARGS "clang")
+qt_configure_add_summary_entry(ARGS "clangcpp")
+qt_configure_add_summary_entry(ARGS "designer")
+qt_configure_add_summary_entry(ARGS "distancefieldgenerator")
+qt_configure_add_summary_entry(ARGS "kmap2qmap")
+qt_configure_add_summary_entry(ARGS "linguist")
+qt_configure_add_summary_entry(ARGS "macdeployqt")
+qt_configure_add_summary_entry(ARGS "makeqpf")
+qt_configure_add_summary_entry(ARGS "pixeltool")
+qt_configure_add_summary_entry(ARGS "qdbus")
+qt_configure_add_summary_entry(ARGS "qev")
+qt_configure_add_summary_entry(ARGS "qtattributionsscanner")
+qt_configure_add_summary_entry(ARGS "qtdiag")
+qt_configure_add_summary_entry(ARGS "qtpaths")
+qt_configure_add_summary_entry(ARGS "qtplugininfo")
+qt_configure_add_summary_entry(ARGS "windeployqt")
+qt_configure_add_summary_entry(ARGS "winrtrunner")
+qt_configure_end_summary_section() # end of "Qt Tools" section
+qt_configure_add_report_entry(
+ TYPE WARNING
+ MESSAGE "QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
+ Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation. On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution. On macOS, you can use Homebrew's llvm package. On Windows, you must set LLVM_INSTALL_DIR to the installation path."
+ CONDITION NOT QT_FEATURE_clang
+)
+qt_configure_add_report_entry(
+ TYPE WARNING
+ MESSAGE "Clang-based lupdate parser will not be available. LLVM and Clang C++ libraries have not been found."
+ CONDITION NOT QT_FEATURE_clangcpp
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2cc9dff84..3ac2dd38c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -14,6 +14,12 @@ qt_exclude_tool_directories_from_default_target(
${_qt_additional_tools_to_exclude} # special case
)
+# special case begin
+# Evaluate features to decide what to build.
+# The config files will be written in the src/global module.
+qt_feature_evaluate_features("${CMAKE_CURRENT_SOURCE_DIR}/../configure.cmake")
+# special case end
+
add_subdirectory(global) # special case add as first directory
add_subdirectory(linguist)
# add_subdirectory(global) # special case remove
diff --git a/src/global/.prev_CMakeLists.txt b/src/global/.prev_CMakeLists.txt
new file mode 100644
index 000000000..d97f5a202
--- /dev/null
+++ b/src/global/.prev_CMakeLists.txt
@@ -0,0 +1,13 @@
+# Generated from global.pro.
+
+#####################################################################
+## Tools Module:
+#####################################################################
+
+qt_add_module(Tools
+ INTERNAL_MODULE
+ HEADER_MODULE
+)
+
+#### Keys ignored in scope 1:.:.:global.pro:<TRUE>:
+# MODULE = "tools"
diff --git a/src/global/CMakeLists.txt b/src/global/CMakeLists.txt
index d97f5a202..961b35699 100644
--- a/src/global/CMakeLists.txt
+++ b/src/global/CMakeLists.txt
@@ -7,6 +7,9 @@
qt_add_module(Tools
INTERNAL_MODULE
HEADER_MODULE
+ # special case begin
+ CONFIGURE_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../configure.cmake"
+ # special case end
)
#### Keys ignored in scope 1:.:.:global.pro:<TRUE>:
diff --git a/src/global/configure.cmake b/src/global/configure.cmake
deleted file mode 100644
index 9f03fd463..000000000
--- a/src/global/configure.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-#### Inputs
-
-
-
-#### Libraries
-
-
-
-#### Tests
-
-# libclang
-qt_find_package(WrapLibClang PROVIDED_TARGETS WrapLibClang::WrapLibClang)
-
-if(TARGET WrapLibClang::WrapLibClang)
- set(TEST_libclang "ON" CACHE BOOL "Required libclang version found." FORCE)
-endif()
-
-
-
-#### Features
-
-qt_feature("clang" PRIVATE
- LABEL "QDoc"
- CONDITION TEST_libclang
-)
-qt_feature("clangcpp" PRIVATE
- LABEL "Clang-based lupdate parser"
- CONDITION QT_FEATURE_clang AND TEST_libclang
-)
diff --git a/src/qdoc/configure.cmake b/src/qdoc/configure.cmake
deleted file mode 100644
index b358b7ece..000000000
--- a/src/qdoc/configure.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-#### Inputs
-
-
-
-#### Libraries
-
-
-
-#### Tests
-
-# libclang
-qt_find_package(WrapLibClang PROVIDED_TARGETS WrapLibClang::WrapLibClang)
-
-if(TARGET WrapLibClang::WrapLibClang)
- set(TEST_libclang "ON" CACHE BOOL "Required libclang version found." FORCE)
-endif()
-
-
-
-#### Features
-
-qt_feature("qdoc" PRIVATE
- LABEL "QDoc"
- CONDITION TEST_libclang
-)