diff options
author | Cristian Adam <cristian.adam@qt.io> | 2021-09-15 15:34:01 +0200 |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2021-09-15 14:26:27 +0000 |
commit | 3f0a54d41c5c8eec71d0551df7bd090955988deb (patch) | |
tree | 80e5aafd4fb6e8b477f2ff4e6ee1631ee6dc39bb /cmake | |
parent | 844cfe70b7eea4508e9b33dad19e5f113ae52a5b (diff) |
CMake: Add option to link with Qt
The named option is BUILD_LINK_WITH_QT, which when set to ON will
generate the QtCreator.ini file needed for Qt Creator to find the
installed Qt.
Change-Id: If3a47a463510fbfc90a314829378c6c4e505d2f7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtCreatorAPIInternal.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmake/QtCreatorAPIInternal.cmake b/cmake/QtCreatorAPIInternal.cmake index 7ebd2d31d7..026647f56d 100644 --- a/cmake/QtCreatorAPIInternal.cmake +++ b/cmake/QtCreatorAPIInternal.cmake @@ -125,6 +125,24 @@ function(qtc_handle_sccache_support) endif() endfunction() +function(qtc_link_with_qt) + # When building with Qt Creator 4.15+ do the "Link with Qt..." automatically + if (BUILD_LINK_WITH_QT AND DEFINED CMAKE_PROJECT_INCLUDE_BEFORE) + get_filename_component(auto_setup_dir "${CMAKE_PROJECT_INCLUDE_BEFORE}" DIRECTORY) + set(qt_creator_ini "${auto_setup_dir}/../QtProject/QtCreator.ini") + if (EXISTS "${qt_creator_ini}") + file(STRINGS "${qt_creator_ini}" install_settings REGEX "^InstallSettings=.*$") + if (install_settings) + string(REPLACE "InstallSettings=" "" install_settings "${install_settings}") + else() + file(TO_CMAKE_PATH "${auto_setup_dir}/.." install_settings) + endif() + file(WRITE ${CMAKE_BINARY_DIR}/${_IDE_DATA_PATH}/QtProject/QtCreator.ini + "[Settings]\nInstallSettings=${install_settings}") + endif() + endif() +endfunction() + function(qtc_enable_release_for_debug_configuration) if (MSVC) string(REPLACE "/Od" "/O2" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") |