summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <volker.krause@kdab.com>2019-06-04 10:28:29 +0200
committerVolker Krause <volker.krause@kdab.com>2019-06-04 10:28:29 +0200
commitc737beb3b0f1e8987c434df171c13aaf9f969f2d (patch)
tree159874302d259e9526b534fba6b1e33aafb30611
parentfa028933f95c4c01987a995ad81ab2fe383240e7 (diff)
downloadqttools-c737beb3b0f1e8987c434df171c13aaf9f969f2d.tar.gz
Add CMake target for qtattributionsscanner
Less useful for external users compared to qdoc, but neeeded for CMake builds of e.g. QtCreator and GammaRay. Change-Id: I8861cf30a21102309fef5b7bf3baf2707abf2965 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
-rw-r--r--src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in56
-rw-r--r--src/qtattributionsscanner/qtattributionsscanner.pro35
2 files changed, 91 insertions, 0 deletions
diff --git a/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in b/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in
new file mode 100644
index 000000000..9e9381c24
--- /dev/null
+++ b/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in
@@ -0,0 +1,56 @@
+if (CMAKE_VERSION VERSION_LESS 2.8.3)
+ message(FATAL_ERROR \"Qt 5 requires at least CMake version 2.8.3\")
+endif()
+
+!!IF !isEmpty(CMAKE_USR_MOVE_WORKAROUND)
+!!IF !isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+set(_qt5_qattributionsscannertools_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+!!ELSE
+get_filename_component(_IMPORT_PREFIX \"${CMAKE_CURRENT_LIST_FILE}\" PATH)
+# Use original install prefix when loaded through a
+# cross-prefix symbolic link such as /lib -> /usr/lib.
+get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)
+get_filename_component(_realOrig \"$$CMAKE_INSTALL_LIBS_DIR/cmake/Qt5AttributionsScannerTools\" REALPATH)
+if(_realCurr STREQUAL _realOrig)
+ get_filename_component(_qt5_qattributionsscannertools_install_prefix \"$$CMAKE_INSTALL_LIBS_DIR/$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}\" ABSOLUTE)
+else()
+ get_filename_component(_qt5_qattributionsscannertools_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+endif()
+unset(_realOrig)
+unset(_realCurr)
+unset(_IMPORT_PREFIX)
+!!ENDIF
+!!ELIF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE)
+get_filename_component(_qt5_qattributionsscannertools_install_prefix \"${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR}\" ABSOLUTE)
+!!ELSE
+set(_qt5_qattributionsscannertools_install_prefix \"$$[QT_INSTALL_PREFIX]\")
+!!ENDIF
+
+macro(_qt5_AttributionsScannerTools_check_file_exists file)
+ if(NOT EXISTS \"${file}\" )
+ message(FATAL_ERROR \"The package \\\"Qt5AttributionsScannerTools\\\" references the file
+ \\\"${file}\\\"
+but this file does not exist. Possible reasons include:
+* The file was deleted, renamed, or moved to another location.
+* An install or uninstall procedure did not complete successfully.
+* The installation package was faulty and contained
+ \\\"${CMAKE_CURRENT_LIST_FILE}\\\"
+but not all the files it references.
+\")
+ endif()
+endmacro()
+
+if (NOT TARGET Qt5::qtattributionsscanner)
+ add_executable(Qt5::qtattributionsscanner IMPORTED)
+
+!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE)
+ set(imported_location \"${_qt5_qattributionsscannertools_install_prefix}/$${CMAKE_BIN_DIR}qtattributionsscanner$$CMAKE_BIN_SUFFIX\")
+!!ELSE
+ set(imported_location \"$${CMAKE_BIN_DIR}qtattributionsscanner$$CMAKE_BIN_SUFFIX\")
+!!ENDIF
+ _qt5_AttributionsScannerTools_check_file_exists(${imported_location})
+
+ set_target_properties(Qt5::qtattributionsscanner PROPERTIES
+ IMPORTED_LOCATION ${imported_location}
+ )
+endif()
diff --git a/src/qtattributionsscanner/qtattributionsscanner.pro b/src/qtattributionsscanner/qtattributionsscanner.pro
index c3c57b35d..839af9b08 100644
--- a/src/qtattributionsscanner/qtattributionsscanner.pro
+++ b/src/qtattributionsscanner/qtattributionsscanner.pro
@@ -20,3 +20,38 @@ DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
QMAKE_TARGET_DESCRIPTION = "Qt Source Code Attribution Scanner"
load(qt_tool)
+
+load(cmake_functions)
+
+CMAKE_INSTALL_LIBS_DIR = $$cmakeTargetPath($$[QT_INSTALL_LIBS])
+contains(CMAKE_INSTALL_LIBS_DIR, ^(/usr)?/lib(64)?.*): CMAKE_USR_MOVE_WORKAROUND = $$CMAKE_INSTALL_LIBS_DIR
+
+CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
+!contains(CMAKE_LIB_DIR,"^\\.\\./.*") {
+ CMAKE_RELATIVE_INSTALL_LIBS_DIR = $$cmakeRelativePath($$[QT_INSTALL_PREFIX], $$[QT_INSTALL_LIBS])
+ # We need to go up another two levels because the CMake files are
+ # installed in $${CMAKE_LIB_DIR}/cmake/Qt5$${CMAKE_MODULE_NAME}
+ CMAKE_RELATIVE_INSTALL_DIR = "$${CMAKE_RELATIVE_INSTALL_LIBS_DIR}../../"
+} else {
+ CMAKE_LIB_DIR_IS_ABSOLUTE = True
+}
+
+CMAKE_BIN_DIR = $$cmakeRelativePath($$[QT_HOST_BINS], $$[QT_INSTALL_PREFIX])
+contains(CMAKE_BIN_DIR, "^\\.\\./.*") {
+ CMAKE_BIN_DIR = $$[QT_HOST_BINS]/
+ CMAKE_BIN_DIR_IS_ABSOLUTE = True
+}
+
+load(qt_build_paths)
+
+cmake_qattributionsscanner_config_file.input = $$PWD/Qt5AttributionsScannerTools.cmake.in
+cmake_qattributionsscanner_config_version_file.input = $$[QT_HOST_DATA/src]/mkspecs/features/data/cmake/Qt5ConfigVersion.cmake.in
+CMAKE_PACKAGE_VERSION = $$MODULE_VERSION
+cmake_qattributionsscanner_config_file.output = $$MODULE_BASE_OUTDIR/lib/cmake/Qt5AttributionsScannerTools/Qt5AttributionsScannerToolsConfig.cmake
+cmake_qattributionsscanner_config_version_file.output = $$MODULE_BASE_OUTDIR/lib/cmake/Qt5AttributionsScannerTools/Qt5AttributionsScannerToolsConfigVersion.cmake
+QMAKE_SUBSTITUTES += cmake_qattributionsscanner_config_file cmake_qattributionsscanner_config_version_file
+
+cmake_qattributionsscanner_tools_files.files += $$cmake_qattributionsscanner_config_file.output $$cmake_qattributionsscanner_config_version_file.output
+cmake_qattributionsscanner_tools_files.path = $$[QT_INSTALL_LIBS]/cmake/Qt5AttributionsScannerTools
+cmake_qattributionsscanner_tools_files.CONFIG = no_check_exist
+INSTALLS += cmake_qattributionsscanner_tools_files