diff options
21 files changed, 235 insertions, 136 deletions
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 37be3cb..35e3c51 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -146,10 +146,11 @@ available components. ignored on all other ones. Formally, it is up to the target package how to interpret the registry view information given to it. -Specifying the ``GLOBAL`` keyword will promote all imported targets to -a global scope in the importing project. Alternatively this functionality -can be enabled by setting the variable -:variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` +.. versionadded:: 3.24 + Specifying the ``GLOBAL`` keyword will promote all imported targets to + a global scope in the importing project. Alternatively, this functionality + can be enabled by setting the :variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` + variable. .. _FIND_PACKAGE_VERSION_FORMAT: diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 73356d9..c871b1b 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -1449,7 +1449,7 @@ Output-Related Expressions .. versionadded:: 3.24 Manage the grouping of libraries during the link step. - This expression may be used to specify how to kept groups of libraries during + This expression may be used to specify how to keep groups of libraries during the link of a target. For example: diff --git a/Help/release/3.24.rst b/Help/release/3.24.rst index 4bde23f..d0db764 100644 --- a/Help/release/3.24.rst +++ b/Help/release/3.24.rst @@ -28,14 +28,16 @@ Generators * The :generator:`Green Hills MULTI` generator now generates build rules to re-run CMake if any CMake files are updated. -* The :ref:`Visual Studio Generators` now support ``SYSTEM`` headers. +* The :ref:`Visual Studio Generators` now support ``SYSTEM`` headers + when using VS 2019 Update 11 or later. Command-Line ------------ * :manual:`cmake(1)` gained the ``--fresh`` command-line option to remove - any existing ``CMakeCache.txt`` when configuring a build tree, thus - starting a new configuration as if the build tree were freshly created. + any existing ``CMakeCache.txt`` file and associated ``CMakeFiles/`` + directory, when configuring a build tree, thus starting a new configuration + as if the build tree were freshly created. * :manual:`cmake(1)` gained the ``--compile-no-warning-as-error`` command-line option which causes the effects of the :prop_tgt:`COMPILE_WARNING_AS_ERROR` @@ -93,14 +95,14 @@ Commands ``RANGE_END`` to specify a range of bytes to download. This can be useful for downloading parts of big binary files. -* The :command:`find_file`, :command:`find_library`, :command:`find_path`, - :command:`find_package`, and :command:`find_program` commands have gained - the ``NO_CMAKE_INSTALL_PREFIX`` option to control searching +* The :command:`find_file`, :command:`find_path`, :command:`find_library`, + :command:`find_program`, and :command:`find_package` commands gained the + ``NO_CMAKE_INSTALL_PREFIX`` option to control searching :variable:`CMAKE_INSTALL_PREFIX`. * The :command:`find_file`, :command:`find_path`, :command:`find_library`, :command:`find_program`, and :command:`find_package` commands gained the - capability to specify which Windows Registry views must be queried. + ability to specify which Windows Registry views must be queried. * The :command:`find_package` command gained a ``GLOBAL`` option that allows for the promotion of imported targets to global scope for the @@ -117,7 +119,7 @@ Variables color build system messages with :ref:`Makefile Generators`, replacing :variable:`CMAKE_COLOR_MAKEFILE`. - The :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment was added to set + The :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment variable was added to set a default value for :variable:`CMAKE_COLOR_DIAGNOSTICS`. * The :variable:`CMAKE_COMPILE_WARNING_AS_ERROR` variable and corresponding @@ -230,9 +232,9 @@ Generator Expressions * The :genex:`LINK_LIBRARY` generator expression was added to manage how libraries are specified during the link step. - The variables :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` and - :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` are used to define features - usable by the :genex:`LINK_LIBRARY` generator expression. + The :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` and + :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variables are used to define + features usable by the :genex:`LINK_LIBRARY` generator expression. Moreover, the :prop_tgt:`LINK_LIBRARY_OVERRIDE` and :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties are available to resolve incompatible features. @@ -267,14 +269,13 @@ Generator Expressions * ``MSYS`` * The :genex:`LINK_GROUP` generator expression was added to manage the - grouping of libraries during the link step. The variables + grouping of libraries during the link step. The :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>` and - :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>` are used to define - features usable by the :genex:`LINK_GROUP` generator expression. - - The :genex:`LINK_GROUP` generator expression can manage, on ``Linux`` - and ``BSD`` systems, circular references among static libraries - by using the ``RESCAN`` feature. + :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>` variables are used to define + features usable with the :genex:`LINK_GROUP` generator expression. + This release defines the ``RESCAN`` feature, which can be used to handle + circular references among static libraries when using toolchains for + Linux, BSD, SunOS and GNU toolchains for Windows. * The :genex:`PATH` generator expression was added to manage paths. @@ -302,7 +303,7 @@ CPack * CPack now supports the :variable:`CPACK_THREADS` option for ``zstd`` compression when compiled with libarchive 3.6 or higher. It is - supported by official CMake binaries available on ``cmake.org``. + supported by official CMake binaries available on `cmake.org`_. Deprecated and Removed Features =============================== @@ -314,7 +315,7 @@ Deprecated and Removed Features * The deprecated :cpack_gen:`CPack PackageMaker Generator` has been removed. * The :module:`FindGLUT` module no longer provides the undocumented - result variables ``GLUT_LIBRARY`` and ``GLUT_INCLUDE_PATH``. + ``GLUT_LIBRARY`` and ``GLUT_INCLUDE_PATH`` result variables. Other Changes ============= @@ -340,7 +341,8 @@ Other Changes * The :command:`while` command now diagnoses errors during condition evaluation. See policy :policy:`CMP0130`. -* The precompiled macOS binaries provided on - `cmake.org <https://cmake.org/download/>`_ no longer attach a SLA - to the ``.dmg`` packages. This was removed because macOS 12 deprecated +* The precompiled macOS binaries provided on `cmake.org`_ no longer attach a + SLA to the ``.dmg`` packages. This was removed because macOS 12 deprecated the tools used to attach ``.dmg`` resources. + +.. _`cmake.org`: https://cmake.org/download/ diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 0e8b2af..2b19736 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -611,6 +611,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} endif() endif() if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_OSX_SYSROOT MATCHES "^$|[Mm][Aa][Cc][Oo][Ss]") + set(id_code_sign_identity "-") # When targeting macOS, use only the host architecture. if (_CMAKE_APPLE_ARCHS_DEFAULT) set(id_archs "ARCHS = \"${_CMAKE_APPLE_ARCHS_DEFAULT}\";") @@ -620,6 +621,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_arch_active "ONLY_ACTIVE_ARCH = YES;") endif() else() + set(id_code_sign_identity "") set(id_archs "") set(id_arch_active "ONLY_ACTIVE_ARCH = YES;") endif() diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in index aab357a..43e8cc8 100644 --- a/Modules/CompilerId/Xcode-3.pbxproj.in +++ b/Modules/CompilerId/Xcode-3.pbxproj.in @@ -49,6 +49,7 @@ }; 2C8FEB8E15DC1A1A00E56A5D = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -72,7 +73,7 @@ 1DEB928608733DD80010E9CD = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "@id_code_sign_identity@"; PRODUCT_NAME = CompilerId@id_lang@; }; name = Debug; diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 75a161a..d0a90f4 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -195,7 +195,14 @@ Commands Everything after the ``FIND_PACKAGE_ARGS`` keyword is appended to the :command:`find_package` call, so all other ``<contentOptions>`` must - come before the ``FIND_PACKAGE_ARGS`` keyword. + come before the ``FIND_PACKAGE_ARGS`` keyword. If the + :variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` variable is set to true + at the time ``FetchContent_Declare()`` is called, a ``GLOBAL`` keyword + will be appended to the :command:`find_package` arguments if it was + not already specified. It will also be appended if + ``FIND_PACKAGE_ARGS`` was not given, but + :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` was set to ``ALWAYS``. + ``OVERRIDE_FIND_PACKAGE`` cannot be used when ``FIND_PACKAGE_ARGS`` is given. @@ -260,6 +267,11 @@ Commands The value of the :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` variable at the time :command:`FetchContent_Declare` was called determines whether ``FetchContent_MakeAvailable()`` can call :command:`find_package`. + If the :variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` variable is set to + true when ``FetchContent_MakeAvailable()`` is called, it still affects + any imported targets created when that in turn calls + :command:`find_package`, even if that variable was false when the + corresponding details were declared. If the dependency was not satisfied by a provider or a :command:`find_package` call, ``FetchContent_MakeAvailable()`` then uses @@ -1078,10 +1090,17 @@ function(__FetchContent_declareDetails contentName) set(__cmdArgs) set(__findPackageArgs) + set(__sawQuietKeyword NO) + set(__sawGlobalKeyword NO) foreach(__item IN LISTS ARGN) if(DEFINED __findPackageArgs) # All remaining args are for find_package() string(APPEND __findPackageArgs " [==[${__item}]==]") + if(__item STREQUAL "QUIET") + set(__sawQuietKeyword YES) + elseif(__item STREQUAL "GLOBAL") + set(__sawGlobalKeyword YES) + endif() continue() endif() @@ -1120,9 +1139,12 @@ function(__FetchContent_declareDetails contentName) if(__tryFindPackage AND __tryFindPackageAllowed) set(propertyName "_FetchContent_${contentNameLower}_find_package_args") define_property(GLOBAL PROPERTY ${propertyName}) - if(NOT QUIET IN_LIST __findPackageArgs) + if(NOT __sawQuietKeyword) list(INSERT __findPackageArgs 0 QUIET) endif() + if(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL AND NOT __sawGlobalKeyword) + list(APPEND __findPackageArgs GLOBAL) + endif() cmake_language(EVAL CODE "set_property(GLOBAL PROPERTY ${propertyName} ${__findPackageArgs})" ) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index c556049..fb12b7d 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -10,15 +10,6 @@ #include <QTranslator> #include <QtPlugin> -// FIXME(#23565): Qt6 has QTextCodec in Core5Compat, but using its -// `setCodecForLocale` does not make cmake-gui support non-ASCII chars -// on Windows. For now we only support them with Qt5. How do we support -// them with Qt6, preferably without Core5Compat? -#if defined(Q_OS_WIN) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) -# include <QTextCodec> -# define CMAKE_HAVE_QTEXTCODEC -#endif - #include "cmsys/CommandLineArguments.hxx" #include "cmsys/Encoding.hxx" #include "cmsys/SystemTools.hxx" @@ -133,11 +124,6 @@ int main(int argc, char** argv) setlocale(LC_NUMERIC, "C"); -#ifdef CMAKE_HAVE_QTEXTCODEC - QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); - QTextCodec::setCodecForLocale(utf8_codec); -#endif - // tell the cmake library where cmake is QDir cmExecDir(QApplication::applicationDirPath()); #if defined(Q_OS_MAC) @@ -146,7 +132,7 @@ int main(int argc, char** argv) // pick up translation files if they exists in the data directory QDir translationsDir = cmExecDir; - translationsDir.cd(QString::fromLocal8Bit(".." CMAKE_DATA_DIR)); + translationsDir.cd(".." CMAKE_DATA_DIR); translationsDir.cd("i18n"); QTranslator translator; if (translator.load(QLocale(), "cmake", "_", translationsDir.path())) { @@ -185,8 +171,7 @@ int main(int argc, char** argv) } } - sourceDirectory = - cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + sourceDirectory = cmSystemTools::CollapseFullPath(path.toStdString()); cmSystemTools::ConvertToUnixSlashes(sourceDirectory); } else if (arg.startsWith("-B")) { QString path = arg.mid(2); @@ -203,8 +188,7 @@ int main(int argc, char** argv) } } - binaryDirectory = - cmSystemTools::CollapseFullPath(path.toLocal8Bit().data()); + binaryDirectory = cmSystemTools::CollapseFullPath(path.toStdString()); cmSystemTools::ConvertToUnixSlashes(binaryDirectory); } else if (arg.startsWith("--preset=")) { QString preset = arg.mid(cmStrLen("--preset=")); @@ -212,7 +196,7 @@ int main(int argc, char** argv) std::cerr << "No preset specified for --preset" << std::endl; return 1; } - presetName = preset.toLocal8Bit().data(); + presetName = preset.toStdString(); } else if (arg == "--browse-manual") { OpenReferenceManual(); return 0; @@ -220,21 +204,20 @@ int main(int argc, char** argv) } if (!sourceDirectory.empty() && (!binaryDirectory.empty() || !presetName.empty())) { - dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str())); + dialog.setSourceDirectory(QString::fromStdString(sourceDirectory)); if (!binaryDirectory.empty()) { - dialog.setBinaryDirectory( - QString::fromLocal8Bit(binaryDirectory.c_str())); + dialog.setBinaryDirectory(QString::fromStdString(binaryDirectory)); if (!presetName.empty()) { dialog.setStartupBinaryDirectory(true); } } if (!presetName.empty()) { - dialog.setDeferredPreset(QString::fromLocal8Bit(presetName.c_str())); + dialog.setDeferredPreset(QString::fromStdString(presetName)); } } else { if (args.count() == 2) { std::string filePath = - cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data()); + cmSystemTools::CollapseFullPath(args[1].toStdString()); // check if argument is a directory containing CMakeCache.txt std::string buildFilePath = cmStrCat(filePath, "/CMakeCache.txt"); @@ -249,12 +232,12 @@ int main(int argc, char** argv) std::string srcFilePath = cmStrCat(filePath, "/CMakeLists.txt"); if (cmSystemTools::FileExists(buildFilePath.c_str())) { - dialog.setBinaryDirectory(QString::fromLocal8Bit( - cmSystemTools::GetFilenamePath(buildFilePath).c_str())); + dialog.setBinaryDirectory(QString::fromStdString( + cmSystemTools::GetFilenamePath(buildFilePath))); } else if (cmSystemTools::FileExists(srcFilePath.c_str())) { - dialog.setSourceDirectory(QString::fromLocal8Bit(filePath.c_str())); - dialog.setBinaryDirectory(QString::fromLocal8Bit( - cmSystemTools::CollapseFullPath(".").c_str())); + dialog.setSourceDirectory(QString::fromStdString(filePath)); + dialog.setBinaryDirectory( + QString::fromStdString(cmSystemTools::CollapseFullPath("."))); } } } diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 3c41fce..01fa7bb 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -50,7 +50,7 @@ void OpenReferenceManual() if (!cmSystemTools::GetHTMLDoc().empty()) { url = QUrl::fromLocalFile( - QDir(QString::fromLocal8Bit(cmSystemTools::GetHTMLDoc().data())) + QDir(QString::fromStdString(cmSystemTools::GetHTMLDoc())) .filePath("index.html")); } @@ -735,7 +735,7 @@ void CMakeSetupDialog::showPresetLoadError( { QMessageBox::warning( this, "Error Reading CMake Presets", - QString::fromLocal8Bit("Could not read presets from %1: %2") + QString("Could not read presets from %1: %2") .arg(dir, cmCMakePresetsGraph::ResultToString(result))); } diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index 10360bb..f3c4a8b 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -107,22 +107,21 @@ void StartCompilerSetup::setGenerators( QStringList generator_list; for (cmake::GeneratorInfo const& gen : gens) { - generator_list.append(QString::fromLocal8Bit(gen.name.c_str())); + generator_list.append(QString::fromStdString(gen.name)); if (gen.supportsPlatform) { this->GeneratorsSupportingPlatform.append( - QString::fromLocal8Bit(gen.name.c_str())); + QString::fromStdString(gen.name)); - this - ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] = - QString::fromLocal8Bit(gen.defaultPlatform.c_str()); + this->GeneratorDefaultPlatform[QString::fromStdString(gen.name)] = + QString::fromStdString(gen.defaultPlatform); auto platformIt = gen.supportedPlatforms.cbegin(); while (platformIt != gen.supportedPlatforms.cend()) { this->GeneratorSupportedPlatforms.insert( - QString::fromLocal8Bit(gen.name.c_str()), - QString::fromLocal8Bit((*platformIt).c_str())); + QString::fromStdString(gen.name), + QString::fromStdString((*platformIt))); platformIt++; } @@ -130,7 +129,7 @@ void StartCompilerSetup::setGenerators( if (gen.supportsToolset) { this->GeneratorsSupportingToolset.append( - QString::fromLocal8Bit(gen.name.c_str())); + QString::fromStdString(gen.name)); } } diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index ffb6157..5420d8d 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -70,7 +70,7 @@ QCMake::QCMake(QObject* p) this->loadPresets(); if (!this->PresetName.isEmpty() && this->CMakePresetsGraph.ConfigurePresets.find( - std::string(this->PresetName.toLocal8Bit())) == + std::string(this->PresetName.toStdString())) == this->CMakePresetsGraph.ConfigurePresets.end()) { this->setPreset(QString{}); } @@ -87,8 +87,8 @@ void QCMake::loadCache(const QString& dir) void QCMake::setSourceDirectory(const QString& _dir) { - QString dir = QString::fromLocal8Bit( - cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str()); + QString dir = QString::fromStdString( + cmSystemTools::GetActualCaseForPath(_dir.toStdString())); if (this->SourceDirectory != dir) { this->SourceDirectory = QDir::fromNativeSeparators(dir); emit this->sourceDirChanged(this->SourceDirectory); @@ -99,8 +99,8 @@ void QCMake::setSourceDirectory(const QString& _dir) void QCMake::setBinaryDirectory(const QString& _dir) { - QString dir = QString::fromLocal8Bit( - cmSystemTools::GetActualCaseForPath(_dir.toLocal8Bit().data()).c_str()); + QString dir = QString::fromStdString( + cmSystemTools::GetActualCaseForPath(_dir.toStdString())); if (this->BinaryDirectory != dir) { this->BinaryDirectory = QDir::fromNativeSeparators(dir); emit this->binaryDirChanged(this->BinaryDirectory); @@ -108,8 +108,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) this->setGenerator(QString()); this->setToolset(QString()); this->setPlatform(QString()); - if (!this->CMakeInstance->LoadCache( - this->BinaryDirectory.toLocal8Bit().data())) { + if (!this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString())) { QDir testDir(this->BinaryDirectory); if (testDir.exists("CMakeCache.txt")) { cmSystemTools::Error( @@ -124,7 +123,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) emit this->propertiesChanged(props); cmValue homeDir = state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"); if (homeDir) { - setSourceDirectory(QString::fromLocal8Bit(homeDir->c_str())); + setSourceDirectory(QString(homeDir->c_str())); } cmValue gen = state->GetCacheEntryValue("CMAKE_GENERATOR"); if (gen) { @@ -133,17 +132,17 @@ void QCMake::setBinaryDirectory(const QString& _dir) std::string curGen = cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*gen, *extraGen); - this->setGenerator(QString::fromLocal8Bit(curGen.c_str())); + this->setGenerator(QString::fromStdString(curGen)); } cmValue platform = state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM"); if (platform) { - this->setPlatform(QString::fromLocal8Bit(platform->c_str())); + this->setPlatform(QString(platform->c_str())); } cmValue toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET"); if (toolset) { - this->setToolset(QString::fromLocal8Bit(toolset->c_str())); + this->setToolset(QString(toolset->c_str())); } checkOpenPossible(); @@ -157,13 +156,13 @@ void QCMake::setPreset(const QString& name, bool setBinary) emit this->presetChanged(this->PresetName); if (!name.isNull()) { - std::string presetName(name.toLocal8Bit()); + std::string presetName(name.toStdString()); auto const& expandedPreset = this->CMakePresetsGraph.ConfigurePresets[presetName].Expanded; if (expandedPreset) { if (setBinary && !expandedPreset->BinaryDir.empty()) { QString binaryDir = - QString::fromLocal8Bit(expandedPreset->BinaryDir.data()); + QString::fromStdString(expandedPreset->BinaryDir); this->setBinaryDirectory(binaryDir); } if (expandedPreset->WarnDev) { @@ -190,8 +189,8 @@ void QCMake::setPreset(const QString& name, bool setBinary) this->Environment = this->StartEnvironment; for (auto const& v : expandedPreset->Environment) { if (v.second) { - this->Environment.insert(QString::fromLocal8Bit(v.first.data()), - QString::fromLocal8Bit(v.second->data())); + this->Environment.insert(QString::fromStdString(v.first), + QString::fromStdString(v.second.value())); } } } @@ -240,17 +239,14 @@ void QCMake::configure() UINT lastErrorMode = SetErrorMode(0); #endif - this->CMakeInstance->SetHomeDirectory( - this->SourceDirectory.toLocal8Bit().data()); + this->CMakeInstance->SetHomeDirectory(this->SourceDirectory.toStdString()); this->CMakeInstance->SetHomeOutputDirectory( - this->BinaryDirectory.toLocal8Bit().data()); + this->BinaryDirectory.toStdString()); this->CMakeInstance->SetGlobalGenerator( this->CMakeInstance->CreateGlobalGenerator( - this->Generator.toLocal8Bit().data())); - this->CMakeInstance->SetGeneratorPlatform( - this->Platform.toLocal8Bit().data()); - this->CMakeInstance->SetGeneratorToolset( - this->Toolset.toLocal8Bit().data()); + this->Generator.toStdString())); + this->CMakeInstance->SetGeneratorPlatform(this->Platform.toStdString()); + this->CMakeInstance->SetGeneratorToolset(this->Toolset.toStdString()); this->CMakeInstance->LoadCache(); this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode); this->CMakeInstance->PreLoadCMakeFiles(); @@ -303,8 +299,8 @@ void QCMake::open() InterruptFlag = 0; cmSystemTools::ResetErrorOccuredFlag(); - auto successful = this->CMakeInstance->Open( - this->BinaryDirectory.toLocal8Bit().data(), false); + auto successful = + this->CMakeInstance->Open(this->BinaryDirectory.toStdString(), false); #ifdef Q_OS_WIN SetErrorMode(lastErrorMode); @@ -329,10 +325,10 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(key.c_str()); + prop.Key = QString::fromStdString(key); int idx = props.indexOf(prop); if (idx == -1) { - toremove.append(QString::fromLocal8Bit(key.c_str())); + toremove.append(QString::fromStdString(key)); } else { prop = props[idx]; #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) @@ -343,8 +339,7 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) if (isBool) { state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF"); } else { - state->SetCacheEntryValue(key, - prop.Value.toString().toLocal8Bit().data()); + state->SetCacheEntryValue(key, prop.Value.toString().toStdString()); } props.removeAt(idx); } @@ -352,35 +347,35 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) // remove some properties foreach (QString const& s, toremove) { - this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data()); + this->CMakeInstance->UnwatchUnusedCli(s.toStdString()); - state->RemoveCacheEntry(s.toLocal8Bit().data()); + state->RemoveCacheEntry(s.toStdString()); } // add some new properties foreach (QCMakeProperty const& s, props) { - this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data()); + this->CMakeInstance->WatchUnusedCli(s.Key.toStdString()); if (s.Type == QCMakeProperty::BOOL) { this->CMakeInstance->AddCacheEntry( - s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF", - s.Help.toLocal8Bit().data(), cmStateEnums::BOOL); + s.Key.toStdString(), s.Value.toBool() ? "ON" : "OFF", + s.Help.toStdString().c_str(), cmStateEnums::BOOL); } else if (s.Type == QCMakeProperty::STRING) { this->CMakeInstance->AddCacheEntry( - s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmStateEnums::STRING); + s.Key.toStdString(), s.Value.toString().toStdString(), + s.Help.toStdString().c_str(), cmStateEnums::STRING); } else if (s.Type == QCMakeProperty::PATH) { this->CMakeInstance->AddCacheEntry( - s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmStateEnums::PATH); + s.Key.toStdString(), s.Value.toString().toStdString(), + s.Help.toStdString().c_str(), cmStateEnums::PATH); } else if (s.Type == QCMakeProperty::FILEPATH) { this->CMakeInstance->AddCacheEntry( - s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmStateEnums::FILEPATH); + s.Key.toStdString(), s.Value.toString().toStdString(), + s.Help.toStdString().c_str(), cmStateEnums::FILEPATH); } } - this->CMakeInstance->SaveCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->SaveCache(this->BinaryDirectory.toStdString()); } QCMakePropertyList QCMake::properties() const @@ -399,11 +394,11 @@ QCMakePropertyList QCMake::properties() const cmValue cachedValue = state->GetCacheEntryValue(key); QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(key.c_str()); + prop.Key = QString::fromStdString(key); if (cmValue hs = state->GetCacheEntryProperty(key, "HELPSTRING")) { - prop.Help = QString::fromLocal8Bit(hs->c_str()); + prop.Help = QString(hs->c_str()); } - prop.Value = QString::fromLocal8Bit(cachedValue->c_str()); + prop.Value = QString(cachedValue->c_str()); prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED"); if (t == cmStateEnums::BOOL) { prop.Type = QCMakeProperty::BOOL; @@ -416,8 +411,7 @@ QCMakePropertyList QCMake::properties() const prop.Type = QCMakeProperty::STRING; cmValue stringsProperty = state->GetCacheEntryProperty(key, "STRINGS"); if (stringsProperty) { - prop.Strings = - QString::fromLocal8Bit(stringsProperty->c_str()).split(";"); + prop.Strings = QString(stringsProperty->c_str()).split(";"); } } @@ -425,7 +419,7 @@ QCMakePropertyList QCMake::properties() const } if (!this->PresetName.isNull()) { - std::string presetName(this->PresetName.toLocal8Bit()); + std::string presetName(this->PresetName.toStdString()); auto const& p = this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded; if (p) { @@ -434,8 +428,8 @@ QCMakePropertyList QCMake::properties() const continue; } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(v.first.data()); - prop.Value = QString::fromLocal8Bit(v.second->Value.data()); + prop.Key = QString::fromStdString(v.first); + prop.Value = QString::fromStdString(v.second->Value); prop.Type = QCMakeProperty::STRING; if (!v.second->Type.empty()) { auto type = cmState::StringToCacheEntryType(v.second->Type); @@ -523,18 +517,18 @@ void QCMake::setUpEnvironment() const { auto env = QProcessEnvironment::systemEnvironment(); for (auto const& key : env.keys()) { - cmSystemTools::UnsetEnv(key.toLocal8Bit().data()); + cmSystemTools::UnsetEnv(key.toStdString().c_str()); } for (auto const& var : this->Environment.toStringList()) { - cmSystemTools::PutEnv(var.toLocal8Bit().data()); + cmSystemTools::PutEnv(var.toStdString()); } } void QCMake::loadPresets() { auto result = this->CMakePresetsGraph.ReadProjectPresets( - this->SourceDirectory.toLocal8Bit().data(), true); + this->SourceDirectory.toStdString(), true); if (result != this->LastLoadPresetsResult && result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { emit this->presetLoadError(this->SourceDirectory, result); @@ -550,14 +544,14 @@ void QCMake::loadPresets() } QCMakePreset preset; - preset.name = QString::fromLocal8Bit(p.Name.data()); - preset.displayName = QString::fromLocal8Bit(p.DisplayName.data()); - preset.description = QString::fromLocal8Bit(p.Description.data()); - preset.generator = QString::fromLocal8Bit(p.Generator.data()); - preset.architecture = QString::fromLocal8Bit(p.Architecture.data()); + preset.name = QString::fromStdString(p.Name); + preset.displayName = QString::fromStdString(p.DisplayName); + preset.description = QString::fromStdString(p.Description); + preset.generator = QString::fromStdString(p.Generator); + preset.architecture = QString::fromStdString(p.Architecture); preset.setArchitecture = !p.ArchitectureStrategy || p.ArchitectureStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; - preset.toolset = QString::fromLocal8Bit(p.Toolset.data()); + preset.toolset = QString::fromStdString(p.Toolset); preset.setToolset = !p.ToolsetStrategy || p.ToolsetStrategy == cmCMakePresetsGraph::ArchToolsetStrategy::Set; preset.enabled = it.Expanded && it.Expanded->ConditionResult && @@ -599,9 +593,9 @@ std::vector<cmake::GeneratorInfo> const& QCMake::availableGenerators() const void QCMake::deleteCache() { // delete cache - this->CMakeInstance->DeleteCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->DeleteCache(this->BinaryDirectory.toStdString()); // reload to make our cache empty - this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString()); // emit no generator and no properties this->setGenerator(QString()); this->setToolset(QString()); @@ -615,7 +609,7 @@ void QCMake::reloadCache() QCMakePropertyList props; emit this->propertiesChanged(props); // reload - this->CMakeInstance->LoadCache(this->BinaryDirectory.toLocal8Bit().data()); + this->CMakeInstance->LoadCache(this->BinaryDirectory.toStdString()); // emit new cache properties props = this->properties(); emit this->propertiesChanged(props); @@ -681,7 +675,7 @@ void QCMake::setWarnUninitializedMode(bool value) void QCMake::checkOpenPossible() { - std::string data = this->BinaryDirectory.toLocal8Bit().data(); + std::string data = this->BinaryDirectory.toStdString(); auto possible = this->CMakeInstance->Open(data, true); emit openPossible(possible); } diff --git a/Source/QtDialog/QCMakePresetItemModel.cxx b/Source/QtDialog/QCMakePresetItemModel.cxx index 00a4e18..7ada2a5 100644 --- a/Source/QtDialog/QCMakePresetItemModel.cxx +++ b/Source/QtDialog/QCMakePresetItemModel.cxx @@ -17,12 +17,12 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const // AccessibleDescriptionRole. This was determined by looking at // QComboBoxDelegate::isSeparator() (located in qcombobox_p.h.) if (index.internalId() == SEPARATOR_INDEX) { - return QString::fromLocal8Bit("separator"); + return QString("separator"); } return QString{}; case Qt::DisplayRole: { if (index.internalId() == CUSTOM_INDEX) { - return QString::fromLocal8Bit("<custom>"); + return QString("<custom>"); } if (index.internalId() == SEPARATOR_INDEX) { return QVariant{}; @@ -32,7 +32,7 @@ QVariant QCMakePresetItemModel::data(const QModelIndex& index, int role) const } case Qt::ToolTipRole: if (index.internalId() == CUSTOM_INDEX) { - return QString::fromLocal8Bit("Specify all settings manually"); + return QString("Specify all settings manually"); } if (index.internalId() == SEPARATOR_INDEX) { return QVariant{}; diff --git a/Source/cmWindowsRegistry.h b/Source/cmWindowsRegistry.h index bb9090e..2eed297 100644 --- a/Source/cmWindowsRegistry.h +++ b/Source/cmWindowsRegistry.h @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include <cstdint> // IWYU pragma: keep #include <string> #include <vector> diff --git a/Tests/RunCMake/FetchContent_find_package/ChildScope/CMakeLists.txt b/Tests/RunCMake/FetchContent_find_package/ChildScope/CMakeLists.txt new file mode 100644 index 0000000..7e994d6 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/ChildScope/CMakeLists.txt @@ -0,0 +1,11 @@ +FetchContent_MakeAvailable( + GlobalWithArgsKeyword + GlobalWithoutArgsKeyword + LocalWithArgsKeyword + LocalWithoutArgsKeyword +) + +# This one was declared without GLOBAL, but should still become global when +# this variable is true at the time FetchContent_MakeAvailable() is called +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +FetchContent_MakeAvailable(EventuallyGlobal) diff --git a/Tests/RunCMake/FetchContent_find_package/GLOBAL.cmake b/Tests/RunCMake/FetchContent_find_package/GLOBAL.cmake new file mode 100644 index 0000000..0de65d5 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/GLOBAL.cmake @@ -0,0 +1,50 @@ +include(FetchContent) + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/PackageFindModules) +set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE ALWAYS) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +FetchContent_Declare( + GlobalWithArgsKeyword + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS +) +FetchContent_Declare( + GlobalWithoutArgsKeyword + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded +) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL FALSE) +FetchContent_Declare( + LocalWithArgsKeyword + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded + FIND_PACKAGE_ARGS +) +FetchContent_Declare( + LocalWithoutArgsKeyword + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded +) +FetchContent_Declare( + EventuallyGlobal + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/FatalIfAdded +) + +add_subdirectory(ChildScope) + +if(NOT TARGET GlobalWithArgsKeywordExe) + message(SEND_ERROR "GlobalWithArgsKeywordExe is not a global target") +endif() +if(NOT TARGET GlobalWithoutArgsKeywordExe) + message(SEND_ERROR "GlobalWithoutArgsKeywordExe is not a global target") +endif() + +if(TARGET LocalWithArgsKeywordExe) + message(SEND_ERROR "LocalWithArgsKeywordExe is unexpectedly a global target") +endif() +if(TARGET LocalWithoutArgsKeywordExe) + message(SEND_ERROR "LocalWithoutArgsKeywordExe is unexpectedly a global target") +endif() + +if(NOT TARGET EventuallyGlobalExe) + message(SEND_ERROR "EventuallyGlobalExe is not a global target") +endif() diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindEventuallyGlobal.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindEventuallyGlobal.cmake new file mode 100644 index 0000000..2389cb1 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindEventuallyGlobal.cmake @@ -0,0 +1,6 @@ +add_executable(EventuallyGlobalExe IMPORTED) +set_target_properties(EventuallyGlobalExe PROPERTIES + IMPORTED_LOCATION "${CMAKE_COMMAND}" +) + +set(EventuallyGlobal_FOUND TRUE) diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithArgsKeyword.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithArgsKeyword.cmake new file mode 100644 index 0000000..55588b8 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithArgsKeyword.cmake @@ -0,0 +1,6 @@ +add_executable(GlobalWithArgsKeywordExe IMPORTED) +set_target_properties(GlobalWithArgsKeywordExe PROPERTIES + IMPORTED_LOCATION "${CMAKE_COMMAND}" +) + +set(GlobalWithArgsKeyword_FOUND TRUE) diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithoutArgsKeyword.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithoutArgsKeyword.cmake new file mode 100644 index 0000000..c3e6a6b --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindGlobalWithoutArgsKeyword.cmake @@ -0,0 +1,6 @@ +add_executable(GlobalWithoutArgsKeywordExe IMPORTED) +set_target_properties(GlobalWithoutArgsKeywordExe PROPERTIES + IMPORTED_LOCATION "${CMAKE_COMMAND}" +) + +set(GlobalWithoutArgsKeyword_FOUND TRUE) diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithArgsKeyword.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithArgsKeyword.cmake new file mode 100644 index 0000000..381daa3 --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithArgsKeyword.cmake @@ -0,0 +1,6 @@ +add_executable(LocalWithArgsKeywordExe IMPORTED) +set_target_properties(LocalWithArgsKeywordExe PROPERTIES + IMPORTED_LOCATION "${CMAKE_COMMAND}" +) + +set(LocalWithArgsKeyword_FOUND TRUE) diff --git a/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithoutArgsKeyword.cmake b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithoutArgsKeyword.cmake new file mode 100644 index 0000000..523fecd --- /dev/null +++ b/Tests/RunCMake/FetchContent_find_package/PackageFindModules/FindLocalWithoutArgsKeyword.cmake @@ -0,0 +1,6 @@ +add_executable(LocalWithoutArgsKeywordExe IMPORTED) +set_target_properties(LocalWithoutArgsKeywordExe PROPERTIES + IMPORTED_LOCATION "${CMAKE_COMMAND}" +) + +set(LocalWithoutArgsKeyword_FOUND TRUE) diff --git a/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake index c139f57..83c0a9a 100644 --- a/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/FetchContent_find_package/RunCMakeTest.cmake @@ -20,3 +20,4 @@ run_cmake(Try_find_package-NEVER) run_cmake(Try_find_package-OPT_IN) run_cmake(Try_find_package-BOGUS) run_cmake(Redirect_find_package_MODULE) +run_cmake(GLOBAL) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index f232b1b..1c92ca0 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -165,7 +165,9 @@ function(run_cmake test) "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" "|[^\n]*xcodebuild[^\n]*DVTPlugInManager" + "|[^\n]*xcodebuild[^\n]*DVTSDK: Warning: SDK path collision for path" "|[^\n]*xcodebuild[^\n]*Requested but did not find extension point with identifier" + "|[^\n]*xcodebuild[^\n]*nil host used in call to allows.*HTTPSCertificateForHost" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" "|[^\n]*objc[^\n]*: Class [^\n]* One of the two will be used. Which one is undefined." "|[^\n]*is a member of multiple groups" |