diff options
35 files changed, 291 insertions, 152 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 94d138c..c96f68b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) endif() +if(POLICY CMP0053) + cmake_policy(SET CMP0053 NEW) +endif() project(CMake) if(CMAKE_BOOTSTRAP) diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 189c3ef..13ee4bd 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -278,3 +278,7 @@ Available output expressions are: object of type ``OBJECT_LIBRARY``. This expression may only be used in the sources of :command:`add_library` and :command:`add_executable` commands. +``$<SHELL_PATH:...>`` + Content of ``...`` converted to shell path style. For example, slashes are + converted to backslashes in Windows shells and drive letters are converted + to posix paths in MSYS shells. The ``...`` must be an absolute path. diff --git a/Help/release/dev/genex-SHELL_PATH.rst b/Help/release/dev/genex-SHELL_PATH.rst new file mode 100644 index 0000000..86af720 --- /dev/null +++ b/Help/release/dev/genex-SHELL_PATH.rst @@ -0,0 +1,6 @@ +genex-SHELL_PATH +---------------- + +* A new ``$<SHELL_PATH:...>`` + :manual:`generator expression <cmake-generator-expressions(7)>` + has been added. diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ceaf0c7..7f240bc 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 3) -set(CMake_VERSION_PATCH 20150927) +set(CMake_VERSION_PATCH 20150928) #set(CMake_VERSION_RC 1) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 31b6766..1c350ab 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorExpressionNode.h" #include "cmGlobalGenerator.h" #include "cmAlgorithms.h" +#include "cmOutputConverter.h" //---------------------------------------------------------------------------- std::string cmGeneratorExpressionNode::EvaluateDependentExpression( @@ -1792,6 +1793,27 @@ static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup; //---------------------------------------------------------------------------- +static const struct ShellPathNode : public cmGeneratorExpressionNode +{ + ShellPathNode() {} + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + if (!cmSystemTools::FileIsFullPath(parameters.front())) + { + reportError(context, content->GetOriginalExpression(), + "\"" + parameters.front() + "\" is not an absolute path."); + return std::string(); + } + cmOutputConverter converter(context->Makefile->GetStateSnapshot()); + return converter.ConvertDirectorySeparatorsForShell(parameters.front()); + } +} shellPathNode; + +//---------------------------------------------------------------------------- const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(const std::string &identifier) { @@ -1846,6 +1868,7 @@ cmGeneratorExpressionNode::GetNode(const std::string &identifier) nodeMap["JOIN"] = &joinNode; nodeMap["LINK_ONLY"] = &linkOnlyNode; nodeMap["COMPILE_LANGUAGE"] = &languageNode; + nodeMap["SHELL_PATH"] = &shellPathNode; } NodeMap::const_iterator i = nodeMap.find(identifier); if (i == nodeMap.end()) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 120bb03..9d8193b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -818,6 +818,17 @@ void cmGlobalNinjaGenerator::CloseRulesFileStream() } } +std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(const std::string& path) +{ + cmLocalNinjaGenerator *ng = + static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); + std::string convPath = ng->Convert(path, cmOutputConverter::HOME_OUTPUT); +#ifdef _WIN32 + cmSystemTools::ReplaceString(convPath, "/", "\\"); +#endif + return convPath; +} + void cmGlobalNinjaGenerator::AddCXXCompileCommand( const std::string &commandLine, const std::string &sourceFile) @@ -907,8 +918,6 @@ cmGlobalNinjaGenerator { std::string configName = target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmLocalNinjaGenerator *ng = - static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); // for frameworks, we want the real name, not smple name // frameworks always appear versioned, and the build.ninja @@ -923,13 +932,13 @@ cmGlobalNinjaGenerator case cmTarget::MODULE_LIBRARY: { cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); - outputs.push_back(ng->ConvertToNinjaPath( + outputs.push_back(this->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; } case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: { - std::string path = ng->ConvertToNinjaPath( + std::string path = this->ConvertToNinjaPath( target->GetMakefile()->GetCurrentBinaryDirectory()); if (path.empty() || path == ".") outputs.push_back(target->GetName()); @@ -1041,8 +1050,6 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) //get the list of files that cmake itself has generated as a //product of configuration. - cmLocalNinjaGenerator *ng = - static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]); for (std::vector<cmLocalGenerator *>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) @@ -1054,7 +1061,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = files.begin(); j != files.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } //get list files which are implicit dependencies as well and will be phony //for rebuild manifest @@ -1062,7 +1069,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) typedef std::vector<std::string>::const_iterator vect_it; for(vect_it j = lf.begin(); j != lf.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } std::vector<cmGeneratorExpressionEvaluationFile*> const& ef = (*i)->GetMakefile()->GetEvaluationFiles(); @@ -1074,7 +1081,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) std::vector<std::string> evaluationFiles = (*li)->GetFiles(); for(vect_it j = evaluationFiles.begin(); j != evaluationFiles.end(); ++j) { - knownDependencies.insert( ng->ConvertToNinjaPath( *j ) ); + knownDependencies.insert( this->ConvertToNinjaPath( *j ) ); } } } @@ -1084,7 +1091,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->TargetAliases.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); + knownDependencies.insert( this->ConvertToNinjaPath(i->first) ); } //remove all source files we know will exist. @@ -1093,7 +1100,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) i != this->AssumedSourceDependencies.end(); ++i) { - knownDependencies.insert( ng->ConvertToNinjaPath(i->first) ); + knownDependencies.insert( this->ConvertToNinjaPath(i->first) ); } //now we difference with CombinedCustomCommandExplicitDependencies to find @@ -1214,8 +1221,6 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*restat=*/ "", /*generator=*/ true); - cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg); - cmNinjaDeps implicitDeps; for(std::vector<cmLocalGenerator*>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) @@ -1224,7 +1229,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) for(std::vector<std::string>::const_iterator fi = lf.begin(); fi != lf.end(); ++fi) { - implicitDeps.push_back(ng->ConvertToNinjaPath(*fi)); + implicitDeps.push_back(this->ConvertToNinjaPath(*fi)); } } implicitDeps.push_back("CMakeCache.txt"); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index d204a50..292f7c7 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -220,6 +220,19 @@ public: cmGeneratedFileStream* GetRulesFileStream() const { return this->RulesFileStream; } + std::string ConvertToNinjaPath(const std::string& path); + + struct MapToNinjaPathImpl { + cmGlobalNinjaGenerator* GG; + MapToNinjaPathImpl(cmGlobalNinjaGenerator* gg): GG(gg) {} + std::string operator()(std::string const& path) { + return this->GG->ConvertToNinjaPath(path); + } + }; + MapToNinjaPathImpl MapToNinjaPath() { + return MapToNinjaPathImpl(this); + } + void AddCXXCompileCommand(const std::string &commandLine, const std::string &sourceFile); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7525bf2..c46adc1 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -284,15 +284,6 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) os << std::endl; } -std::string cmLocalNinjaGenerator::ConvertToNinjaPath(const std::string& path) -{ - std::string convPath = this->Convert(path, cmLocalGenerator::HOME_OUTPUT); -#ifdef _WIN32 - cmSystemTools::ReplaceString(convPath, "/", "\\"); -#endif - return convPath; -} - void cmLocalNinjaGenerator ::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs) @@ -316,7 +307,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps( i != deps.end(); ++i) { std::string dep; if (this->GetRealDependency(*i, this->GetConfigName(), dep)) - ninjaDeps.push_back(ConvertToNinjaPath(dep)); + ninjaDeps.push_back( + this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep)); } } @@ -413,9 +405,11 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( at us. How to know which ExternalProject step actually provides it? #endif std::transform(outputs.begin(), outputs.end(), - ninjaOutputs.begin(), MapToNinjaPath()); + ninjaOutputs.begin(), + this->GetGlobalNinjaGenerator()->MapToNinjaPath()); std::transform(byproducts.begin(), byproducts.end(), - ninjaOutputs.begin() + outputs.size(), MapToNinjaPath()); + ninjaOutputs.begin() + outputs.size(), + this->GetGlobalNinjaGenerator()->MapToNinjaPath()); this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8d3d49c..1645a8d 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -50,21 +50,6 @@ public: std::string GetHomeRelativeOutputPath() const { return this->HomeRelativeOutputPath; } - std::string ConvertToNinjaPath(const std::string& path); - - struct map_to_ninja_path { - cmLocalNinjaGenerator *LocalGenerator; - map_to_ninja_path(cmLocalNinjaGenerator *LocalGen) - : LocalGenerator(LocalGen) {} - std::string operator()(const std::string &path) { - return LocalGenerator->ConvertToNinjaPath(path); - } - }; - - map_to_ninja_path MapToNinjaPath() { - return map_to_ninja_path(this); - } - void ExpandRuleVariables(std::string& string, const RuleVariables& replaceValues) { cmLocalGenerator::ExpandRuleVariables(string, replaceValues); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6d96af5..84c19a3 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -583,7 +583,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } const std::string objPath = GetTarget()->GetSupportDirectory(); - vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath); + vars["OBJECT_DIR"] = + this->GetLocalGenerator()->ConvertToOutputFormat( + this->ConvertToNinjaPath(objPath), cmLocalGenerator::SHELL); EnsureDirectoryExists(objPath); if (this->GetGlobalGenerator()->IsGCCOnWindows()) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index f46c5b9..6e6dc60 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -771,14 +771,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( // Get the input file location. std::string input = source.GetFullPath(); input = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input); + this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input); // Get the output file location. std::string output = macdir; output += "/"; output += cmSystemTools::GetFilenameName(input); output = - this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output); + this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output); // Write a build statement to copy the content into the bundle. this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index a10ceba..0267f63 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -17,11 +17,11 @@ #include "cmStandardIncludes.h" #include "cmNinjaTypes.h" +#include "cmGlobalNinjaGenerator.h" #include "cmLocalNinjaGenerator.h" #include "cmOSXBundleGenerator.h" class cmTarget; -class cmGlobalNinjaGenerator; class cmGeneratedFileStream; class cmGeneratorTarget; class cmMakefile; @@ -87,10 +87,10 @@ protected: const std::string& language); std::string ConvertToNinjaPath(const std::string& path) const { - return this->GetLocalGenerator()->ConvertToNinjaPath(path); + return this->GetGlobalGenerator()->ConvertToNinjaPath(path); } - cmLocalNinjaGenerator::map_to_ninja_path MapToNinjaPath() const { - return this->GetLocalGenerator()->MapToNinjaPath(); + cmGlobalNinjaGenerator::MapToNinjaPathImpl MapToNinjaPath() const { + return this->GetGlobalGenerator()->MapToNinjaPath(); } /// @return the list of link dependency for the given target @a target. diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 7be5b3f..5acae2f 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -142,21 +142,7 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source, } else if(output == SHELL || output == WATCOMQUOTE) { - // For the MSYS shell convert drive letters to posix paths, so - // that c:/some/path becomes /c/some/path. This is needed to - // avoid problems with the shell path translation. - if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell) - { - if(result.size() > 2 && result[1] == ':') - { - result[1] = result[0]; - result[0] = '/'; - } - } - if(this->GetState()->UseWindowsShell()) - { - std::replace(result.begin(), result.end(), '/', '\\'); - } + result = this->ConvertDirectorySeparatorsForShell(source); result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE); } else if(output == RESPONSE) @@ -167,6 +153,29 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source, } //---------------------------------------------------------------------------- +std::string cmOutputConverter::ConvertDirectorySeparatorsForShell( + const std::string& source) const +{ + std::string result = source; + // For the MSYS shell convert drive letters to posix paths, so + // that c:/some/path becomes /c/some/path. This is needed to + // avoid problems with the shell path translation. + if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell) + { + if(result.size() > 2 && result[1] == ':') + { + result[1] = result[0]; + result[0] = '/'; + } + } + if(this->GetState()->UseWindowsShell()) + { + std::replace(result.begin(), result.end(), '/', '\\'); + } + return result; +} + +//---------------------------------------------------------------------------- std::string cmOutputConverter::Convert(RelativeRoot remote, const std::string& local, OutputFormat output, diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index ed7739e..852df5d 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -45,6 +45,8 @@ public: std::string Convert(RelativeRoot remote, const std::string& local, OutputFormat output = UNCHANGED, bool optional = false) const; + std::string ConvertDirectorySeparatorsForShell( + const std::string& source) const; /** * Get path for the specified relative root. diff --git a/Source/kwsys/CTestCustom.cmake.in b/Source/kwsys/CTestCustom.cmake.in index d6f802e..760221b 100644 --- a/Source/kwsys/CTestCustom.cmake.in +++ b/Source/kwsys/CTestCustom.cmake.in @@ -9,7 +9,6 @@ # resulting memory leaks are not logged by valgrind anyway. Therefore, we # don't have to exclude it. -set(CTEST_CUSTOM_MEMCHECK_IGNORE - ${CTEST_CUSTOM_MEMCHECK_IGNORE} +list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE kwsys.testProcess-10 ) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 3857e41..80289b8 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -2365,95 +2365,102 @@ bool SystemTools::CopyFileAlways(const std::string& source, const std::string& d } mode_t perm = 0; bool perms = SystemTools::GetPermissions(source, perm); - - const int bufferSize = 4096; - char buffer[bufferSize]; - - // If destination is a directory, try to create a file with the same - // name as the source in that directory. - std::string real_destination = destination; - std::string destination_dir; - if(SystemTools::FileExists(destination) && - SystemTools::FileIsDirectory(destination)) + + if(SystemTools::FileIsDirectory(source)) { - destination_dir = real_destination; - SystemTools::ConvertToUnixSlashes(real_destination); - real_destination += '/'; - std::string source_name = source; - real_destination += SystemTools::GetFilenameName(source_name); + SystemTools::MakeDirectory(destination); } else { - destination_dir = SystemTools::GetFilenamePath(destination); - } + const int bufferSize = 4096; + char buffer[bufferSize]; + + // If destination is a directory, try to create a file with the same + // name as the source in that directory. + + std::string destination_dir; + if(SystemTools::FileExists(destination) && + SystemTools::FileIsDirectory(destination)) + { + destination_dir = real_destination; + SystemTools::ConvertToUnixSlashes(real_destination); + real_destination += '/'; + std::string source_name = source; + real_destination += SystemTools::GetFilenameName(source_name); + } + else + { + destination_dir = SystemTools::GetFilenamePath(destination); + } - // Create destination directory + // Create destination directory - SystemTools::MakeDirectory(destination_dir); + SystemTools::MakeDirectory(destination_dir); - // Open files + // Open files #if defined(_WIN32) - kwsys::ifstream fin(Encoding::ToNarrow( - SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), - std::ios::in | std::ios::binary); + kwsys::ifstream fin(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(source)).c_str(), + std::ios::in | std::ios::binary); #else - kwsys::ifstream fin(source.c_str(), - std::ios::in | std::ios::binary); + kwsys::ifstream fin(source.c_str(), + std::ios::in | std::ios::binary); #endif - if(!fin) - { - return false; - } + if(!fin) + { + return false; + } - // try and remove the destination file so that read only destination files - // can be written to. - // If the remove fails continue so that files in read only directories - // that do not allow file removal can be modified. - SystemTools::RemoveFile(real_destination); + // try and remove the destination file so that read only destination files + // can be written to. + // If the remove fails continue so that files in read only directories + // that do not allow file removal can be modified. + SystemTools::RemoveFile(real_destination); #if defined(_WIN32) - kwsys::ofstream fout(Encoding::ToNarrow( - SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), + kwsys::ofstream fout(Encoding::ToNarrow( + SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #else - kwsys::ofstream fout(real_destination.c_str(), + kwsys::ofstream fout(real_destination.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); #endif - if(!fout) - { - return false; - } - - // This copy loop is very sensitive on certain platforms with - // slightly broken stream libraries (like HPUX). Normally, it is - // incorrect to not check the error condition on the fin.read() - // before using the data, but the fin.gcount() will be zero if an - // error occurred. Therefore, the loop should be safe everywhere. - while(fin) - { - fin.read(buffer, bufferSize); - if(fin.gcount()) + if(!fout) { - fout.write(buffer, fin.gcount()); + return false; } - else + + // This copy loop is very sensitive on certain platforms with + // slightly broken stream libraries (like HPUX). Normally, it is + // incorrect to not check the error condition on the fin.read() + // before using the data, but the fin.gcount() will be zero if an + // error occurred. Therefore, the loop should be safe everywhere. + while(fin) { - break; + fin.read(buffer, bufferSize); + if(fin.gcount()) + { + fout.write(buffer, fin.gcount()); + } + else + { + break; + } } - } - // Make sure the operating system has finished writing the file - // before closing it. This will ensure the file is finished before - // the check below. - fout.flush(); + // Make sure the operating system has finished writing the file + // before closing it. This will ensure the file is finished before + // the check below. + fout.flush(); - fin.close(); - fout.close(); + fin.close(); + fout.close(); - if(!fout) - { - return false; + if(!fout) + { + return false; + } } if ( perms ) { diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index a3f1f81..aedc89b 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -136,7 +136,7 @@ add_library(testLibDepends testLibDepends.c) target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired) macro(add_include_lib _libName) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "// no content\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n") add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_libName}") set_property(TARGET ${_libName} APPEND PROPERTY @@ -144,7 +144,7 @@ macro(add_include_lib _libName) "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${_libName}>" ) if (NOT "${ARGV1}" STREQUAL "NO_HEADER") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "// no content\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "/* no content */\n") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" DESTINATION include/${_libName} @@ -182,7 +182,7 @@ install(FILES ) add_include_lib(testLibIncludeRequired6) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired7/testLibIncludeRequired7.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired7/testLibIncludeRequired7.h" "/* No content */\n") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired7/testLibIncludeRequired7.h" DESTINATION include/testLibIncludeRequired7 @@ -391,22 +391,22 @@ install(TARGETS install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest2/installIncludesTest2.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired/installIncludesTest3.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest3/testLibRequired/installIncludesTest3.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4/installIncludesTest4.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibRequired/installIncludesTest4/installIncludesTest4.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5/installIncludesTest5.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest5/installIncludesTest5.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6/installIncludesTest6.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest6/installIncludesTest6.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7/installIncludesTest7.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest7/installIncludesTest7.h" "/* No content */\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8/installIncludesTest8.h" "// No content\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest8/installIncludesTest8.h" "/* No content */\n") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/installIncludesTest/installIncludesTest.h" DESTINATION installIncludesTest diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 758165c..27f33a2 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -66,7 +66,7 @@ add_custom_target(check-part1 ALL -Dtest_colons_4=$<1:C:\\CMake> -Dtest_colons_5=$<1:C:/CMake> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 3)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)" VERBATIM ) @@ -137,7 +137,7 @@ add_custom_target(check-part2 ALL -Dtest_arbitrary_content_comma_9=$<1:a,,b,,> -Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 3)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)" VERBATIM ) @@ -221,7 +221,27 @@ add_custom_target(check-part3 ALL -Dequal22=$<EQUAL:10,-012> -Dequal23=$<EQUAL:-10,-012> -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake - COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)" + VERBATIM + ) + +if(WIN32) + set(test_shell_path c:/shell/path) +else() + set(test_shell_path /shell/path) +endif() +set(path_prefix BYPASS_FURTHER_CONVERSION) + +add_custom_target(check-part4 ALL + COMMAND ${CMAKE_COMMAND} + # Prefix path to bypass its further conversion when being processed by + # CMake as command-line argument + -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}> + -Dpath_prefix=${path_prefix} + -DWIN32=${WIN32} + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake + COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)" VERBATIM ) diff --git a/Tests/GeneratorExpression/check-common.cmake b/Tests/GeneratorExpression/check-common.cmake index 8ffebd7..faf5d4f 100644 --- a/Tests/GeneratorExpression/check-common.cmake +++ b/Tests/GeneratorExpression/check-common.cmake @@ -1,5 +1,5 @@ -macro(check var val) +function(check var val) if(NOT "${${var}}" STREQUAL "${val}") message(SEND_ERROR "${var} is \"${${var}}\", not \"${val}\"") endif() -endmacro() +endfunction() diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 3207582..60b193f 100644 --- a/Tests/GeneratorExpression/check-part1.cmake +++ b/Tests/GeneratorExpression/check-part1.cmake @@ -55,5 +55,5 @@ check(test_semicolon ";") check(test_colons_1 ":") check(test_colons_2 "::") check(test_colons_3 "Qt5::Core") -check(test_colons_4 "C:\\\\CMake") +check(test_colons_4 [[C:\CMake]]) check(test_colons_5 "C:/CMake") diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake new file mode 100644 index 0000000..9e516d5 --- /dev/null +++ b/Tests/GeneratorExpression/check-part4.cmake @@ -0,0 +1,15 @@ +include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake) + +string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path}) + +if(WIN32) + if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") + check(test_shell_path [[/c/shell/path]]) + elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + check(test_shell_path [[c:/shell/path]]) + else() + check(test_shell_path [[c:\shell\path]]) + endif() +else() + check(test_shell_path [[/shell/path]]) +endif() diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 8e2bd0a..5b99ea7 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -5,7 +5,7 @@ project(TargetIncludeDirectories) macro(create_header _name) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" "//${_name}.h\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" "/* ${_name}.h */\n") endmacro() create_header(bar) @@ -88,7 +88,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bad/common.h" "#error Should not be incl file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/good") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/good/common.h" "#include \"othergood.h\"\n") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/othergood") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/othergood/othergood.h" "// No error\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/othergood/othergood.h" "/* No error */\n") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libothergood.cpp" "// No content \n") add_library(libothergood "${CMAKE_CURRENT_BINARY_DIR}/libothergood.cpp") @@ -149,7 +149,7 @@ target_include_directories(lib5 ) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat/prefix_foo_bar_bat.h" "// prefix_foo_bar_bat.h\n") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat/prefix_foo_bar_bat.h" "/* prefix_foo_bar_bat.h */\n") target_include_directories(TargetIncludeDirectories PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix_$<JOIN:foo;bar;bat,/prefix_>") diff --git a/Tests/OutOfBinary/CMakeLists.txt b/Tests/OutOfBinary/CMakeLists.txt index e327541..f50536e 100644 --- a/Tests/OutOfBinary/CMakeLists.txt +++ b/Tests/OutOfBinary/CMakeLists.txt @@ -1,2 +1,4 @@ add_library(outlib outlib.c) +add_executable(outexe outexe.c) +target_link_libraries(outexe subdir) diff --git a/Tests/OutOfBinary/outexe.c b/Tests/OutOfBinary/outexe.c new file mode 100644 index 0000000..6f14043 --- /dev/null +++ b/Tests/OutOfBinary/outexe.c @@ -0,0 +1,2 @@ +extern int subdir(void); +int main(void) { return subdir(); } diff --git a/Tests/OutOfSource/SubDir/CMakeLists.txt b/Tests/OutOfSource/SubDir/CMakeLists.txt index c5df36e..e18dbb9 100644 --- a/Tests/OutOfSource/SubDir/CMakeLists.txt +++ b/Tests/OutOfSource/SubDir/CMakeLists.txt @@ -6,3 +6,5 @@ add_subdirectory(${OutOfSource_SOURCE_DIR}/../OutOfBinary # subdir to a sibling dir add_subdirectory(${OutOfSource_SOURCE_DIR}/${KEN}OutOfSourceSubdir OutOfSourceSubdir ) + +add_library(subdir subdir.c) diff --git a/Tests/OutOfSource/SubDir/subdir.c b/Tests/OutOfSource/SubDir/subdir.c new file mode 100644 index 0000000..0d0d827 --- /dev/null +++ b/Tests/OutOfSource/SubDir/subdir.c @@ -0,0 +1 @@ +int subdir(void) { return 0; } diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 8782ba9..a578408 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -1,5 +1,11 @@ include(RunCMake) +if(RunCMake_GENERATOR STREQUAL "Borland Makefiles") + set(fs_delay 3) +else() + set(fs_delay 1.125) +endif() + function(run_BuildDepends CASE) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) @@ -17,7 +23,7 @@ function(run_BuildDepends CASE) if(run_BuildDepends_skip_step_2) return() endif() - execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1.125) # handle 1s resolution + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) # handle 1s resolution include(${RunCMake_SOURCE_DIR}/${CASE}.step2.cmake OPTIONAL) set(check_step 2) run_cmake_command(${CASE}-build2 ${CMAKE_COMMAND} --build . --config Debug) diff --git a/Tests/RunCMake/CommandLine/Wdev-stderr.txt b/Tests/RunCMake/CommandLine/Wdev-stderr.txt index f427303..92c1d23 100644 --- a/Tests/RunCMake/CommandLine/Wdev-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wdev-stderr.txt @@ -2,4 +2,10 @@ Some Author Warning Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. + +CMake Warning \(dev\) at Wdev.cmake:6 \(include\): + include\(\) given empty file name \(ignored\). +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLine/Wdev.cmake b/Tests/RunCMake/CommandLine/Wdev.cmake index 0242086..e5026ef 100644 --- a/Tests/RunCMake/CommandLine/Wdev.cmake +++ b/Tests/RunCMake/CommandLine/Wdev.cmake @@ -1 +1,6 @@ message(AUTHOR_WARNING "Some Author Warning") + +# with -Wdev this will also cause an AUTHOR_WARNING message, checks that +# messages issued outside of the message command, by other CMake commands, also +# are affected by -Wdev +include("") diff --git a/Tests/RunCMake/CommandLine/Wno-dev.cmake b/Tests/RunCMake/CommandLine/Wno-dev.cmake index 0242086..d81b858 100644 --- a/Tests/RunCMake/CommandLine/Wno-dev.cmake +++ b/Tests/RunCMake/CommandLine/Wno-dev.cmake @@ -1 +1,6 @@ message(AUTHOR_WARNING "Some Author Warning") + +# without -Wno-dev this will also cause an AUTHOR_WARNING message, checks that +# messages issued outside of the message command, by other CMake commands, also +# are affected by -Wno-dev +include("") diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-result.txt b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt new file mode 100644 index 0000000..8d3c4cc --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt @@ -0,0 +1,17 @@ +CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<SHELL_PATH:> + + "" is not an absolute path. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\): + Error evaluating generator expression: + + \$<SHELL_PATH:Relative/Path> + + "Relative/Path" is not an absolute path. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake new file mode 100644 index 0000000..5eff7bc --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake @@ -0,0 +1,4 @@ +add_custom_target(check ALL COMMAND check + $<SHELL_PATH:> + $<SHELL_PATH:Relative/Path> + VERBATIM) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 0679024..45175d8 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -10,6 +10,7 @@ run_cmake(BadTargetName) run_cmake(BadTargetTypeInterface) run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) +run_cmake(BadSHELL_PATH) run_cmake(CMP0044-WARN) run_cmake(NonValidTarget-C_COMPILER_ID) run_cmake(NonValidTarget-CXX_COMPILER_ID) diff --git a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp index 41896a7..7b33828 100644 --- a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp +++ b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp @@ -529,7 +529,7 @@ bool Reader::decodeNumber(Token& token, Value& decoded) { return addError("'" + std::string(token.start_, token.end_) + "' is not a number.", token); - Value::UInt digit(c - '0'); + Value::UInt digit(static_cast<Value::UInt>(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If // a) we've only just touched the limit, b) this is the last digit, and |