summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-12-14 15:53:15 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-01 16:53:36 +0000
commit8eb24153fd07a6e233fb3828f306f4285e126dd0 (patch)
tree9c8e87d82838922e66d23822bf00fcb805ef0acf /cmake
parent708e2ed8b3215a47dc4c2f96617e6ca10be7cdfd (diff)
CMake: Shorten ExternalProject example project paths
Instead of nesting the external project build dir under the current binary dir, place the EP build dir where it would usually be when we use add_subdirectory. Shorten the name of the external project to just ${subdir} instead of using the relative current binary dir path. Place the EP prefix and stamp dirs under a new ${subdir}-ep folder next to the example build dir. Overall this places example executables where you'd usually expect them to be, as well as shortens a bunch of build paths to circumvent path limit issues when building on Windows. Fixes: QTBUG-94608 Task-number: QTBUG-96232 Change-Id: Ifb921c5a6397385e8a914111bf56ee59cda003fd Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 1a103beff61542c5149c3876a7bb0885ec989c0a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake18
1 files changed, 15 insertions, 3 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index a10296d45b..112d55a7f7 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -833,9 +833,18 @@ function(qt_internal_add_example subdir)
cmake_parse_arguments(PARSE_ARGV 1 arg "${options}" "${singleOpts}" "${multiOpts}")
+ file(RELATIVE_PATH example_rel_path
+ "${QT_EXAMPLE_BASE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}")
+
if(NOT arg_NAME)
- file(RELATIVE_PATH rel_path ${QT_EXAMPLE_BASE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
- string(REPLACE "/" "_" arg_NAME "${rel_path}")
+ set(arg_NAME "${subdir}")
+ endif()
+
+ # Likely a clash with an example subdir ExternalProject custom target of the same name.
+ if(TARGET "${arg_NAME}")
+ string(SHA1 rel_path_hash "${example_rel_path}")
+ string(SUBSTRING "${rel_path_hash}" 0 4 short_hash)
+ set(arg_NAME "${arg_NAME}-${short_hash}")
endif()
if(QtBase_BINARY_DIR)
@@ -945,7 +954,10 @@ function(qt_internal_add_example subdir)
ExternalProject_Add(${arg_NAME}
EXCLUDE_FROM_ALL TRUE
- SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}
+ SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}"
+ PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${subdir}-ep"
+ STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/${subdir}-ep/stamp"
+ BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${subdir}"
INSTALL_COMMAND ""
TEST_COMMAND ""
DEPENDS ${deps}