`Native Conversion`_
cmake_path(`NATIVE_PATH`_ <path-var> [NORMALIZE] <out-var>)
- cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <out-var>)
- cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <out-var>)
+ cmake_path(`CONVERT`_ <input> `TO_CMAKE_PATH_LIST`_ <out-var> [NORMALIZE])
+ cmake_path(`CONVERT`_ <input> `TO_NATIVE_PATH_LIST`_ <out-var> [NORMALIZE])
`Hashing`_
cmake_path(`HASH`_ <path-var> <out-var>)
Get a specific component of a full filename.
-.. versionchanged:: 3.19
+.. versionchanged:: 3.20
This command been superseded by :command:`cmake_path` command, except
``REALPATH`` now offered by :ref:`file(REAL_PATH) <REAL_PATH>` command and
``PROGRAM`` now available in :command:`separate_arguments(PROGRAM)` command.
.. variable:: CPACK_DMG_FILESYSTEM
+ .. versionadded:: 3.21
+
The filesystem format. Common values are ``APFS`` and ``HFS+``.
See ``man hdiutil`` for a full list of supported formats.
Defaults to ``HFS+``.
.. warning::
- This is experimental and based on "Visual Studio 2022 Preview 2".
+ This is experimental and based on "Visual Studio 2022 Preview 3.1".
As of this version of CMake, VS 2022 has not been released.
Project Types
Toolset Selection
^^^^^^^^^^^^^^^^^
-The ``v143`` toolset that comes with VS 17 2022 Preview 2 is selected by
+The ``v143`` toolset that comes with VS 17 2022 Preview 3.1 is selected by
default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
An optional string representing the path to the toolchain file.
This field supports `macro expansion`_. If a relative path is specified,
it is calculated relative to the build directory, and if not found,
- relative to the source directory. Takes precedence over any `CMAKE_TOOLCHAIN_FILE`
- value. This is allowed in preset files specifying version ``3`` or above.
+ relative to the source directory. This field takes precedence over any
+ :variable:`CMAKE_TOOLCHAIN_FILE` value. It is allowed in preset files
+ specifying version ``3`` or above.
``binaryDir``
----------
* The :generator:`Visual Studio 17 2022` generator was added. This is
- experimental and based on "Visual Studio 2022 Preview 2" because this
+ experimental and based on "Visual Studio 2022 Preview 3.1" because this
version of VS has not been released.
* The :ref:`Makefile Generators` and the :generator:`Ninja` generator
* The :generator:`Visual Studio 17 2022` generator is now based on
"Visual Studio 2022 Preview 2". Previously it was based on "Preview 1.1".
+
+3.21.2
+------
+
+* ``CUDA`` targets with :prop_tgt:`CUDA_SEPARABLE_COMPILATION` enabled are now
+ correctly generated in non-root directories.
+
+* The :generator:`Visual Studio 17 2022` generator is now based on
+ "Visual Studio 2022 Preview 3.1". Previously it was based on "Preview 2".
if(NOT _CMAKE_USER_TOOL_PATH)
# Find CMAKE_TOOL in the SEARCH_PATH directory by user-defined name.
- find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH})
+ find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
if(_CMAKE_TOOL_WITH_PATH)
# Overwrite CMAKE_TOOL with full path found in SEARCH_PATH.
# Prepend toolchain-specific names.
if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang)
if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC")
- set(_CMAKE_LINKER_NAMES "lld-link")
+ list(PREPEND _CMAKE_LINKER_NAMES "lld-link")
else()
- set(_CMAKE_LINKER_NAMES "ld.lld")
+ list(PREPEND _CMAKE_LINKER_NAMES "ld.lld")
endif()
list(PREPEND _CMAKE_AR_NAMES "llvm-ar")
list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib")
endforeach()
list(REMOVE_DUPLICATES _CMAKE_${_CMAKE_TOOL}_FIND_NAMES)
- find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_${_CMAKE_TOOL} NAMES ${_CMAKE_${_CMAKE_TOOL}_FIND_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
unset(_CMAKE_${_CMAKE_TOOL}_FIND_NAMES)
endforeach()
if(CMAKE_PLATFORM_HAS_INSTALLNAME)
- find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
if(NOT CMAKE_INSTALL_NAME_TOOL)
message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
include_guard(GLOBAL)
+cmake_policy(PUSH)
+cmake_policy(SET CMP0126 NEW)
+
macro(check_language lang)
if(NOT DEFINED CMAKE_${lang}_COMPILER)
set(_desc "Looking for a ${lang} compiler")
endif()
endmacro()
+
+cmake_policy(POP)
"${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar-${__version_x}"
"${_CMAKE_TOOLCHAIN_PREFIX}llvm-ar"
HINTS ${__clang_hints}
+ NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH
DOC "LLVM archiver"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR)
"${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib-${__version_x}"
"${_CMAKE_TOOLCHAIN_PREFIX}llvm-ranlib"
HINTS ${__clang_hints}
+ NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH
DOC "Generate index for LLVM archive"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB)
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}"
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}"
HINTS ${__gcc_hints}
+ NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH
DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR)
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}"
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}"
HINTS ${__gcc_hints}
+ NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH
DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler"
)
mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB)
# Needed so that we support `LANGUAGE` property correctly
set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c)
-# Required since as of NVHPC 21.03 the `-MD` flag implicitly
-# implies `-E` and therefore compilation and dependency generation
-# can't occur in the same invocation
-set(CMAKE_C_DEPENDS_EXTRA_COMMANDS "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x c -M <SOURCE> -MT <OBJECT> -MD<DEP_FILE>")
+if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11)
+ set(CMAKE_C17_STANDARD_COMPILE_OPTION -std=c17)
+ set(CMAKE_C17_EXTENSION_COMPILE_OPTION -std=gnu17)
+endif()
__compiler_nvhpc(C)
# Needed so that we support `LANGUAGE` property correctly
set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++)
-# Required since as of NVHPC 21.03 the `-MD` flag implicitly
-# implies `-E` and therefore compilation and dependency generation
-# can't occur in the same invocation
-set(CMAKE_CXX_DEPENDS_EXTRA_COMMANDS "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x c++ -M <SOURCE> -MT <OBJECT> -MD<DEP_FILE>")
+if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 20.11)
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION -std=c++20)
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION -std=gnu++20)
+endif()
__compiler_nvhpc(CXX)
macro(__compiler_nvhpc lang)
# Logic specific to NVHPC.
+
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 21.07)
+ set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
+ set(CMAKE_${lang}_DEPFILE_FORMAT gcc)
+ set(CMAKE_${lang}_DEPENDS_USE_COMPILER TRUE)
+ else()
+ # Before NVHPC 21.07 the `-MD` flag implicitly
+ # implies `-E` and therefore compilation and dependency generation
+ # can't occur in the same invocation
+ set(CMAKE_${lang}_DEPENDS_EXTRA_COMMANDS "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> ${CMAKE_${lang}_COMPILE_OPTIONS_EXPLICIT_LANGUAGE} -M <SOURCE> -MT <OBJECT> -MD<DEP_FILE>")
+ endif()
+
endmacro()
# we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore
# produce inconsistent results with the regularly flags.
# Similarly, aliasing flags do not belong into our flag array.
- if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce])")
+ # Also strip out `-framework` flags.
+ if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce]|ramework)")
list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}")
endif()
endforeach()
# Unsets the given variables
macro(_pkgconfig_unset var)
+ # Clear normal variable (possibly set by project code).
+ unset(${var})
+ # Store as cache variable.
+ # FIXME: Add a policy to switch to a normal variable.
set(${var} "" CACHE INTERNAL "")
endmacro()
macro(_pkgconfig_set var value)
+ # Clear normal variable (possibly set by project code).
+ unset(${var})
+ # Store as cache variable.
+ # FIXME: Add a policy to switch to a normal variable.
set(${var} ${value} CACHE INTERNAL "")
endmacro()
macro(GNUInstallDirs_get_absolute_install_dir absvar var)
set(GGAID_extra_args ${ARGN})
list(LENGTH GGAID_extra_args GGAID_extra_arg_count)
- if(GGAID_extra_arg_count GREATER 0)
+ if(GGAID_extra_arg_count GREATER "0")
list(GET GGAID_extra_args 0 GGAID_dir)
else()
# Historical behavior: use ${dir} from caller's scope
if(PACKAGE_NAME)
set(PACKAGE_NAME " -n ${PACKAGE_NAME}")
endif()
- set(${TYPE}_
- "%${TYPE}${PACKAGE_NAME}\n"
- "${VAR}\n" PARENT_SCOPE)
+ set(${TYPE}_ "%${TYPE}${PACKAGE_NAME}\n${VAR}\n" PARENT_SCOPE)
else()
set(${TYPE} "" PARENT_SCOPE)
endif()
if(CMAKE_ANDROID_NDK)
# Identify the host platform.
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86_64")
else()
set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86")
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
set(CMAKE_MODULE_EXISTS 1)
set(CMAKE_DL_LIBS "")
-set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
+if(NOT "${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
+endif()
foreach(lang C CXX OBJC OBJCXX)
set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
-# process only once
-if(HAIKU)
- return()
-endif()
-
set(HAIKU 1)
set(UNIX 1)
cmQtAutoMocUic.h
cmQtAutoRcc.cxx
cmQtAutoRcc.h
- cmQtAutoUicHelpers.cxx
- cmQtAutoUicHelpers.h
cmRST.cxx
cmRST.h
cmRuntimeDependencyArchive.cxx
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 21)
-set(CMake_VERSION_PATCH 1)
+set(CMake_VERSION_PATCH 2)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
if(NOT CMake_VERSION_NO_GIT)
# If this source was exported by 'git archive', use its commit info.
- set(git_info [==[f7cf69e34a CMake 3.21.1]==])
+ set(git_info [==[31c5700d43 CMake 3.21.2]==])
# Otherwise, try to identify the current development source version.
if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* "
{
this->AppendXML = false;
this->TestLoad = 0;
- this->Options.clear();
- for (auto const& po : this->PersistentOptions) {
- this->Options[po.first] = po.second;
- }
+ this->Options = this->PersistentOptions;
+ this->MultiOptions = this->PersistentMultiOptions;
}
const char* cmCTestGenericHandler::GetOption(const std::string& op)
template <class T>
ReadFileResult VisitPreset(
T& preset, std::map<std::string, cmCMakePresetsFile::PresetPair<T>>& presets,
- std::map<std::string, CycleStatus> cycleStatus, int version)
+ std::map<std::string, CycleStatus> cycleStatus,
+ const cmCMakePresetsFile& file)
{
switch (cycleStatus[preset.Name]) {
case CycleStatus::InProgress:
return ReadFileResult::USER_PRESET_INHERITANCE;
}
- auto result = VisitPreset(parentPreset, presets, cycleStatus, version);
+ auto result = VisitPreset(parentPreset, presets, cycleStatus, file);
if (result != ReadFileResult::READ_OK) {
return result;
}
preset.ConditionEvaluator.reset();
}
- CHECK_OK(preset.VisitPresetAfterInherit(version))
+ CHECK_OK(preset.VisitPresetAfterInherit(file.GetVersion(preset)))
cycleStatus[preset.Name] = CycleStatus::Verified;
return ReadFileResult::READ_OK;
for (auto& it : presets) {
auto& preset = it.second.Unexpanded;
- auto result =
- VisitPreset<T>(preset, presets, cycleStatus, file.GetVersion(preset));
+ auto result = VisitPreset<T>(preset, presets, cycleStatus, file);
if (result != ReadFileResult::READ_OK) {
return result;
}
if (version == "14.29.16.10" && vcToolsetVersion == "14.29.30037") {
return AuxToolset::Default;
}
+ if (version == "14.29.16.11" && vcToolsetVersion == "14.29.30133") {
+ return AuxToolset::Default;
+ }
// The first two components of the default toolset version typically
// match the name used by later VS versions for the SxS props files.
this->LocalGenerator->MaybeRelativeToTopBinDir(dependFileNameFull))
<< "\n";
+ // Scan any custom commands to check if DEPFILE option is specified
+ bool ccGenerateDeps = false;
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands,
+ this->GetConfigName());
+ for (cmSourceFile const* sf : customCommands) {
+ if (!sf->GetCustomCommand()->GetDepfile().empty()) {
+ ccGenerateDeps = true;
+ break;
+ }
+ }
+
std::string depsUseCompiler = "CMAKE_DEPENDS_USE_COMPILER";
- if (!this->Makefile->IsDefinitionSet(depsUseCompiler) ||
- this->Makefile->IsOn(depsUseCompiler)) {
+ bool compilerGenerateDeps =
+ this->GlobalGenerator->SupportsCompilerDependencies() &&
+ (!this->Makefile->IsDefinitionSet(depsUseCompiler) ||
+ this->Makefile->IsOn(depsUseCompiler));
+
+ if (compilerGenerateDeps || ccGenerateDeps) {
std::string compilerDependFile =
cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.make");
*this->BuildFileStream << "# Include any dependencies generated by the "
"management for "
<< this->GeneratorTarget->GetName() << ".\n";
}
+ }
+ if (compilerGenerateDeps) {
// deactivate no longer needed legacy dependency files
// Write an empty dependency file.
cmGeneratedFileStream legacyDepFileStream(
}
std::vector<std::string> architectures = cmExpandedList(architecturesStr);
+ std::string const& relPath =
+ this->LocalGenerator->GetHomeRelativeOutputPath();
// Ensure there are no duplicates.
const std::vector<std::string> linkDeps = [&]() -> std::vector<std::string> {
std::vector<std::string> deps;
this->AppendTargetDepends(deps, true);
this->GeneratorTarget->GetLinkDepends(deps, this->GetConfigName(), "CUDA");
- std::copy(this->Objects.begin(), this->Objects.end(),
- std::back_inserter(deps));
+
+ for (std::string const& obj : this->Objects) {
+ deps.emplace_back(cmStrCat(relPath, obj));
+ }
std::unordered_set<std::string> depsSet(deps.begin(), deps.end());
deps.clear();
std::string profiles;
std::vector<std::string> fatbinaryDepends;
- std::string registerFile = cmStrCat(objectDir, "cmake_cuda_register.h");
+ std::string const registerFile =
+ cmStrCat(objectDir, "cmake_cuda_register.h");
// Link device code for each architecture.
for (const std::string& architectureKind : architectures) {
- // Clang always generates real code, so strip the specifier.
- const std::string architecture =
- architectureKind.substr(0, architectureKind.find('-'));
- const std::string cubin =
- cmStrCat(relObjectDir, "sm_", architecture, ".cubin");
-
- profiles += cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin);
- fatbinaryDepends.emplace_back(cubin);
-
std::string registerFileCmd;
// The generated register file contains macros that when expanded
// register the device routines. Because the routines are the same for
// all architectures the register file will be the same too. Thus
// generate it only on the first invocation to reduce overhead.
- if (fatbinaryDepends.size() == 1) {
- std::string registerFileRel =
- this->LocalGenerator->MaybeRelativeToCurBinDir(registerFile);
+ if (fatbinaryDepends.empty()) {
+ std::string const registerFileRel =
+ cmStrCat(relPath, relObjectDir, "cmake_cuda_register.h");
registerFileCmd =
cmStrCat(" --register-link-binaries=", registerFileRel);
cleanFiles.push_back(registerFileRel);
}
+ // Clang always generates real code, so strip the specifier.
+ const std::string architecture =
+ architectureKind.substr(0, architectureKind.find('-'));
+ const std::string cubin =
+ cmStrCat(objectDir, "sm_", architecture, ".cubin");
+
+ profiles += cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin);
+ fatbinaryDepends.emplace_back(cubin);
+
std::string command = cmStrCat(
this->Makefile->GetRequiredDefinition("CMAKE_CUDA_DEVICE_LINKER"),
" -arch=sm_", architecture, registerFileCmd, " -o=$@ ",
const std::string fatbinaryOutput =
cmStrCat(objectDir, "cmake_cuda_fatbin.h");
const std::string fatbinaryOutputRel =
- this->LocalGenerator->MaybeRelativeToCurBinDir(fatbinaryOutput);
+ cmStrCat(relPath, relObjectDir, "cmake_cuda_fatbin.h");
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
fatbinaryOutputRel, fatbinaryDepends,
compileCmd, vars);
commands.emplace_back(compileCmd);
- this->LocalGenerator->WriteMakeRule(
- *this->BuildFileStream, nullptr, output,
- { cmStrCat(relObjectDir, "cmake_cuda_fatbin.h") }, commands, false);
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, output,
+ { fatbinaryOutputRel }, commands, false);
// Clean all the possible executable names and symlinks.
this->CleanFiles.insert(cleanFiles.begin(), cleanFiles.end());
const std::string cubin =
cmStrCat(ninjaOutputDir, "/sm_", architecture, ".cubin");
- fatbinary.Variables["PROFILES"] +=
- cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin);
- fatbinary.ExplicitDeps.emplace_back(cubin);
-
cmNinjaBuild dlink(this->LanguageLinkerCudaDeviceRule(config));
dlink.ExplicitDeps = explicitDeps;
dlink.Outputs = { cubin };
// the device routines. Because the routines are the same for all
// architectures the register file will be the same too. Thus generate it
// only on the first invocation to reduce overhead.
- if (fatbinary.ExplicitDeps.size() == 1) {
+ if (fatbinary.ExplicitDeps.empty()) {
dlink.Variables["REGISTER"] = cmStrCat(
"--register-link-binaries=", ninjaOutputDir, "/cmake_cuda_register.h");
}
+ fatbinary.Variables["PROFILES"] +=
+ cmStrCat(" -im=profile=sm_", architecture, ",file=", cubin);
+ fatbinary.ExplicitDeps.emplace_back(cubin);
+
this->GetGlobalGenerator()->WriteBuild(this->GetCommonFileStream(), dlink);
}
this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"],
config);
- if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
+ if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE") &&
+ (gt->GetType() == cmStateEnums::TargetType::EXECUTABLE ||
+ gt->GetType() == cmStateEnums::TargetType::SHARED_LIBRARY ||
+ gt->GetType() == cmStateEnums::TargetType::MODULE_LIBRARY)) {
vars["LINK_FLAGS"] += " -Wl,--no-as-needed";
}
vars["LINK_FLAGS"] = globalGen->EncodeLiteral(vars["LINK_FLAGS"]);
}
return true;
}
-
-bool cmQtAutoGen::FileRead(std::string& content, std::string const& filename,
- std::string* error)
-{
- content.clear();
- if (!cmSystemTools::FileExists(filename, true)) {
- if (error != nullptr) {
- *error = "Not a file.";
- }
- return false;
- }
-
- unsigned long const length = cmSystemTools::FileLength(filename);
- cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
-
- // Use lambda to save destructor calls of ifs
- return [&ifs, length, &content, error]() -> bool {
- if (!ifs) {
- if (error != nullptr) {
- *error = "Opening the file for reading failed.";
- }
- return false;
- }
- content.reserve(length);
- using IsIt = std::istreambuf_iterator<char>;
- content.assign(IsIt{ ifs }, IsIt{});
- if (!ifs) {
- content.clear();
- if (error != nullptr) {
- *error = "Reading from the file failed.";
- }
- return false;
- }
- return true;
- }();
-}
std::vector<std::string> const& newOpts,
bool isQt5);
- static bool FileRead(std::string& content, std::string const& filename,
- std::string* error = nullptr);
-
/** @class RccLister
* @brief Lists files in qrc resource files
*/
// The reason is that their file names might be discovered from source files
// at generation time.
if (this->MocOrUicEnabled()) {
- std::set<std::string> uicIncludes;
- auto collectUicIncludes = [&](std::unique_ptr<cmSourceFile> const& sf) {
- std::string content;
- FileRead(content, sf->GetFullPath());
- this->AutoUicHelpers.CollectUicIncludes(uicIncludes, content);
- };
-
for (const auto& sf : this->Makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->ResolveFullPath() ...
// Since we're iterating over source files that might be not in the
std::string const& extLower =
cmSystemTools::LowerCase(sf->GetExtension());
- bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
- bool const skipUic =
- (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC) ||
- !this->Uic.Enabled);
if (cm->IsAHeaderExtension(extLower)) {
if (!cm::contains(this->AutogenTarget.Headers, sf.get())) {
auto muf = makeMUFile(sf.get(), fullPath, {}, false);
addMUHeader(std::move(muf), extLower);
}
}
- if (!skipUic && !sf->GetIsGenerated()) {
- collectUicIncludes(sf);
- }
} else if (cm->IsACLikeSourceExtension(extLower)) {
if (!cm::contains(this->AutogenTarget.Sources, sf.get())) {
auto muf = makeMUFile(sf.get(), fullPath, {}, false);
addMUSource(std::move(muf));
}
}
- if (!skipUic && !sf->GetIsGenerated()) {
- collectUicIncludes(sf);
- }
} else if (this->Uic.Enabled && (extLower == kw.ui)) {
// .ui file
+ bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
+ bool const skipUic =
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
if (!skipUic) {
// Check if the .ui file has uic options
std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS);
this->Uic.UiFilesWithOptions.emplace_back(fullPath,
cmExpandedList(uicOpts));
}
+
+ auto uiHeaderRelativePath = cmSystemTools::RelativePath(
+ this->LocalGen->GetCurrentSourceDirectory(),
+ cmSystemTools::GetFilenamePath(fullPath));
+
+ // Avoid creating a path containing adjacent slashes
+ if (!uiHeaderRelativePath.empty() &&
+ uiHeaderRelativePath.back() != '/') {
+ uiHeaderRelativePath += '/';
+ }
+
+ auto uiHeaderFilePath = cmStrCat(
+ '/', uiHeaderRelativePath, "ui_"_s,
+ cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s);
+
+ ConfigString uiHeader;
+ std::string uiHeaderGenex;
+ this->ConfigFileNamesAndGenex(
+ uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
+ uiHeaderFilePath);
+
+ this->Uic.UiHeaders.emplace_back(
+ std::make_pair(uiHeader, uiHeaderGenex));
} else {
// Register skipped .ui file
this->Uic.SkipUi.insert(fullPath);
}
}
}
-
- for (const auto& include : uicIncludes) {
- ConfigString uiHeader;
- std::string uiHeaderGenex;
- this->ConfigFileNamesAndGenex(uiHeader, uiHeaderGenex,
- cmStrCat(this->Dir.Build, "/include"_s),
- cmStrCat("/"_s, include));
- this->Uic.UiHeaders.emplace_back(
- std::make_pair(uiHeader, uiHeaderGenex));
- }
}
// Process GENERATED sources and headers
#include "cmFilePathChecksum.h"
#include "cmQtAutoGen.h"
-#include "cmQtAutoUicHelpers.h"
class cmGeneratorTarget;
class cmGlobalGenerator;
std::string ConfigDefault;
std::vector<std::string> ConfigsList;
std::string TargetsFolder;
- cmQtAutoUicHelpers AutoUicHelpers;
/** Common directories. */
struct
return success;
}
+bool cmQtAutoGenerator::FileRead(std::string& content,
+ std::string const& filename,
+ std::string* error)
+{
+ content.clear();
+ if (!cmSystemTools::FileExists(filename, true)) {
+ if (error != nullptr) {
+ *error = "Not a file.";
+ }
+ return false;
+ }
+
+ unsigned long const length = cmSystemTools::FileLength(filename);
+ cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
+
+ // Use lambda to save destructor calls of ifs
+ return [&ifs, length, &content, error]() -> bool {
+ if (!ifs) {
+ if (error != nullptr) {
+ *error = "Opening the file for reading failed.";
+ }
+ return false;
+ }
+ content.reserve(length);
+ using IsIt = std::istreambuf_iterator<char>;
+ content.assign(IsIt{ ifs }, IsIt{});
+ if (!ifs) {
+ content.clear();
+ if (error != nullptr) {
+ *error = "Reading from the file failed.";
+ }
+ return false;
+ }
+ return true;
+ }();
+}
+
bool cmQtAutoGenerator::FileWrite(std::string const& filename,
std::string const& content,
std::string* error)
// -- File system methods
static bool MakeParentDirectory(std::string const& filename);
+ static bool FileRead(std::string& content, std::string const& filename,
+ std::string* error = nullptr);
static bool FileWrite(std::string const& filename,
std::string const& content,
std::string* error = nullptr);
#include "cmGeneratedFileStream.h"
#include "cmQtAutoGen.h"
#include "cmQtAutoGenerator.h"
-#include "cmQtAutoUicHelpers.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkerPool.h"
std::vector<std::string> Options;
std::unordered_map<std::string, UiFile> UiFiles;
std::vector<std::string> SearchPaths;
- cmQtAutoUicHelpers AutoUicHelpers;
+ cmsys::RegularExpression RegExpInclude;
};
/** Uic shared variables. */
return res;
}
-cmQtAutoMocUicT::UicSettingsT::UicSettingsT() = default;
+cmQtAutoMocUicT::UicSettingsT::UicSettingsT()
+{
+ this->RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+"
+ "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
+}
cmQtAutoMocUicT::UicSettingsT::~UicSettingsT() = default;
}
std::set<std::string> includes;
- this->UicConst().AutoUicHelpers.CollectUicIncludes(includes, this->Content);
+ {
+ const char* contentChars = this->Content.c_str();
+ cmsys::RegularExpression const& regExp = this->UicConst().RegExpInclude;
+ cmsys::RegularExpressionMatch match;
+ while (regExp.find(contentChars, match)) {
+ includes.emplace(match.match(2));
+ // Forward content pointer
+ contentChars += match.end();
+ }
+ }
this->CreateKeys(this->FileHandle->ParseData->Uic.Include, includes,
UiUnderscoreLength);
}
+++ /dev/null
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmQtAutoUicHelpers.h"
-
-cmQtAutoUicHelpers::cmQtAutoUicHelpers()
-{
- RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+"
- "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
-}
-
-void cmQtAutoUicHelpers::CollectUicIncludes(std::set<std::string>& includes,
- const std::string& content) const
-{
- if (content.find("ui_") == std::string::npos) {
- return;
- }
-
- const char* contentChars = content.c_str();
- cmsys::RegularExpressionMatch match;
- while (this->RegExpInclude.find(contentChars, match)) {
- includes.emplace(match.match(2));
- // Forward content pointer
- contentChars += match.end();
- }
-}
+++ /dev/null
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#pragma once
-
-#include <set>
-#include <string>
-
-#include "cmsys/RegularExpression.hxx"
-
-class cmQtAutoUicHelpers
-{
-public:
- cmQtAutoUicHelpers();
- virtual ~cmQtAutoUicHelpers() = default;
- void CollectUicIncludes(std::set<std::string>& includes,
- const std::string& content) const;
-
-private:
- cmsys::RegularExpression RegExpInclude;
-};
if (this->ProjectType == csproj) {
return;
}
+ if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) {
+ return;
+ }
// This processes *any* of the .idl files specified in the project's file
// list (and passed as the item metadata %(Filename) expressing the rule
"comment": "Additional Module Dependencies",
"value": "",
"flags": [
- "UserValue",
+ "UserFollowing",
"SemicolonAppendable"
]
},
"comment": "Additional Header Unit Dependencies",
"value": "",
"flags": [
- "UserValue",
+ "UserFollowing",
"SemicolonAppendable"
]
},
"comment": "Additional Module Dependencies",
"value": "",
"flags": [
- "UserValue",
+ "UserFollowing",
"SemicolonAppendable"
]
},
"comment": "Additional Header Unit Dependencies",
"value": "",
"flags": [
- "UserValue",
+ "UserFollowing",
"SemicolonAppendable"
]
},
add_cuda_test_macro(CudaOnly.WithDefs CudaOnlyWithDefs)
add_cuda_test_macro(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine)
add_cuda_test_macro(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
-add_cuda_test_macro(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
+add_cuda_test_macro(CudaOnly.SeparateCompilation main/CudaOnlySeparateCompilation)
if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang")
# Clang doesn't have flags for selecting the runtime.
target_compile_features(CUDASeparateLibB PRIVATE cuda_std_11)
target_link_libraries(CUDASeparateLibB PRIVATE CUDASeparateLibA)
-add_executable(CudaOnlySeparateCompilation main.cu)
-target_link_libraries(CudaOnlySeparateCompilation
- PRIVATE CUDASeparateLibB)
-set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD 11)
-set_target_properties(CudaOnlySeparateCompilation PROPERTIES CUDA_STANDARD_REQUIRED TRUE)
-
set_target_properties(CUDASeparateLibA
CUDASeparateLibB
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON)
-if (CMAKE_GENERATOR MATCHES "^Visual Studio")
- #Visual Studio CUDA integration will not perform device linking
- #on a target that itself does not have GenerateRelocatableDeviceCode
- #enabled.
- set_target_properties(CudaOnlySeparateCompilation
- PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
-endif()
-
-if(APPLE)
- # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
- set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
-endif()
+add_subdirectory(main)
--- /dev/null
+add_executable(CudaOnlySeparateCompilation main.cu)
+target_link_libraries(CudaOnlySeparateCompilation PRIVATE CUDASeparateLibB)
+set_target_properties(CudaOnlySeparateCompilation PROPERTIES
+ CUDA_STANDARD 11
+ CUDA_STANDARD_REQUIRED TRUE
+)
+
+if(CMAKE_GENERATOR MATCHES "^Visual Studio")
+ # Visual Studio CUDA integration will not perform device linking
+ # on a target that itself does not have GenerateRelocatableDeviceCode
+ # enabled.
+ set_property(TARGET CudaOnlySeparateCompilation PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+endif()
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()
#include <iostream>
-#include "file1.h"
-#include "file2.h"
+#include "../file1.h"
+#include "../file2.h"
int file4_launch_kernel(int x);
int file5_launch_kernel(int x);
endmacro()
configure_file("${testProjectTemplateDir}/mocwidget.h" "${testProjectSrc}/mocwidget.h" COPYONLY)
+configure_file("${testProjectTemplateDir}/mainwindow.h" "${testProjectSrc}/mainwindow.h" COPYONLY)
configure_file("${testProjectTemplateDir}/main.cpp" "${testProjectSrc}/main.cpp" COPYONLY)
-configure_file("${testProjectTemplateDir}/subdir/subdircheck.cpp" "${testProjectSrc}/subdir/subdircheck.cpp" COPYONLY)
configure_file("${testProjectTemplateDir}/CMakeLists.txt.in" "${testProjectSrc}/CMakeLists.txt" @ONLY)
set(Num 1)
configure_file("${testProjectTemplateDir}/mainwindow.ui.in" "${testProjectSrc}/mainwindow.ui" @ONLY)
-configure_file("${testProjectTemplateDir}/subdir/mainwindowsubdir.ui.in" "${testProjectSrc}/subdir/mainwindowsubdir.ui" @ONLY)
if(CMAKE_GENERATOR_INSTANCE)
set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}")
set(Num 2)
configure_file("${testProjectTemplateDir}/mainwindow.ui.in" "${testProjectSrc}/mainwindow.ui" @ONLY)
-configure_file("${testProjectTemplateDir}/subdir/mainwindowsubdir.ui.in" "${testProjectSrc}/subdir/mainwindowsubdir.ui" @ONLY)
rebuild(2)
execute_process(COMMAND "${testProjectBinDir}/${extra_bin_path}UicOnFileChange" RESULT_VARIABLE result)
if(NOT result EQUAL "0")
message(FATAL_ERROR "Rebuild of UicOnFileChange test result is: ${result}")
endif()
+
+# Check if the generated ui_mainwindow.h rules introduce circular dependency between the generated
+# ui_mainwinow.h and timestamp.
+#
+# The first rebuild updates a timestamp dependency file after "touching" mainwindow.h.
+sleep()
+execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${testProjectSrc}/mainwindow.h")
+rebuild(3)
+
+# The second rebuild detects if cycling dependency is introduced by deps file.
+sleep()
+rebuild(4)
# Enable CMAKE_AUTOUIC for all targets
set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTOMOC ON)
-add_executable(UicOnFileChange main.cpp mainwindow.ui
- subdir/subdircheck.cpp subdir/mainwindowsubdir.ui
+add_executable(UicOnFileChange main.cpp mainwindow.ui mainwindow.h
+)
+target_include_directories(UicOnFileChange PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}/UicOnFileChange_autogen/include"
)
-target_include_directories(UicOnFileChange PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(UicOnFileChange ${QT_QTCORE_TARGET} ${QT_LIBRARIES})
+#include "mainwindow.h"
#include "ui_mainwindow.h"
-extern bool subdircheck();
-
int main(int argc, char* argv[])
{
MocWidget mw;
Ui::Widget mwUi;
mwUi.setupUi(&mw);
- return mw.objectName() == "Widget2" && subdircheck() ? 0 : 1;
+ return mw.objectName() == "Widget2" ? 0 : 1;
}
--- /dev/null
+#include <QObject>
+
+#include "ui_mainwindow.h"
+
+class MainWindow : public QObject
+{
+ Q_OBJECT
+public:
+ MainWindow() { mwUi.setupUi(&mw); }
+
+ MocWidget mw;
+ Ui::Widget mwUi;
+};
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>WidgetSubdir</class>
- <widget class="MocWidget" name="WidgetSubdir@Num@"/>
- <resources/>
- <connections/>
-</ui>
+++ /dev/null
-#include "ui_mainwindowsubdir.h"
-
-bool subdircheck()
-{
- MocWidget mw;
- Ui::WidgetSubdir mwUi;
- mwUi.setupUi(&mw);
- return mw.objectName() == "WidgetSubdir2";
-}
--- /dev/null
+enable_language(C)
+
+add_custom_command(OUTPUT main.c
+ DEPFILE main.c.d
+ COMMAND "${CMAKE_COMMAND}" -DINFILE=${CMAKE_CURRENT_SOURCE_DIR}/main.c -DOUTFILE=main.c -DDEPFILE=main.c.d
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/GenerateDepFile.cmake"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c)
if (RunCMake_GENERATOR MATCHES "Makefiles")
run_cmake(CustomCommandDependencies-BadArgs)
+ run_cmake_with_options(CustomCommandDependencies-compiler-deps-legacy -DCMAKE_DEPENDS_USE_COMPILER=FALSE)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(CustomCommandDependencies-compiler-deps-legacy ${CMAKE_COMMAND} --build . --config Debug)
+ unset(RunCMake_TEST_NO_CLEAN)
endif()
if(RunCMake_GENERATOR MATCHES "Make|Ninja|Visual Studio|Xcode" AND
run_cmake_presets(GoodUserOnly)
run_cmake_presets(GoodUserFromMain)
run_cmake_presets(GoodUserFromUser)
+run_cmake_presets(V2InheritV3Optional)
# Test CMakeUserPresets.json errors
run_cmake_presets(UserDuplicateInUser)
--- /dev/null
+{
+ "version": 3,
+ "configurePresets": [
+ {
+ "name": "default"
+ }
+ ]
+}
--- /dev/null
+{
+ "version": 2,
+ "configurePresets": [
+ {
+ "name": "V2InheritV3Optional",
+ "inherits": "default",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build"
+ }
+ ]
+}
--- /dev/null
+
+cmake_policy(SET CMP0126 NEW)
+
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE, FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+ # Cannot create directories for all the existing architectures...
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ else()
+ # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
+ get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS)
+ get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32")
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/libx32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/libx32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ elseif(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib32/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ elseif(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ endif()
+else()
+ if(WIN32)
+ set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+endif()
+
+
+set(FOO_FOUND FALSE)
+
+pkg_check_modules(FOO "${expected_path}")
+
+if(NOT FOO_FOUND)
+ message(FATAL_ERROR "Expected FOO_FOUND == 1.")
+endif()
run_cmake(PkgConfigDoesNotExist)
+run_cmake(FindPkgConfig_CMP0126_NEW)
run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH)
--- /dev/null
+cmake_policy(SET CMP0076 NEW)
+include_directories(Inc1 Inc2)
+add_library(iface INTERFACE)
+target_sources(iface PRIVATE iface.c)
+# Ensure the INCLUDE_DIRECTORIES property is populated.
+# Since interface libraries do not actually compile anything, this should be ignored.
+set_property(TARGET iface APPEND PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/Inc3 ${CMAKE_CURRENT_SOURCE_DIR}/Inc4)
run_WithSources(EmptySources "build1:iface" "build2:iface2,merge")
run_WithSources(ExcludeFromAll "build1" "build2:iface" "build3:iface2,merge")
run_WithSources(PublicSources "build1" "build2:iface" "build3:iface2,merge")
+run_WithSources(IncludeDirectories "build1:iface")
set(CMAKE_LINK_WHAT_YOU_USE TRUE)
add_executable(main main.c)
target_link_libraries(main m)
+add_library(foo STATIC foo.c)
set(CMAKE_LINK_WHAT_YOU_USE TRUE)
add_executable(main main.cxx)
target_link_libraries(main m)
+add_library(foo STATIC foo.cxx)
--- /dev/null
+int foo(void)
+{
+ return 0;
+}
--- /dev/null
+int foo()
+{
+ return 0;
+}
run_ctest(TestCompletionStatus)
endfunction()
run_completion_status()
+
+# Verify that running ctest_test() multiple times with different label arguments
+# doesn't break.
+function(run_changing_labels)
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_test(NAME a COMMAND ${CMAKE_COMMAND} -E true)
+set_property(TEST a PROPERTY LABELS a)
+add_test(NAME b COMMAND ${CMAKE_COMMAND} -E true)
+set_property(TEST b PROPERTY LABELS b)
+ ]])
+ run_ctest(TestChangingLabels)
+endfunction()
+run_changing_labels()
ctest_start(Experimental)
ctest_configure()
ctest_build()
-ctest_test(${ctest_test_args})
+if("@CASE_NAME@" STREQUAL "TestChangingLabels")
+ ctest_test(${ctest_test_args} INCLUDE_LABEL "^a$")
+ ctest_test(${ctest_test_args} INCLUDE_LABEL "^b$")
+else()
+ ctest_test(${ctest_test_args})
+endif()