Merge topic 'ninja-swift-library-name'
157570b5a2 Add placeholder for Swift's library name
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2902
diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake
index b3c96ee..d34154c 100644
--- a/Modules/Compiler/Cray-C.cmake
+++ b/Modules/Compiler/Cray-C.cmake
@@ -8,13 +8,13 @@
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
- set(CMAKE_C90_STANDARD_COMPILE_OPTION "-h noc99,conform")
- set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-h noc99,gnu")
- set(CMAKE_C99_STANDARD_COMPILE_OPTION "-h c99,conform")
- set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-h c99,gnu")
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform)
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform)
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5)
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "-h std=c11,conform")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-h std=c11,gnu")
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform)
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu)
endif ()
endif ()
diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake
index bbb5718..85a3167 100644
--- a/Modules/Compiler/Cray-CXX.cmake
+++ b/Modules/Compiler/Cray-CXX.cmake
@@ -8,15 +8,15 @@
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-h conform")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-h gnu")
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform)
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-h std=c++11")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-h std=c++11,gnu")
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11)
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu)
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6)
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-h std=c++14")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-h std=c++14,gnu")
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14)
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu)
endif ()
endif ()
diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake
index d522739..f0e61d8 100644
--- a/Modules/Compiler/Flang-Fortran.cmake
+++ b/Modules/Compiler/Flang-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/Clang)
__compiler_clang(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake
index c333d50..6413769 100644
--- a/Modules/Compiler/GNU-Fortran.cmake
+++ b/Modules/Compiler/GNU-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/GNU)
__compiler_gnu(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "@")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake
index a132055..5275ddf 100644
--- a/Modules/Compiler/Intel-Fortran.cmake
+++ b/Modules/Compiler/Intel-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/Intel)
__compiler_intel(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "@")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_MODDIR_FLAG "-module ")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake
index a183c33..3daf798 100644
--- a/Modules/Compiler/PGI-Fortran.cmake
+++ b/Modules/Compiler/PGI-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/PGI)
__compiler_pgi(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake
index 6bab6f6..c4fb097 100644
--- a/Modules/Compiler/XL-Fortran.cmake
+++ b/Modules/Compiler/XL-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/XL)
__compiler_xl(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "_")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>]
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm]
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index 1a2af16..47c0e79 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -18,7 +18,7 @@
This module will set the following variables in your project:
-``LIBXML2_FOUND``
+``LibXml2_FOUND``
true if libxml2 headers and libraries were found
``LIBXML2_INCLUDE_DIR``
the directory containing LibXml2 headers
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index a73ffba..5590433 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -214,7 +214,7 @@
if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr)
foreach(lang C CXX)
- list(APPEND CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
+ list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
endforeach()
endif()
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 4ae4514..46c24bb 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -63,11 +63,6 @@
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
)
-# Platform-wide directories to avoid adding via -I<dir>.
-list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES
- /usr/include
- )
-
# Default per-language values. These may be later replaced after
# parsing the implicit directory information from compiler output.
set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index e1284df..e69ceb9 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 14)
-set(CMake_VERSION_PATCH 20190213)
+set(CMake_VERSION_PATCH 20190215)
#set(CMake_VERSION_RC 1)
diff --git a/Source/LexerParser/cmListFileLexer.c b/Source/LexerParser/cmListFileLexer.c
index c726415..15dcda0 100644
--- a/Source/LexerParser/cmListFileLexer.c
+++ b/Source/LexerParser/cmListFileLexer.c
@@ -766,7 +766,7 @@
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifdef WIN32
+#ifdef _WIN32
#include "cmsys/Encoding.h"
#endif
diff --git a/Source/LexerParser/cmListFileLexer.in.l b/Source/LexerParser/cmListFileLexer.in.l
index 6a6fb5f..fdf14d2 100644
--- a/Source/LexerParser/cmListFileLexer.in.l
+++ b/Source/LexerParser/cmListFileLexer.in.l
@@ -18,7 +18,7 @@
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifdef WIN32
+#ifdef _WIN32
#include "cmsys/Encoding.h"
#endif
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 30328c6..1c4160b 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -348,6 +348,14 @@
return std::reverse_iterator<Iter>(it);
}
+inline bool cmHasPrefix(std::string const& str, std::string const& prefix)
+{
+ if (str.size() < prefix.size()) {
+ return false;
+ }
+ return str.compare(0, prefix.size(), prefix) == 0;
+}
+
inline bool cmHasSuffix(const std::string& str, const std::string& suffix)
{
if (str.size() < suffix.size()) {
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index bd110ec..eb52895 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -226,7 +226,7 @@
} else if (doing == DoingCMakeFlags) {
cmakeFlags.push_back(argv[i]);
} else if (doing == DoingCompileDefinitions) {
- compileDefs.push_back(argv[i]);
+ cmSystemTools::ExpandListArgument(argv[i], compileDefs);
} else if (doing == DoingLinkOptions) {
linkOptions.push_back(argv[i]);
} else if (doing == DoingLinkLibraries) {
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index cae3ff6..3f036a9 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -94,6 +94,10 @@
}
this->PPDefinitions.insert(def);
}
+
+ this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID");
+ this->SModSep = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ this->SModExt = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
cmDependsFortran::~cmDependsFortran()
@@ -116,6 +120,11 @@
return false;
}
+ cmFortranCompiler fc;
+ fc.Id = this->CompilerId;
+ fc.SModSep = this->SModSep;
+ fc.SModExt = this->SModExt;
+
bool okay = true;
for (std::string const& src : sources) {
// Get the information object for this source.
@@ -123,7 +132,7 @@
// Create the parser object. The constructor takes info by reference,
// so we may look into the resulting objects later.
- cmFortranParser parser(this->IncludePath, this->PPDefinitions, info);
+ cmFortranParser parser(fc, this->IncludePath, this->PPDefinitions, info);
// Push on the starting file.
cmFortranParser_FilePush(&parser, src.c_str());
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index bf09904..0485115 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -77,6 +77,10 @@
// The source file from which to start scanning.
std::string SourceFile;
+ std::string CompilerId;
+ std::string SModSep;
+ std::string SModExt;
+
std::set<std::string> PPDefinitions;
// Internal implementation details.
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index 8d4c90b..0762340 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -128,15 +128,29 @@
bool LastCharWasNewline;
};
+struct cmFortranCompiler
+{
+ std::string Id;
+ std::string SModSep;
+ std::string SModExt;
+};
+
struct cmFortranParser_s
{
- cmFortranParser_s(std::vector<std::string> includes,
+ cmFortranParser_s(cmFortranCompiler fc, std::vector<std::string> includes,
std::set<std::string> defines, cmFortranSourceInfo& info);
~cmFortranParser_s();
bool FindIncludeFile(const char* dir, const char* includeName,
std::string& fileName);
+ std::string ModName(std::string const& mod_name) const;
+ std::string SModName(std::string const& mod_name,
+ std::string const& sub_name) const;
+
+ // What compiler.
+ cmFortranCompiler Compiler;
+
// The include file search path.
std::vector<std::string> IncludePath;
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 45481a4..18e3c10 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -43,10 +43,12 @@
return false;
}
-cmFortranParser_s::cmFortranParser_s(std::vector<std::string> includes,
+cmFortranParser_s::cmFortranParser_s(cmFortranCompiler fc,
+ std::vector<std::string> includes,
std::set<std::string> defines,
cmFortranSourceInfo& info)
- : IncludePath(std::move(includes))
+ : Compiler(std::move(fc))
+ , IncludePath(std::move(includes))
, PPDefinitions(std::move(defines))
, Info(info)
{
@@ -69,6 +71,17 @@
cmFortran_yylex_destroy(this->Scanner);
}
+std::string cmFortranParser_s::ModName(std::string const& mod_name) const
+{
+ return mod_name + ".mod";
+}
+
+std::string cmFortranParser_s::SModName(std::string const& mod_name,
+ std::string const& sub_name) const
+{
+ return mod_name + this->Compiler.SModSep + sub_name + this->Compiler.SModExt;
+}
+
bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
{
// Open the new file and push it onto the stack. Save the old
@@ -178,7 +191,7 @@
// syntax: "use module_name"
// requires: "module_name.mod"
std::string const& mod_name = cmSystemTools::LowerCase(module_name);
- parser->Info.Requires.insert(mod_name + ".mod");
+ parser->Info.Requires.insert(parser->ModName(mod_name));
}
void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
@@ -242,7 +255,7 @@
// syntax: "module module_name"
// provides: "module_name.mod"
std::string const& mod_name = cmSystemTools::LowerCase(module_name);
- parser->Info.Provides.insert(mod_name + ".mod");
+ parser->Info.Provides.insert(parser->ModName(mod_name));
}
}
@@ -265,8 +278,8 @@
std::string const& mod_name = cmSystemTools::LowerCase(module_name);
std::string const& sub_name = cmSystemTools::LowerCase(submodule_name);
- parser->Info.Requires.insert(mod_name + ".mod");
- parser->Info.Provides.insert(mod_name + "@" + sub_name + ".smod");
+ parser->Info.Requires.insert(parser->ModName(mod_name));
+ parser->Info.Provides.insert(parser->SModName(mod_name, sub_name));
}
void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser,
@@ -286,8 +299,8 @@
std::string const& sub_name = cmSystemTools::LowerCase(submodule_name);
std::string const& nest_name =
cmSystemTools::LowerCase(nested_submodule_name);
- parser->Info.Requires.insert(mod_name + "@" + sub_name + ".smod");
- parser->Info.Provides.insert(mod_name + "@" + nest_name + ".smod");
+ parser->Info.Requires.insert(parser->SModName(mod_name, sub_name));
+ parser->Info.Provides.insert(parser->SModName(mod_name, nest_name));
}
void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* macro)
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index ba1ace6..31bcacf 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1678,6 +1678,7 @@
return 1;
}
+ cmFortranCompiler fc;
std::vector<std::string> includes;
{
Json::Value tdio;
@@ -1699,11 +1700,20 @@
includes.push_back(tdi_include_dir.asString());
}
}
+
+ Json::Value const& tdi_compiler_id = tdi["compiler-id"];
+ fc.Id = tdi_compiler_id.asString();
+
+ Json::Value const& tdi_submodule_sep = tdi["submodule-sep"];
+ fc.SModSep = tdi_submodule_sep.asString();
+
+ Json::Value const& tdi_submodule_ext = tdi["submodule-ext"];
+ fc.SModExt = tdi_submodule_ext.asString();
}
cmFortranSourceInfo info;
std::set<std::string> defines;
- cmFortranParser parser(includes, defines, info);
+ cmFortranParser parser(fc, includes, defines, info);
if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
cmSystemTools::Error("-E cmake_ninja_depends failed to open ",
arg_pp.c_str());
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 12d9304..913fc4a 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -453,7 +453,8 @@
"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
"Windows Kits\\Installed Roots;KitsRoot81",
win81Root, cmSystemTools::KeyWOW64_32)) {
- return cmSystemTools::FileExists(win81Root + "/um/windows.h", true);
+ return cmSystemTools::FileExists(win81Root + "/include/um/windows.h",
+ true);
}
return false;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ba3c574..a2d0efe 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -935,16 +935,11 @@
} else {
rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
+ cmSystemTools::ConvertToUnixSlashes(rootPath);
// Raw list of implicit include directories
std::vector<std::string> impDirVec;
- // Get platform-wide implicit directories.
- if (const char* implicitIncludes = (this->Makefile->GetDefinition(
- "CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) {
- cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec);
- }
-
// Load implicit include directories for this language.
std::string key = "CMAKE_";
key += lang;
@@ -953,9 +948,28 @@
cmSystemTools::ExpandListArgument(value, impDirVec);
}
+ // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX,
+ // and CUDA in CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES, but those
+ // variables are now computed. On macOS the /usr/include directory is
+ // inside the platform SDK so the computed value does not contain it
+ // directly. In this case adding -I/usr/include can hide SDK headers so we
+ // must still exclude it.
+ if ((lang == "C" || lang == "CXX" || lang == "CUDA") &&
+ std::find(impDirVec.begin(), impDirVec.end(), "/usr/include") ==
+ impDirVec.end() &&
+ std::find_if(impDirVec.begin(), impDirVec.end(),
+ [](std::string const& d) {
+ return cmHasLiteralSuffix(d, "/usr/include");
+ }) != impDirVec.end()) {
+ impDirVec.emplace_back("/usr/include");
+ }
+
for (std::string const& i : impDirVec) {
- std::string imd = rootPath + i;
+ std::string imd = i;
cmSystemTools::ConvertToUnixSlashes(imd);
+ if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) {
+ imd = rootPath + imd;
+ }
if (implicitSet.insert(imd).second) {
implicitDirs.emplace_back(std::move(imd));
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index d6f71d3..7eb4a03 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1808,6 +1808,17 @@
<< "_COMPILER_ID \"" << cid << "\")\n";
}
+ if (implicitLang.first == "Fortran") {
+ std::string smodSep =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ std::string smodExt =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
+ cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_SEP \"" << smodSep
+ << "\")\n";
+ cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_EXT \"" << smodExt
+ << "\")\n";
+ }
+
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
this->GetTargetDefines(target, this->ConfigName, implicitLang.first,
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index df6428f..8d2586d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1148,6 +1148,10 @@
mod_dir = this->Makefile->GetCurrentBinaryDirectory();
}
tdi["module-dir"] = mod_dir;
+ tdi["submodule-sep"] =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ tdi["submodule-ext"] =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
tdi["dir-cur-bld"] = this->Makefile->GetCurrentBinaryDirectory();
diff --git a/Source/kwsys/CommandLineArguments.hxx.in b/Source/kwsys/CommandLineArguments.hxx.in
index 31115e5..7db9015 100644
--- a/Source/kwsys/CommandLineArguments.hxx.in
+++ b/Source/kwsys/CommandLineArguments.hxx.in
@@ -62,6 +62,9 @@
CommandLineArguments();
~CommandLineArguments();
+ CommandLineArguments(const CommandLineArguments&) = delete;
+ CommandLineArguments& operator=(const CommandLineArguments&) = delete;
+
/**
* Various argument types.
*/
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 31b1c15..59530a4 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -102,7 +102,7 @@
# endif
char* buf;
size_t n = name.size();
- if (*name.rbegin() == '/' || *name.rbegin() == '\\') {
+ if (name.back() == '/' || name.back() == '\\') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
} else {
@@ -144,7 +144,7 @@
# endif
char* buf;
size_t n = name.size();
- if (*name.rbegin() == '/') {
+ if (name.back() == '/') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
} else {
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 6952d24..829c138 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -263,7 +263,7 @@
}
} else {
if (!this->Internals->Expressions.empty() &&
- this->Internals->Expressions.rbegin()->find(fname)) {
+ this->Internals->Expressions.back().find(fname)) {
this->AddFile(this->Internals->Files, realname);
}
}
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index bd4a176..4c3bde1 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -41,17 +41,9 @@
, content(c)
{
}
- Message(const Message& msg)
- : type(msg.type)
- , content(msg.content)
- {
- }
- Message& operator=(Message const& msg)
- {
- this->type = msg.type;
- this->content = msg.content;
- return *this;
- }
+ ~Message() = default;
+ Message(const Message& msg) = default;
+ Message& operator=(Message const& msg) = default;
};
typedef std::vector<Message> GlobMessages;
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index f323efc..4354753 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -4620,7 +4620,7 @@
// Run the application
kwsysProcess* gp = kwsysProcess_New();
- kwsysProcess_SetCommand(gp, &*args.begin());
+ kwsysProcess_SetCommand(gp, args.data());
kwsysProcess_SetOption(gp, kwsysProcess_Option_HideWindow, 1);
kwsysProcess_Execute(gp);
diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in
index 9e1ce6c..5e93878 100644
--- a/Source/kwsys/SystemInformation.hxx.in
+++ b/Source/kwsys/SystemInformation.hxx.in
@@ -56,6 +56,9 @@
SystemInformation();
~SystemInformation();
+ SystemInformation(const SystemInformation&) = delete;
+ SystemInformation& operator=(const SystemInformation&) = delete;
+
const char* GetVendorString();
const char* GetVendorID();
std::string GetTypeID();
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index cbdfe11..33a92e4 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -416,6 +416,9 @@
{
}
~Free() { free(const_cast<envchar*>(this->Env)); }
+
+ Free(const Free&) = delete;
+ Free& operator=(const Free&) = delete;
};
const envchar* Release(const envchar* env)
@@ -473,7 +476,7 @@
}
// A hack to make the below algorithm work.
- if (!pathEnv.empty() && *pathEnv.rbegin() != pathSep) {
+ if (!pathEnv.empty() && pathEnv.back() != pathSep) {
pathEnv += pathSep;
}
std::string::size_type start = 0;
@@ -1943,7 +1946,7 @@
// a single /
pathCString = path.c_str();
size_t size = path.size();
- if (size > 1 && *path.rbegin() == '/') {
+ if (size > 1 && path.back() == '/') {
// if it is c:/ then do not remove the trailing slash
if (!((size == 3 && pathCString[1] == ':'))) {
path.resize(size - 1);
@@ -2692,7 +2695,7 @@
for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
++i) {
std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
+ if (p.empty() || p.back() != '/') {
p += "/";
}
}
@@ -2810,7 +2813,7 @@
for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
++i) {
std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
+ if (p.empty() || p.back() != '/') {
p += "/";
}
}
@@ -2888,7 +2891,7 @@
for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
++i) {
std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
+ if (p.empty() || p.back() != '/') {
p += "/";
}
}
@@ -3234,10 +3237,10 @@
if (SystemTools::FileIsFullPath(path_b) &&
path_b.find("..") == std::string::npos) {
// Before inserting make sure path ends with '/'
- if (!path_a.empty() && *path_a.rbegin() != '/') {
+ if (!path_a.empty() && path_a.back() != '/') {
path_a += '/';
}
- if (!path_b.empty() && *path_b.rbegin() != '/') {
+ if (!path_b.empty() && path_b.back() != '/') {
path_b += '/';
}
if (!(path_a == path_b)) {
@@ -3446,7 +3449,7 @@
// between each entry that does not already have one
for (std::vector<std::string>::iterator vit1 = finalPath.begin();
vit1 != finalPath.end(); ++vit1) {
- if (!relativePath.empty() && *relativePath.rbegin() != '/') {
+ if (!relativePath.empty() && relativePath.back() != '/') {
relativePath += "/";
}
relativePath += *vit1;
@@ -3648,7 +3651,7 @@
}
#endif
if (!homedir.empty() &&
- (*homedir.rbegin() == '/' || *homedir.rbegin() == '\\')) {
+ (homedir.back() == '/' || homedir.back() == '\\')) {
homedir.resize(homedir.size() - 1);
}
SystemTools::SplitPath(homedir, components);
@@ -4016,7 +4019,7 @@
filename_dir = SystemTools::GetFilenamePath(filename_dir);
filename_dir_base = SystemTools::GetFilenameName(filename_dir);
#if defined(_WIN32)
- if (filename_dir_base.empty() || *filename_dir_base.rbegin() == ':')
+ if (filename_dir_base.empty() || filename_dir_base.back() == ':')
#else
if (filename_dir_base.empty())
#endif
@@ -4092,7 +4095,7 @@
std::string tempPath = path; // create a buffer
// if the path passed in has quotes around it, first remove the quotes
- if (!path.empty() && path[0] == '"' && *path.rbegin() == '"') {
+ if (!path.empty() && path[0] == '"' && path.back() == '"') {
tempPath = path.substr(1, path.length() - 2);
}
@@ -4169,7 +4172,7 @@
bool haveData = !line.empty() || !is.eof();
if (!line.empty()) {
// Avoid storing a carriage return character.
- if (*line.rbegin() == '\r') {
+ if (line.back() == '\r') {
line.resize(line.size() - 1);
}
@@ -4307,7 +4310,7 @@
if (subdir.size() <= dir.size() || dir.empty()) {
return false;
}
- bool isRootPath = *dir.rbegin() == '/'; // like "/" or "C:/"
+ bool isRootPath = dir.back() == '/'; // like "/" or "C:/"
size_t expectedSlashPosition = isRootPath ? dir.size() - 1u : dir.size();
if (subdir[expectedSlashPosition] != '/') {
return false;
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 1967860..33b579f 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -54,6 +54,9 @@
public:
SystemToolsManager();
~SystemToolsManager();
+
+ SystemToolsManager(const SystemToolsManager&) = delete;
+ SystemToolsManager& operator=(const SystemToolsManager&) = delete;
};
// This instance will show up in any translation unit that uses
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index fc0d60e..0981c66 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -73,7 +73,7 @@
void public_method_to_quiet_warning_about_all_methods_private();
private:
- void operator=(_Hashtable_node<_Val> const&); // poison node assignment
+ void operator=(_Hashtable_node<_Val> const&) = delete;
};
template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 40e53a2..3245f3e 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3272,12 +3272,14 @@
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
)
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
- add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
- -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
- --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
- )
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
+ add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
+ -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
+ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
+ )
+ endif()
if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
@@ -3309,11 +3311,13 @@
PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
endif ()
- get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
- if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
- set_tests_properties ( CTestTest2
- PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
- endif ()
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
+ if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
+ set_tests_properties ( CTestTest2
+ PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
+ endif()
+ endif()
endif ()
if(CMake_TEST_EXTERNAL_CMAKE)
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index 616092d..b584e16 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -128,7 +128,8 @@
endif()
# for msvc the compiler version determines which c++11 features are available.
-if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
index f4b726f..9b32e59 100644
--- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
+++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
@@ -5,10 +5,48 @@
# Dummy executable to generate a clean target
add_executable(dummy dummy.cpp)
-set(timeformat "%Y%j%H%M%S")
+# Utility variables
+set(timeformat "%Y.%j.%H.%M%S")
set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic")
set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic")
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(acquire_timestamp When)
+ file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}")
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName}.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} failed.")
+ else()
+ message(STATUS "Build ${buildName} finished.")
+ endif()
+endmacro()
+
+macro(require_change)
+ if (timeAfter VERSION_GREATER timeBefore)
+ message(STATUS "As expected the file ${mocBasicBin} changed.")
+ else()
+ message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n")
+ endif()
+endmacro()
+
+macro(require_change_not)
+ if (timeAfter VERSION_GREATER timeBefore)
+ message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n")
+ else()
+ message(STATUS "As expected the file ${mocBasicBin} did not change.")
+ endif()
+endmacro()
+
+
# Initial build
configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
try_compile(MOC_RERUN
@@ -21,46 +59,44 @@
OUTPUT_VARIABLE output
)
if (NOT MOC_RERUN)
- message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}")
+ message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}")
endif()
+
# Get name of the output binary
file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8)
list(GET mocBasicList 0 mocBasicBin)
-message("Changing the header content for a MOC rerun")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}")
+# To avoid a race condition where the binary has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - touch binary to ensure it has a new timestamp
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Touching binary file to ensure a new timestamps")
+file(TOUCH_NOCREATE "${mocBasicBin}")
+acquire_timestamp(After)
+require_change()
+
+
# - Ensure that the timestamp will change
-# - Change header file content and rebuild
+# - Change header file content
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Changing the header content for a MOC re-run")
configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result )
-if (result)
- message(SEND_ERROR "Second build of mocBasic failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}")
-# - Test if timestamps changed
-if (NOT timeAfter GREATER timeBefore)
- message(SEND_ERROR "File (${mocBasicBin}) should have changed!")
-endif()
+sleep()
+rebuild(2)
+acquire_timestamp(After)
+require_change()
-message("Changing nothing for a MOC rerun")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}")
# - Ensure that the timestamp would change
# - Change nothing
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result )
-if (result)
- message(SEND_ERROR "Third build of mocBasic failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}")
-# - Test if timestamps changed
-if (timeAfter GREATER timeBefore)
- message(SEND_ERROR "File (${mocBasicBin}) should not have changed!")
-endif()
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Changing nothing for no MOC re-run")
+rebuild(3)
+acquire_timestamp(After)
+require_change_not()
diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt
index b83e994..6ab9538 100644
--- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt
+++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt
@@ -9,10 +9,53 @@
add_executable(dummy dummy.cpp)
# Utility variables
-set(timeformat "%Y%j%H%M%S")
+set(timeformat "%Y.%j.%H.%M%S")
set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin")
set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin")
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName}.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} failed.")
+ else()
+ message(STATUS "Build ${buildName} finished.")
+ endif()
+endmacro()
+
+macro(require_change PLG)
+ if (pl${PLG}After VERSION_GREATER pl${PLG}Before)
+ message(STATUS "As expected the file ${pl${PLG}File} changed.")
+ else()
+ message(SEND_ERROR
+ "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n")
+ endif()
+endmacro()
+
+macro(require_change_not PLG)
+ if (pl${PLG}After VERSION_GREATER pl${PLG}Before)
+ message(SEND_ERROR
+ "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n")
+ else()
+ message(STATUS "As expected the file ${pl${PLG}File} did not change.")
+ endif()
+endmacro()
+
+macro(acquire_timestamps When)
+ file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}")
+ file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}")
+ file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}")
+ file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}")
+ file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}")
+endmacro()
+
+
# Initial build
try_compile(MOC_PLUGIN
"${mocPlugBinDir}"
@@ -24,83 +67,75 @@
OUTPUT_VARIABLE output
)
if (NOT MOC_PLUGIN)
- message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
+ message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}")
endif()
+# Get names of the output binaries
find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+# To avoid a race condition where the library has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - touch library to ensure it has a new timestamp
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Touching library files to ensure new timestamps")
+file(TOUCH_NOCREATE "${plAFile}" "${plBFile}" "${plCFile}" "${plDFile}" "${plEFile}")
+acquire_timestamps(After)
+require_change(A)
+require_change(B)
+require_change(C)
+require_change(D)
+require_change(E)
+
+
# - Ensure that the timestamp will change.
# - Change the json files referenced by Q_PLUGIN_METADATA
# - Rebuild
-file(TIMESTAMP "${plAFile}" plABefore "${timeformat}")
-file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}")
-file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
-file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
-file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
-
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing json files")
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
+sleep()
+rebuild(2)
+acquire_timestamps(After)
+# Test changes
+require_change_not(A)
+require_change_not(B)
+require_change(C)
+require_change(D)
+# There's a bug in Ninja on Windows:
+# https://gitlab.kitware.com/cmake/cmake/issues/16776
+if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
+ require_change(E)
+endif()
-file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}")
-file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}")
-file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
-file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
-file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
-
-if (plAAfter GREATER plABefore)
- message(SEND_ERROR "file (${plAFile}) should not have changed!")
-endif()
-if (plBAfter GREATER plBBefore)
- message(SEND_ERROR "file (${plBFile}) should not have changed!")
-endif()
-if (NOT plCAfter GREATER plCBefore)
- message(SEND_ERROR "file (${plCFile}) should have changed!")
-endif()
-if (NOT plDAfter GREATER plDBefore)
- message(SEND_ERROR "file (${plDFile}) should have changed!")
-endif()
-if (NOT plEAfter GREATER plEBefore)
- # There's a bug in Ninja on Windows
- # https://gitlab.kitware.com/cmake/cmake/issues/16776
- if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
- message(SEND_ERROR "file (${plEFile}) should have changed!")
- endif()
-endif()
# - Ensure that the timestamp will change.
# - Change the json files referenced by A_CUSTOM_MACRO
# - Rebuild
-file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
-file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
-file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}")
-
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing json files")
configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
-
-file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
-file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
-file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}")
-
-if (NOT plCAfter GREATER plCBefore)
- message(SEND_ERROR "file (${plCFile}) should have changed!")
-endif()
-if (NOT plDAfter GREATER plDBefore)
- message(SEND_ERROR "file (${plDFile}) should have changed!")
-endif()
-if (NOT plEAfter GREATER plEBefore)
- # There's a bug in Ninja on Windows
- # https://gitlab.kitware.com/cmake/cmake/issues/16776
- if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
- message(SEND_ERROR "file (${plEFile}) should have changed!")
- endif()
+sleep()
+rebuild(3)
+acquire_timestamps(After)
+# Test changes
+require_change_not(A)
+require_change_not(B)
+require_change(C)
+require_change(D)
+# There's a bug in Ninja on Windows
+# https://gitlab.kitware.com/cmake/cmake/issues/16776
+if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
+ require_change(E)
endif()
diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt
index dcb7a79..33c01ac 100644
--- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt
+++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt
@@ -9,10 +9,23 @@
# When a .qrc or a file listed in a .qrc file changes,
# the target must be rebuilt
-set(timeformat "%Y%j%H%M%S")
set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange")
set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange")
+# Rebuild macro
+macro(rebuild CFG)
+ message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}"
+ WORKING_DIRECTORY "${rccDepBD}"
+ RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "${CFG} build of rccConfigChange failed.")
+ else()
+ message(STATUS "${CFG} build of rccConfigChange finished.")
+ endif()
+endmacro()
+
# Initial build
try_compile(RCC_DEPENDS
"${rccDepBD}"
@@ -24,19 +37,11 @@
OUTPUT_VARIABLE output
)
if (NOT RCC_DEPENDS)
- message(SEND_ERROR "Initial build of rccConfigChange failed. Output: ${output}")
+ message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}")
endif()
-# - Rebuild Release
-message("Rebuilding rccConfigChange in Release configuration")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Release build of rccConfigChange failed.")
-endif()
+# Rebuild: Release
+rebuild(Release)
-# - Rebuild Debug
-message("Rebuilding rccConfigChange in Debug configuration")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Debug build of rccConfigChange failed.")
-endif()
+# Rebuild: Debug
+rebuild(Debug)
diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
index 80c5cf0..1301550 100644
--- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
@@ -3,19 +3,63 @@
include("../AutogenCoreTest.cmake")
# Tests rcc rebuilding when a resource file changes
+# When a .qrc or a file listed in a .qrc file changes,
+# the target must be rebuilt
# Dummy executable to generate a clean target
add_executable(dummy dummy.cpp)
-# When a .qrc or a file listed in a .qrc file changes,
-# the target must be rebuilt
-set(timeformat "%Y%j%H%M%S")
+# Utility variables
+set(timeformat "%Y.%j.%H.%M%S")
set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends")
set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends")
-# Initial build
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(acquire_timestamps When)
+ file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}")
+ file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}")
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName} of rccDepends.")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" --build .
+ WORKING_DIRECTORY "${rccDepBD}"
+ RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} of rccDepends failed.")
+ else()
+ message(STATUS "Build ${buildName} of rccDepends finished.")
+ endif()
+endmacro()
+
+macro(require_change type)
+ if (rd${type}After VERSION_GREATER rd${type}Before)
+ message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.")
+ else()
+ message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n")
+ endif()
+endmacro()
+
+macro(require_change_not type)
+ if (rd${type}After VERSION_GREATER rd${type}Before)
+ message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n")
+ else()
+ message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.")
+ endif()
+endmacro()
+
+
+# Initial configuration
configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
+
+# Initial build
try_compile(RCC_DEPENDS
"${rccDepBD}"
"${rccDepSD}"
@@ -26,113 +70,84 @@
OUTPUT_VARIABLE output
)
if (NOT RCC_DEPENDS)
- message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
+ message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}")
endif()
# Get name of the output binaries
file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8)
file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8)
list(GET targetListPlain 0 rccDepBinPlain)
-list(GET targetListGen 0 rccDepBinGen)
-message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
-message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}")
+list(GET targetListGen 0 rccDepBinGenerated)
+message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
+message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}")
+
+# To avoid a race condition where the binary has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - touch binary to ensure it has a new timestamp
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Touching binary files to ensure new timestamps")
+file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}")
+acquire_timestamps(After)
+require_change(Plain)
+require_change(Generated)
-message("Changing a resource files listed in the .qrc file")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
# - Ensure that the timestamp will change
# - Change a resource files listed in the .qrc file
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing a resource file listed in the .qrc file")
file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Second build of rccDepends failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+sleep()
+rebuild(2)
+acquire_timestamps(After)
# - Test if timestamps changed
-if (NOT rdPlainAfter GREATER rdPlainBefore)
- message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
-endif()
-if (NOT rdGenAfter GREATER rdGenBefore)
- message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
-endif()
+require_change(Plain)
+require_change(Generated)
-message("Changing the .qrc file")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
# - Ensure that the timestamp will change
# - Change the .qrc file
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing the .qrc file")
configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Third build of rccDepends failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+sleep()
+rebuild(3)
+acquire_timestamps(After)
# - Test if timestamps changed
-if (NOT rdPlainAfter GREATER rdPlainBefore)
- message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
-endif()
-if (NOT rdGenAfter GREATER rdGenBefore)
- message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
-endif()
+require_change(Plain)
+require_change(Generated)
-message("Changing a newly added resource files listed in the .qrc file")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
# - Ensure that the timestamp will change
# - Change a newly added resource files listed in the .qrc file
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing a newly added resource file listed in the .qrc file")
file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Fourth build of rccDepends failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+sleep()
+rebuild(4)
+acquire_timestamps(After)
# - Test if timestamps changed
-if (NOT rdPlainAfter GREATER rdPlainBefore)
- message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!")
-endif()
-if (NOT rdGenAfter GREATER rdGenBefore)
- message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!")
-endif()
+require_change(Plain)
+require_change(Generated)
-message("Changing nothing in the .qrc file")
-# - Acquire binary timestamps before the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}")
# - Ensure that the timestamp will change
# - Change nothing
# - Rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Fifth build of rccDepends failed.")
-endif()
-# - Acquire binary timestamps after the build
-file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}")
-file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}")
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing nothing in the .qrc file")
+rebuild(5)
+acquire_timestamps(After)
# - Test if timestamps changed
-if (rdPlainAfter GREATER rdPlainBefore)
- message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!")
-endif()
-if (rdGenAfter GREATER rdGenBefore)
- message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!")
-endif()
+require_change_not(Plain)
+require_change_not(Generated)
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 184a7be..54e96a2 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -165,6 +165,35 @@
OUTPUT_VARIABLE output)
TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}")
+try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/check_a_b.c
+ OUTPUT_VARIABLE output
+ COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B"
+ )
+if(COMPILE_DEFINITIONS_LIST_EXPANDED)
+ message(STATUS "COMPILE_DEFINITIONS list expanded correctly")
+else()
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "COMPILE_DEFINITIONS list did not expand correctly\n${output}")
+endif()
+
+try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/pass.c
+ OUTPUT_VARIABLE output
+ COMPILE_DEFINITIONS "bad#source.c"
+ )
+if(SHOULD_FAIL_DUE_TO_BAD_SOURCE AND NOT CMAKE_GENERATOR MATCHES "Watcom WMake|NMake Makefiles")
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "try_compile with bad#source.c did not fail:\n${output}")
+elseif(NOT output MATCHES [[(bad#source\.c|bad\\)]])
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "try_compile with bad#source.c failed without mentioning bad source:\n${output}")
+else()
+ message(STATUS "try_compile with bad#source.c correctly failed")
+endif()
+
add_executable(TryCompile pass.c)
######################################
diff --git a/Tests/TryCompile/check_a_b.c b/Tests/TryCompile/check_a_b.c
new file mode 100644
index 0000000..05fba0f
--- /dev/null
+++ b/Tests/TryCompile/check_a_b.c
@@ -0,0 +1,10 @@
+#ifndef DEF_A
+# error DEF_A not defined
+#endif
+#ifndef DEF_B
+# error DEF_B not defined
+#endif
+int main()
+{
+ return 0;
+}