diff options
74 files changed, 768 insertions, 242 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9381f35..787f319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,7 +327,15 @@ macro (CMAKE_BUILD_UTILITIES) if(CMAKE_TESTS_CDASH_SERVER) set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") endif() - option(CMAKE_USE_OPENSSL "Use OpenSSL." OFF) + set(_CMAKE_USE_OPENSSL_DEFAULT OFF) + if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE + AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") + find_package(OpenSSL QUIET) + if(OPENSSL_FOUND) + set(_CMAKE_USE_OPENSSL_DEFAULT ON) + endif() + endif() + option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) mark_as_advanced(CMAKE_USE_OPENSSL) if(CMAKE_USE_OPENSSL) set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") diff --git a/Help/command/string.rst b/Help/command/string.rst index 0361c74..3f4050e 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -277,6 +277,7 @@ specifiers: %j The day of the current year (001-366). %m The month of the current year (01-12). %M The minute of the current hour (00-59). + %s Seconds since midnight (UTC) 1-Jan-1970 (UNIX time). %S The second of the current minute. 60 represents a leap second. (00-60) %U The week number of the current year (00-53). diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst index 28dae80..78b1bc7 100644 --- a/Help/command/try_compile.rst +++ b/Help/command/try_compile.rst @@ -112,3 +112,6 @@ The current setting of :policy:`CMP0065` is set in the generated project. Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose a build configuration. + +Set the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to specify +the type of target used for the source file signature. diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst index b9073a5..aebc5d9 100644 --- a/Help/manual/cmake-packages.7.rst +++ b/Help/manual/cmake-packages.7.rst @@ -89,7 +89,7 @@ a package is to set the ``CMAKE_PREFIX_PATH`` cache variable. Config-file packages are provided by upstream vendors as part of development packages, that is, they belong with the header files and any other files -provided to assist downsteams in using the package. +provided to assist downstreams in using the package. A set of variables which provide package status information are also set automatically when using a config-file package. The ``<Package>_FOUND`` @@ -352,7 +352,7 @@ version-specific variables ``<Package>_VERSION``, ``<Package>_VERSION_MAJOR``, used to export the targets in the ``ClimbingStatsTargets`` export-set, defined previously by the :command:`install(TARGETS)` command. This command generates the ``ClimbingStatsTargets.cmake`` file to contain :prop_tgt:`IMPORTED` -targets, suitable for use by downsteams and arranges to install it to +targets, suitable for use by downstreams and arranges to install it to ``lib/cmake/ClimbingStats``. The generated ``ClimbingStatsConfigVersion.cmake`` and a ``cmake/ClimbingStatsConfig.cmake`` are installed to the same location, completing the package. @@ -383,7 +383,7 @@ In this case, when using :command:`install(TARGETS)` the ``INCLUDES DESTINATION` was specified. This causes the ``IMPORTED`` targets to have their :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` populated with the ``include`` directory in the :variable:`CMAKE_INSTALL_PREFIX`. When the ``IMPORTED`` -target is used by downsteam, it automatically consumes the entries from +target is used by downstream, it automatically consumes the entries from that property. Creating a Package Configuration File @@ -412,7 +412,7 @@ This can also be extended to cover dependencies: target_link_libraries(ClimbingStats PUBLIC Stats::Types) As the ``Stats::Types`` target is a ``PUBLIC`` dependency of ``ClimbingStats``, -downsteams must also find the ``Stats`` package and link to the ``Stats::Types`` +downstreams must also find the ``Stats`` package and link to the ``Stats::Types`` library. The ``Stats`` package should be found in the ``ClimbingStatsConfig.cmake`` file to ensure this. The ``find_dependency`` macro from the :module:`CMakeFindDependencyMacro` helps with this by propagating @@ -464,7 +464,7 @@ Creating a Package Configuration File for the Build Tree The :command:`export(EXPORT)` command creates an :prop_tgt:`IMPORTED` targets definition file which is specific to the build-tree, and is not relocatable. -This can similiarly be used with a suitable package configuration file and +This can similarly be used with a suitable package configuration file and package version file to define a package for the build tree which may be used without installation. Consumers of the build tree can simply ensure that the :variable:`CMAKE_PREFIX_PATH` contains the build directory, or set the diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index a41d484..d6618fe 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -255,6 +255,7 @@ Properties on Targets /prop_tgt/TYPE /prop_tgt/VERSION /prop_tgt/VISIBILITY_INLINES_HIDDEN + /prop_tgt/VS_CONFIGURATION_TYPE /prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION /prop_tgt/VS_DOTNET_REFERENCES /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 15eaece..444a706 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -292,6 +292,7 @@ Variables that Control the Build /variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG /variable/CMAKE_STATIC_LINKER_FLAGS /variable/CMAKE_TRY_COMPILE_CONFIGURATION + /variable/CMAKE_TRY_COMPILE_TARGET_TYPE /variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 959148e..5295a48c 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -200,16 +200,19 @@ Available commands are: ``make_directory <dir>...`` Create ``<dir>`` directories. If necessary, create parent - directories too. + directories too. If a directory already exists it will be + silently ignored. ``md5sum <file>...`` Compute md5sum of files. ``remove [-f] <file>...`` - Remove the file(s), use ``-f`` to force it. + Remove the file(s), use ``-f`` to force it. If a file does + not exist it will be silently ignored. ``remove_directory <dir>`` - Remove a directory and its contents. + Remove a directory and its contents. If a directory does + not exist it will be silently ignored. ``rename <oldname> <newname>`` Rename a file or directory (on one volume). @@ -242,7 +245,8 @@ Available commands are: Touch a file. ``touch_nocreate <file>`` - Touch a file if it exists but do not create it. + Touch a file if it exists but do not create it. If a file does + not exist it will be silently ignored. UNIX-specific Command-Line Tools -------------------------------- diff --git a/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst new file mode 100644 index 0000000..ff987ff --- /dev/null +++ b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst @@ -0,0 +1,10 @@ +VS_CONFIGURATION_TYPE +--------------------- + +Visual Studio project configuration type. + +Sets the ``ConfigurationType`` attribute for a generated Visual Studio project. +If this property is set, it overrides the default setting that is based on the +target type (e.g. ``StaticLibrary``, ``Application``, ...). + +Supported on :ref:`Visual Studio Generators` for VS 2010 and higher. diff --git a/Help/release/dev/cpack-deb-autodep-ORIGIN-RPATH.rst b/Help/release/dev/cpack-deb-autodep-ORIGIN-RPATH.rst new file mode 100644 index 0000000..b0d6196 --- /dev/null +++ b/Help/release/dev/cpack-deb-autodep-ORIGIN-RPATH.rst @@ -0,0 +1,6 @@ +cpack-deb-autodep-ORIGIN-RPATH +-------------------------------- + +* The "CPackDeb" module learned how to handle ``$ORIGIN`` + in ``CMAKE_INSTALL_RPATH`` when :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` + is used for dependency auto detection. diff --git a/Help/release/dev/enable-ssl-automatically.rst b/Help/release/dev/enable-ssl-automatically.rst new file mode 100644 index 0000000..8ded656 --- /dev/null +++ b/Help/release/dev/enable-ssl-automatically.rst @@ -0,0 +1,8 @@ +enable-ssl-automatically +------------------------ + +* On Linux and FreeBSD platforms, when building CMake itself from source and + not using a system-provided libcurl, OpenSSL is now used by default if it is + found on the system. This enables SSL/TLS support for commands supporting + network communication via ``https``, such as :command:`file(DOWNLOAD)`, + :command:`file(UPLOAD)`, and :command:`ctest_submit`. diff --git a/Help/release/dev/try_compile-target-type.rst b/Help/release/dev/try_compile-target-type.rst new file mode 100644 index 0000000..cc41bf3 --- /dev/null +++ b/Help/release/dev/try_compile-target-type.rst @@ -0,0 +1,8 @@ +try_compile-target-type +----------------------- + +* The :command:`try_compile` command learned to check a new + :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable to optionally + build a static library instead of an executable. This is useful + for cross-compiling toolchains that cannot link binaries without + custom flags or scripts. diff --git a/Help/release/dev/unix-timestamps.rst b/Help/release/dev/unix-timestamps.rst new file mode 100644 index 0000000..cdb0e5b --- /dev/null +++ b/Help/release/dev/unix-timestamps.rst @@ -0,0 +1,6 @@ +unix-timestamps +--------------- + +* The :command:`string(TIMESTAMP)` and :command:`file(TIMESTAMP)` + commands gained support for the ``%s`` placeholder. This is + the number of seconds since the UNIX Epoch. diff --git a/Help/release/dev/vs-vcxproj-ConfigurationType.rst b/Help/release/dev/vs-vcxproj-ConfigurationType.rst new file mode 100644 index 0000000..46d05b4 --- /dev/null +++ b/Help/release/dev/vs-vcxproj-ConfigurationType.rst @@ -0,0 +1,6 @@ +vs-vcxproj-ConfigurationType +---------------------------- + +* :ref:`Visual Studio Generators` for VS 2010 and above learned a new + :prop_tgt:`VS_CONFIGURATION_TYPE` target property to specify a custom + project file type. diff --git a/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst b/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst new file mode 100644 index 0000000..5fa8dfc --- /dev/null +++ b/Help/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.rst @@ -0,0 +1,15 @@ +CMAKE_TRY_COMPILE_TARGET_TYPE +----------------------------- + +Type of target generated for :command:`try_compile` calls using the +source file signature. Valid values are: + +``EXECUTABLE`` + Use :command:`add_executable` to name the source file in the + generated project. This is the default if no value is given. + +``STATIC_LIBRARY`` + Use :command:`add_library` with the ``STATIC`` option to name the + source file in the generated project. This avoids running the + linker and is intended for use with cross-compiling toolchains + that cannot link without custom flags or linker scripts. diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake index f8d8d59..bf85ea0 100644 --- a/Modules/CMakeFindCodeBlocks.cmake +++ b/Modules/CMakeFindCodeBlocks.cmake @@ -23,3 +23,18 @@ endif() # Determine builtin macros and include dirs: include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) + +# Try to find out how many CPUs we have and set the -j argument for make accordingly +set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "") + +include(ProcessorCount) +processorcount(_CMAKE_CODEBLOCKS_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +if("${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "-j${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}") +endif() + +# This variable is used by the CodeBlocks generator and appended to the make invocation commands. +set(CMAKE_CODEBLOCKS_MAKE_ARGUMENTS "${_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when CodeBlocks invokes make. Enter e.g. -j<some_number> to get parallel builds") diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 85c1fdf..5bf738a 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -30,6 +30,8 @@ function(_FIND_ECLIPSE_VERSION) set(_ECLIPSE_VERSION_NAME_3.7 "Indigo" ) set(_ECLIPSE_VERSION_NAME_4.2 "Juno" ) set(_ECLIPSE_VERSION_NAME_4.3 "Kepler" ) + set(_ECLIPSE_VERSION_NAME_4.4 "Luna" ) + set(_ECLIPSE_VERSION_NAME_4.5 "Mars" ) if(NOT DEFINED CMAKE_ECLIPSE_VERSION) if(CMAKE_ECLIPSE_EXECUTABLE) @@ -65,6 +67,8 @@ function(_FIND_ECLIPSE_VERSION) "3.7 (${_ECLIPSE_VERSION_NAME_3.7})" "4.2 (${_ECLIPSE_VERSION_NAME_4.2})" "4.3 (${_ECLIPSE_VERSION_NAME_4.3})" + "4.4 (${_ECLIPSE_VERSION_NAME_4.4})" + "4.5 (${_ECLIPSE_VERSION_NAME_4.5})" ) endfunction() diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake index d51b503..e0d45e7 100644 --- a/Modules/CMakeTestCompilerCommon.cmake +++ b/Modules/CMakeTestCompilerCommon.cmake @@ -13,9 +13,5 @@ # License text for the above reference.) function(PrintTestCompilerStatus LANG MSG) - if(CMAKE_GENERATOR MATCHES Make) - message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") - else() - message(STATUS "Check for working ${LANG} compiler using: ${CMAKE_GENERATOR}${MSG}") - endif() + message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}") endfunction() diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 2aaef61..b41d926 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -504,6 +504,9 @@ function(cpack_deb_prepare_package_vars) file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") + # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN. + file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN") + # Add --ignore-missing-info if the tool supports it execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help OUTPUT_VARIABLE _TMP_HELP @@ -544,6 +547,9 @@ function(cpack_deb_prepare_package_vars) # Remove blank control file # Might not be safe if package actual contain file or directory named debian file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") + + # remove temporary directory that was created only for dpkg-shlibdeps execution + file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN") else() if(CPACK_DEBIAN_PACKAGE_DEBUG) message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4b38a66..2a369b2 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 5) -set(CMake_VERSION_PATCH 20160218) +set(CMake_VERSION_PATCH 20160307) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 22d4bf0..3eca280 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -723,10 +723,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmGlobalGenerator gg(&cm); cmsys::auto_ptr<cmMakefile> mf( new cmMakefile(&gg, cm.GetCurrentSnapshot())); - std::string realInstallDirectory = tempInstallDirectory; if ( !installSubDirectory.empty() && installSubDirectory != "/" ) { - realInstallDirectory += installSubDirectory; + tempInstallDirectory += installSubDirectory; } if (componentInstall) { diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 2c2cd48..fd62696 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -983,7 +983,7 @@ int cmCTestCoverageHandler::HandleDelphiCoverage( std::string BinDir = this->CTest->GetBinaryDir(); - std::string coverageFile = BinDir+ "/*.html"; + std::string coverageFile = BinDir+ "/*(*.pas).html"; g.FindFiles(coverageFile); @@ -1017,9 +1017,25 @@ int cmCTestCoverageHandler::HandleBlanketJSCoverage( std::string coverageFile = SourceDir+ "/*.json"; cmsys::Glob g; std::vector<std::string> files; + std::vector<std::string> blanketFiles; g.FindFiles(coverageFile); files=g.GetFiles(); - if (!files.empty()) + // Ensure that the JSON files found are the result of the + // Blanket.js output. Check for the "node-jscoverage" + // string on the second line + std::string line; + for(unsigned int fileEntry=0;fileEntry<files.size();fileEntry++) + { + cmsys::ifstream in(files[fileEntry].c_str()); + cmSystemTools::GetLineFromStream(in, line); + cmSystemTools::GetLineFromStream(in, line); + if (line.find("node-jscoverage") != line.npos) + { + blanketFiles.push_back(files[fileEntry]); + } + } + // Take all files with the node-jscoverage string and parse those + if (!blanketFiles.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found BlanketJS output JSON, Performing Coverage" << std::endl, diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 4a1f770..b639c15 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -19,13 +19,42 @@ #include <assert.h> -int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) +int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, + bool isTryRun) { this->BinaryDirectory = argv[1].c_str(); this->OutputFile = ""; // which signature were we called with ? this->SrcFileSignature = true; + cmState::TargetType targetType = cmState::EXECUTABLE; + const char* tt = + this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE"); + if (!isTryRun && tt && *tt) + { + if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0) + { + targetType = cmState::EXECUTABLE; + } + else if (strcmp(tt, + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY)) == 0) + { + targetType = cmState::STATIC_LIBRARY; + } + else + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + std::string("Invalid value '") + tt + "' for " + "CMAKE_TRY_COMPILE_TARGET_TYPE. Only " + "'" + cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and " + "'" + cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) + "' " + "are allowed." + ); + return -1; + } + } + const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; std::string targetName; @@ -486,11 +515,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) fprintf(fout, "set(CMAKE_ENABLE_EXPORTS %s)\n", ee); } - /* Put the executable at a known location (for COPY_FILE). */ - fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", - this->BinaryDirectory.c_str()); - /* Create the actual executable. */ - fprintf(fout, "add_executable(%s", targetName.c_str()); + if (targetType == cmState::EXECUTABLE) + { + /* Put the executable at a known location (for COPY_FILE). */ + fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", + this->BinaryDirectory.c_str()); + /* Create the actual executable. */ + fprintf(fout, "add_executable(%s", targetName.c_str()); + } + else // if (targetType == cmState::STATIC_LIBRARY) + { + /* Put the static library at a known location (for COPY_FILE). */ + fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n", + this->BinaryDirectory.c_str()); + /* Create the actual static library. */ + fprintf(fout, "add_library(%s STATIC", targetName.c_str()); + } for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) { @@ -549,7 +589,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (this->SrcFileSignature) { std::string copyFileErrorMessage; - this->FindOutputFile(targetName); + this->FindOutputFile(targetName, targetType); if ((res==0) && !copyFile.empty()) { @@ -651,13 +691,26 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } } -void cmCoreTryCompile::FindOutputFile(const std::string& targetName) +void cmCoreTryCompile::FindOutputFile(const std::string& targetName, + cmState::TargetType targetType) { this->FindErrorMessage = ""; this->OutputFile = ""; std::string tmpOutputFile = "/"; - tmpOutputFile += targetName; - tmpOutputFile +=this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); + if (targetType == cmState::EXECUTABLE) + { + tmpOutputFile += targetName; + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); + } + else // if (targetType == cmState::STATIC_LIBRARY) + { + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); + tmpOutputFile += targetName; + tmpOutputFile += + this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); + } // a list of directories where to search for the compilation result // at first directly in the binary dir diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index 3272462..c2beea8 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -30,7 +30,7 @@ public: * commands, such as TryRun can access the same logic without * duplication. */ - int TryCompileCode(std::vector<std::string> const& argv); + int TryCompileCode(std::vector<std::string> const& argv, bool isTryRun); /** * This deletes all the files created by TryCompileCode. @@ -44,8 +44,8 @@ public: TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ - void FindOutputFile(const std::string& targetName); - + void FindOutputFile(const std::string& targetName, + cmState::TargetType targetType); cmTypeMacro(cmCoreTryCompile, cmCommand); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 026958a..ed0c69c 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -300,6 +300,8 @@ void cmExtraCodeBlocksGenerator // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_CODEBLOCKS_MAKE_ARGUMENTS"); fout<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" "<CodeBlocks_project_file>\n" @@ -311,7 +313,8 @@ void cmExtraCodeBlocksGenerator " "<<virtualFolders<<"\n" " <Build>\n"; - this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str()); + this->AppendTarget(fout, "all", 0, make.c_str(), lgs[0], compiler.c_str(), + makeArgs); // add all executable and library targets and some of the GLOBAL // and UTILITY targets @@ -333,7 +336,8 @@ void cmExtraCodeBlocksGenerator (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), + makeArgs); } } break; @@ -350,7 +354,7 @@ void cmExtraCodeBlocksGenerator } this->AppendTarget(fout, targetName, 0, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(),makeArgs); break; case cmState::EXECUTABLE: case cmState::STATIC_LIBRARY: @@ -360,11 +364,11 @@ void cmExtraCodeBlocksGenerator { cmGeneratorTarget* gt = *ti; this->AppendTarget(fout, targetName, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); std::string fastTarget = targetName; fastTarget += "/fast"; this->AppendTarget(fout, fastTarget, gt, - make.c_str(), *lg, compiler.c_str()); + make.c_str(), *lg, compiler.c_str(), makeArgs); } break; default: @@ -555,7 +559,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, - const char* compiler) + const char* compiler, + const std::string& makeFlags) { cmMakefile const* makefile = lg->GetMakefile(); std::string makefileName = lg->GetCurrentBinaryDirectory(); @@ -663,16 +668,18 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, fout<<" <MakeCommands>\n" " <Build command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), targetName) + << this->BuildMakeCommand(make, makefileName.c_str(), targetName, + makeFlags) << "\" />\n" " <CompileFile command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(),""$file"") + << this->BuildMakeCommand(make, makefileName.c_str(),""$file"", + makeFlags) << "\" />\n" " <Clean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " <DistClean command=\"" - << this->BuildMakeCommand(make, makefileName.c_str(), "clean") + << this->BuildMakeCommand(make, makefileName.c_str(), "clean", makeFlags) << "\" />\n" " </MakeCommands>\n" " </Target>\n"; @@ -802,9 +809,15 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) // make std::string cmExtraCodeBlocksGenerator::BuildMakeCommand( const std::string& make, const char* makefile, - const std::string& target) + const std::string& target, const std::string& makeFlags) { std::string command = make; + if (makeFlags.size() > 0) + { + command += " "; + command += makeFlags; + } + std::string generator = this->GlobalGenerator->GetName(); if (generator == "NMake Makefiles") { diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h index 0c3846d..4abfa7e 100644 --- a/Source/cmExtraCodeBlocksGenerator.h +++ b/Source/cmExtraCodeBlocksGenerator.h @@ -54,13 +54,16 @@ private: std::string GetCBCompilerId(const cmMakefile* mf); int GetCBTargetType(cmGeneratorTarget* target); std::string BuildMakeCommand(const std::string& make, const char* makefile, - const std::string& target); + const std::string& target, + const std::string& makeFlags); void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName, cmGeneratorTarget* target, const char* make, const cmLocalGenerator* lg, - const char* compiler); + const char* compiler, + const std::string& makeFlags + ); }; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index aedf6f4..133a85a 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -42,6 +42,8 @@ cmExtraEclipseCDT4Generator this->GenerateLinkedResources = true; this->SupportsGmakeErrorParser = true; this->SupportsMachO64Parser = true; + this->CEnabled = false; + this->CXXEnabled = false; } //---------------------------------------------------------------------------- @@ -64,10 +66,12 @@ void cmExtraEclipseCDT4Generator { this->Natures.insert("org.eclipse.cdt.core.ccnature"); this->Natures.insert("org.eclipse.cdt.core.cnature"); + this->CXXEnabled = true; } else if (*lit == "C") { this->Natures.insert("org.eclipse.cdt.core.cnature"); + this->CEnabled = true; } else if (*lit == "Java") { @@ -890,7 +894,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // add system defined c macros const char* cDefs=mf->GetDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS"); - if(cDefs) + if(this->CEnabled && cDefs) { // Expand the list. std::vector<std::string> defs; @@ -925,7 +929,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // add system defined c++ macros const char* cxxDefs = mf->GetDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS"); - if(cxxDefs) + if(this->CXXEnabled && cxxDefs) { // Expand the list. std::vector<std::string> defs; @@ -979,7 +983,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // CMakeSystemSpecificInformation.cmake. This makes Eclipse find the // standard headers. std::string compiler = mf->GetSafeDefinition("CMAKE_C_COMPILER"); - if (!compiler.empty()) + if (this->CEnabled && !compiler.empty()) { std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); @@ -988,7 +992,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const this->AppendIncludeDirectories(fout, dirs, emmited); } compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); - if (!compiler.empty()) + if (this->CXXEnabled && !compiler.empty()) { std::string systemIncludeDirs = mf->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 16675f2..1da2077 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -116,6 +116,8 @@ private: bool SupportsVirtualFolders; bool SupportsGmakeErrorParser; bool SupportsMachO64Parser; + bool CEnabled; + bool CXXEnabled; }; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index b3557f9..1fa27eb 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3300,6 +3300,15 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) << " status: [" << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"]" << std::endl ; + + if(!statusVar.empty() && res == 0) + { + std::string status = "1;HASH mismatch: " + "expected: " + expectedHash + + " actual: " + actualHash; + this->Makefile->AddDefinition(statusVar, status.c_str()); + } + this->SetError(oss.str()); return false; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 526e32f..ef18729 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2805,7 +2805,10 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt, fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); - fileRef->AddAttribute("refType", this->CreateString("0")); + if(this->XcodeVersion == 15) + { + fileRef->AddAttribute("refType", this->CreateString("0")); + } fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); fileRef->SetComment(gtgt->GetName().c_str()); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 226ab43..b16eccd 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1104,39 +1104,10 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders, std::cout << "AUTOGEN: Checking " << headerName << std::endl; } - std::string headerDirectory; - if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectSourceDir)) - { - headerDirectory = this->ProjectSourceDir; - } - else if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectBinaryDir)) - { - headerDirectory = this->ProjectBinaryDir; - } - else - { - cmsys::SystemTools::SplitPathRootComponent(headerName, - &headerDirectory); - } - - std::string baseHeaderName = - cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName); - - headerDirectory = cmsys::SystemTools::RelativePath( - headerDirectory, cmsys::SystemTools::GetParentDirectory(headerName)); - - if (!headerDirectory.empty()) - { - headerDirectory += "/"; - } - - std::string mocName = headerDirectory + baseHeaderName; - - cmSystemTools::ReplaceString(mocName, "/", "_"); + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); - const std::string currentMoc = "moc_" + mocName + ".cpp"; + const std::string currentMoc = "moc_" + basename + ".cpp"; std::string macroName; if (requiresMocing(contents, macroName)) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3ba7287..9af54bf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -60,8 +60,7 @@ #endif #if defined(CMAKE_BUILD_WITH_CMAKE) -# include <fcntl.h> -# include "cmCryptoHash.h" +# include "cmCryptoHash.h" #endif #if defined(CMAKE_USE_ELF_PARSER) @@ -2184,8 +2183,10 @@ unsigned int cmSystemTools::RandomSeed() } seed; // Try using a real random source. - cmsys::ifstream fin("/dev/urandom"); - if(fin && fin.read(seed.bytes, sizeof(seed)) && + cmsys::ifstream fin; + fin.rdbuf()->pubsetbuf(0, 0); // Unbuffered read. + fin.open("/dev/urandom"); + if(fin.good() && fin.read(seed.bytes, sizeof(seed)) && fin.gcount() == sizeof(seed)) { return seed.integer; diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 6fd6ab7..1c795c4 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -12,9 +12,11 @@ #include "cmTimestamp.h" #include <cstring> +#include <cstdlib> #include <sys/types.h> #include <sys/stat.h> +#include <sstream> //---------------------------------------------------------------------------- std::string cmTimestamp::CurrentTime( @@ -44,7 +46,7 @@ std::string cmTimestamp::FileModificationTime(const char* path, //---------------------------------------------------------------------------- std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, - std::string formatString, bool utcFlag) + std::string formatString, bool utcFlag) const { if(formatString.empty()) { @@ -79,12 +81,12 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, for(std::string::size_type i = 0; i < formatString.size(); ++i) { char c1 = formatString[i]; - char c2 = (i+1 < formatString.size()) ? - formatString[i+1] : static_cast<char>(0); + char c2 = (i + 1 < formatString.size()) ? + formatString[i + 1] : static_cast<char>(0); if(c1 == '%' && c2 != 0) { - result += AddTimestampComponent(c2, timeStruct); + result += AddTimestampComponent(c2, timeStruct, timeT); ++i; } else @@ -97,8 +99,40 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT, } //---------------------------------------------------------------------------- +time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm &tm) const +{ +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return _mkgmtime(&tm); +#else + // From Linux timegm() manpage. + + std::string tz_old = "TZ="; + if (const char* tz = cmSystemTools::GetEnv("TZ")) + { + tz_old += tz; + } + + // The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC. + // It seems that "TZ=" does NOT work, at least under Windows + // with neither MSVC nor MinGW, so let's use explicit "TZ=UTC" + + cmSystemTools::PutEnv("TZ=UTC"); + + tzset(); + + time_t result = mktime(&tm); + + cmSystemTools::PutEnv(tz_old); + + tzset(); + + return result; +#endif +} + +//---------------------------------------------------------------------------- std::string cmTimestamp::AddTimestampComponent( - char flag, struct tm& timeStruct) + char flag, struct tm& timeStruct, const time_t timeT) const { std::string formatString = "%"; formatString += flag; @@ -117,6 +151,26 @@ std::string cmTimestamp::AddTimestampComponent( case 'y': case 'Y': break; + case 's': // Seconds since UNIX epoch (midnight 1-jan-1970) + { + // Build a time_t for UNIX epoch and substract from the input "timeT": + struct tm tmUnixEpoch; + memset(&tmUnixEpoch, 0, sizeof(tmUnixEpoch)); + tmUnixEpoch.tm_mday = 1; + tmUnixEpoch.tm_year = 1970-1900; + + const time_t unixEpoch = this->CreateUtcTimeTFromTm(tmUnixEpoch); + if (unixEpoch == -1) + { + cmSystemTools::Error("Error generating UNIX epoch in " + "STRING(TIMESTAMP ...). Please, file a bug report aginst CMake"); + return std::string(); + } + + std::stringstream ss; + ss << static_cast<long int>(difftime(timeT, unixEpoch)); + return ss.str(); + } default: { return formatString; diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h index 24c1869..7c4b216 100644 --- a/Source/cmTimestamp.h +++ b/Source/cmTimestamp.h @@ -16,7 +16,7 @@ #include <time.h> /** \class cmTimestamp - * \brief Utility class to generate sting representation of a timestamp + * \brief Utility class to generate string representation of a timestamp * */ class cmTimestamp @@ -30,10 +30,13 @@ public: const std::string& formatString, bool utcFlag); private: - std::string CreateTimestampFromTimeT(time_t timeT, - std::string formatString, bool utcFlag); + time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const; - std::string AddTimestampComponent(char flag, struct tm& timeStruct); + std::string CreateTimestampFromTimeT( + time_t timeT, std::string formatString, bool utcFlag) const; + + std::string AddTimestampComponent( + char flag, struct tm& timeStruct, time_t timeT) const; }; diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 12ce015..87fbbdf 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -28,7 +28,7 @@ bool cmTryCompileCommand return false; } - this->TryCompileCode(argv); + this->TryCompileCode(argv, false); // if They specified clean then we clean up what we can if (this->SrcFileSignature) diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index b9ffe5e..d4a36c9 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -135,7 +135,7 @@ bool cmTryRunCommand this->CompileResultVariable = argv[1]; // do the try compile - int res = this->TryCompileCode(tryCompile); + int res = this->TryCompileCode(tryCompile, true); // now try running the command if it compiled if (!res) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 09d4a90..61d7855 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -696,43 +696,51 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() i->c_str(), 1, " Label=\"Configuration\"", "\n"); std::string configType = "<ConfigurationType>"; - switch(this->GeneratorTarget->GetType()) - { - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - configType += "DynamicLibrary"; - break; - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: - configType += "StaticLibrary"; - break; - case cmState::EXECUTABLE: - if(this->NsightTegra && - !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) - { - // Android executables are .so too. + if (const char* vsConfigurationType = + this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) + { + configType += cmVS10EscapeXML(vsConfigurationType); + } + else + { + switch(this->GeneratorTarget->GetType()) + { + case cmState::SHARED_LIBRARY: + case cmState::MODULE_LIBRARY: configType += "DynamicLibrary"; - } - else - { - configType += "Application"; - } - break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - if(this->NsightTegra) - { - // Tegra-Android platform does not understand "Utility". + break; + case cmState::OBJECT_LIBRARY: + case cmState::STATIC_LIBRARY: configType += "StaticLibrary"; - } - else - { - configType += "Utility"; - } - break; - case cmState::UNKNOWN_LIBRARY: - case cmState::INTERFACE_LIBRARY: - break; + break; + case cmState::EXECUTABLE: + if(this->NsightTegra && + !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) + { + // Android executables are .so too. + configType += "DynamicLibrary"; + } + else + { + configType += "Application"; + } + break; + case cmState::UTILITY: + case cmState::GLOBAL_TARGET: + if(this->NsightTegra) + { + // Tegra-Android platform does not understand "Utility". + configType += "StaticLibrary"; + } + else + { + configType += "Utility"; + } + break; + case cmState::UNKNOWN_LIBRARY: + case cmState::INTERFACE_LIBRARY: + break; + } } configType += "</ConfigurationType>\n"; this->WriteString(configType.c_str(), 2); @@ -2698,6 +2706,33 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } } + // Hack to fix flag version selection in a common use case. + // FIXME: Select flag table based on toolset instead of VS version. + if (this->LocalGenerator->GetVersion() >= + cmGlobalVisualStudioGenerator::VS14) + { + cmGlobalVisualStudio10Generator* gg = + static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator); + const char* toolset = gg->GetPlatformToolset(); + if (toolset && + (cmHasLiteralPrefix(toolset, "v110") || + cmHasLiteralPrefix(toolset, "v120"))) + { + if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation")) + { + // Convert value from enumeration back to boolean for older toolsets. + if (strcmp(debug, "No") == 0) + { + linkOptions.AddFlag("GenerateDebugInformation", "false"); + } + else if (strcmp(debug, "Debug") == 0) + { + linkOptions.AddFlag("GenerateDebugInformation", "true"); + } + } + } + } + this->LinkOptions[config] = pOptions.release(); return true; } diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 5bc34c1..911e154 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -111,102 +111,102 @@ void cmXCodeObject::Print(std::ostream& out) for(i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end(); ++i) { - cmXCodeObject* object = i->second; - if(i->first != "isa") - { - cmXCodeObject::Indent(3*indentFactor, out); - } - else - { + if(i->first == "isa") continue; - } - if(object->TypeValue == OBJECT_LIST) - { - out << i->first << " = (" << separator; - for(unsigned int k = 0; k < i->second->List.size(); k++) - { - cmXCodeObject::Indent(4*indentFactor, out); - out << i->second->List[k]->Id; - i->second->List[k]->PrintComment(out); - out << "," << separator; - } - cmXCodeObject::Indent(3*indentFactor, out); - out << ");" << separator; - } - else if(object->TypeValue == ATTRIBUTE_GROUP) + + PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this); + } + cmXCodeObject::Indent(2*indentFactor, out); + out << "};\n"; +} + +void cmXCodeObject::PrintAttribute(std::ostream& out, const int level, + const std::string separator, + const int factor, const std::string& name, + const cmXCodeObject* object, + const cmXCodeObject* parent) +{ + cmXCodeObject::Indent(level * factor, out); + switch(object->TypeValue) + { + case OBJECT_LIST: { - std::map<std::string, cmXCodeObject*>::iterator j; - out << i->first << " = {"; - if(separator == "\n") + out << name << " = ("; + if(parent->TypeValue != ATTRIBUTE_GROUP) { out << separator; } - for(j = object->ObjectAttributes.begin(); j != - object->ObjectAttributes.end(); ++j) + for(unsigned int i = 0; i < object->List.size(); ++i) { - cmXCodeObject::Indent(4 *indentFactor, out); - - if(j->second->TypeValue == STRING) - { - cmXCodeObject::PrintString(out,j->first); - out << " = "; - j->second->PrintString(out); - out << ";"; - } - else if(j->second->TypeValue == OBJECT_LIST) + if(object->List[i]->TypeValue == STRING) { - cmXCodeObject::PrintString(out,j->first); - out << " = ("; - for(unsigned int k = 0; k < j->second->List.size(); k++) + object->List[i]->PrintString(out); + if(i+1 < object->List.size()) { - if(j->second->List[k]->TypeValue == STRING) - { - j->second->List[k]->PrintString(out); - out << ", "; - } - else - { - out << "List_" << k << "_TypeValue_IS_NOT_STRING, "; - } + out << ","; } - out << ");"; } else { - cmXCodeObject::PrintString(out,j->first); - out << " = error_unexpected_TypeValue_" << - j->second->TypeValue << ";"; + cmXCodeObject::Indent((level + 1) * factor, out); + out << object->List[i]->Id; + object->List[i]->PrintComment(out); + out << "," << separator; } + } + if(parent->TypeValue != ATTRIBUTE_GROUP) + { + cmXCodeObject::Indent(level * factor, out); + } + out << ");" << separator; + } + break; + case ATTRIBUTE_GROUP: + { + out << name << " = {"; + if(separator == "\n") + { out << separator; } - cmXCodeObject::Indent(3 *indentFactor, out); + std::map<std::string, cmXCodeObject*>::const_iterator i; + for(i = object->ObjectAttributes.begin(); + i != object->ObjectAttributes.end(); ++i) + { + PrintAttribute(out, (level + 1) * factor, separator, factor, + i->first, i->second, object); + } + cmXCodeObject::Indent(level * factor, out); out << "};" << separator; } - else if(object->TypeValue == OBJECT_REF) + break; + + case OBJECT_REF: { - cmXCodeObject::PrintString(out,i->first); + cmXCodeObject::PrintString(out, name); out << " = " << object->Object->Id; - if(object->Object->HasComment() && i->first != "remoteGlobalIDString") + if(object->Object->HasComment() && name != "remoteGlobalIDString") { object->Object->PrintComment(out); } out << ";" << separator; } - else if(object->TypeValue == STRING) + break; + + case STRING: { - cmXCodeObject::PrintString(out,i->first); + cmXCodeObject::PrintString(out, name); out << " = "; object->PrintString(out); out << ";" << separator; } - else + break; + + default: { - out << "what is this?? " << i->first << "\n"; + break; } } - cmXCodeObject::Indent(2*indentFactor, out); - out << "};\n"; } //---------------------------------------------------------------------------- diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index bd0f43f..2d876da 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -75,6 +75,10 @@ public: } static void Indent(int level, std::ostream& out); void Print(std::ostream& out); + void PrintAttribute(std::ostream& out, const int level, + const std::string separator, const int factor, + const std::string& name, const cmXCodeObject* object, + const cmXCodeObject* parent); virtual void PrintComment(std::ostream&) {} static void PrintList(std::vector<cmXCodeObject*> const&, diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 3636836..f713294 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -20,6 +20,7 @@ #if 0 # include "CommandLineArguments.hxx.in" # include "Configure.hxx.in" +# include "String.hxx.in" #endif #include <vector> diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 07c644b..7402955 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -505,6 +505,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.tv_sec = -1; } /*--------------------------------------------------------------------------*/ diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 1f8749f..a18ea27 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -17,7 +17,7 @@ duplicate the above list of headers. */ #if 0 # include "Process.h.in" -# include "Encoding_c.h.in" +# include "Encoding.h.in" #endif /* @@ -698,6 +698,8 @@ void kwsysProcess_SetTimeout(kwsysProcess* cp, double timeout) { cp->Timeout = 0; } + // Force recomputation of TimeoutTime. + cp->TimeoutTime.QuadPart = -1; } /*--------------------------------------------------------------------------*/ diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index cddcc8d..127a048 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -43,7 +43,6 @@ #if 0 # include "SystemInformation.hxx.in" # include "Process.h.in" -# include "Configure.hxx.in" #endif #include <iostream> @@ -3570,33 +3569,44 @@ SystemInformationImplementation::GetHostMemoryUsed() return (statex.ullTotalPhys - statex.ullAvailPhys)/1024; # endif #elif defined(__linux) - const char *names[3]={"MemTotal:","MemFree:",NULL}; - SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; - int ierr=GetFieldsFromFile("/proc/meminfo",names,values); + // First try to use MemAvailable, but it only works on newer kernels + const char *names2[3]={"MemTotal:","MemAvailable:",NULL}; + SystemInformation::LongLong values2[2]={SystemInformation::LongLong(0)}; + int ierr=GetFieldsFromFile("/proc/meminfo",names2,values2); if (ierr) { - return ierr; - } - SystemInformation::LongLong &memTotal=values[0]; - SystemInformation::LongLong &memFree=values[1]; - return memTotal - memFree; + const char *names4[5]={"MemTotal:","MemFree:","Buffers:","Cached:",NULL}; + SystemInformation::LongLong values4[4]={SystemInformation::LongLong(0)}; + ierr=GetFieldsFromFile("/proc/meminfo",names4,values4); + if(ierr) + { + return ierr; + } + SystemInformation::LongLong &memTotal=values4[0]; + SystemInformation::LongLong &memFree=values4[1]; + SystemInformation::LongLong &memBuffers=values4[2]; + SystemInformation::LongLong &memCached=values4[3]; + return memTotal - memFree - memBuffers - memCached; + } + SystemInformation::LongLong &memTotal=values2[0]; + SystemInformation::LongLong &memAvail=values2[1]; + return memTotal - memAvail; #elif defined(__APPLE__) SystemInformation::LongLong psz=getpagesize(); if (psz<1) { return -1; } - const char *names[4]={"Pages active:","Pages inactive:","Pages wired down:",NULL}; - SystemInformation::LongLong values[3]={SystemInformation::LongLong(0)}; + const char *names[3]={"Pages wired down:","Pages active:",NULL}; + SystemInformation::LongLong values[2]={SystemInformation::LongLong(0)}; int ierr=GetFieldsFromCommand("vm_stat", names, values); if (ierr) { return -1; } - SystemInformation::LongLong &vmActive=values[0]; - SystemInformation::LongLong &vmInactive=values[1]; - SystemInformation::LongLong &vmWired=values[2]; - return ((vmActive+vmInactive+vmWired)*psz)/1024; + SystemInformation::LongLong &vmWired=values[0]; + SystemInformation::LongLong &vmActive=values[1]; + return ((vmActive+vmWired)*psz)/1024; #else return 0; #endif diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index e3428f8..544a638 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -35,10 +35,12 @@ #include <fstream> #include <sstream> #include <set> +#include <vector> // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 +# include "RegularExpression.hxx.in" # include "SystemTools.hxx.in" # include "Directory.hxx.in" # include "FStream.hxx.in" @@ -87,6 +89,7 @@ // Windows API. #if defined(_WIN32) # include <windows.h> +# include <winioctl.h> # ifndef INVALID_FILE_ATTRIBUTES # define INVALID_FILE_ATTRIBUTES ((DWORD)-1) # endif @@ -2754,6 +2757,106 @@ std::string SystemTools::GetLastSystemError() return strerror(e); } +#ifdef _WIN32 + +static bool IsJunction(const std::wstring& source) +{ +#ifdef FSCTL_GET_REPARSE_POINT + const DWORD JUNCTION_ATTRS = FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_REPARSE_POINT; + DWORD attrs = GetFileAttributesW(source.c_str()); + if (attrs == INVALID_FILE_ATTRIBUTES) + { + return false; + } + if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS) + { + return false; + } + + // Adjust privileges so that we can succefully open junction points. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Query whether this is a reparse point or not. + BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) buffer; + DWORD sentinel; + + BOOL success = DeviceIoControl( + dir, FSCTL_GET_REPARSE_POINT, + NULL, 0, + reparse_buffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, + &sentinel, NULL); + + CloseHandle(dir); + + return (success && (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)); +#else + return false; +#endif +} + +static bool DeleteJunction(const std::wstring& source) +{ +#ifdef FSCTL_DELETE_REPARSE_POINT + // Adjust privileges so that we can succefully open junction points as + // read/write. + HANDLE token; + TOKEN_PRIVILEGES privs; + OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token); + LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid); + privs.PrivilegeCount = 1; + privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL, NULL); + CloseHandle(token); + + HANDLE dir = CreateFileW(source.c_str(), GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if (dir == INVALID_HANDLE_VALUE) + { + return false; + } + + // Set up the structure so that we can delete the junction. + std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0); + REPARSE_GUID_DATA_BUFFER *reparse_buffer = + (REPARSE_GUID_DATA_BUFFER*) &buffer[0]; + DWORD sentinel; + + reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; + + BOOL success = DeviceIoControl( + dir, FSCTL_DELETE_REPARSE_POINT, + reparse_buffer, REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, + NULL, 0, + &sentinel, NULL); + + CloseHandle(dir); + + return !!success; +#else + return false; +#endif +} +#endif + bool SystemTools::RemoveFile(const std::string& source) { #ifdef _WIN32 @@ -2781,6 +2884,10 @@ bool SystemTools::RemoveFile(const std::string& source) SetLastError(err); return false; } + if (IsJunction(ws) && !DeleteJunction(ws)) + { + return false; + } if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND) diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx index ab1f83e..ae66ceb 100644 --- a/Source/kwsys/testHashSTL.cxx +++ b/Source/kwsys/testHashSTL.cxx @@ -18,7 +18,6 @@ #if 0 # include "hash_map.hxx.in" # include "hash_set.hxx.in" -# include "hashtable.hxx.in" #endif #include <iostream> diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx index 396a09d..5ff7955 100644 --- a/Source/kwsys/testIOS.cxx +++ b/Source/kwsys/testIOS.cxx @@ -18,6 +18,12 @@ #include <vector> #include <string.h> /* strlen */ +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Configure.hxx.in" +#endif + int testIOS(int, char*[]) { std::ostringstream ostr; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0639804..ba493cb 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1644,7 +1644,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release if(CMake_TEST_XCODE_VERSION AND NOT CMake_TEST_XCODE_VERSION VERSION_LESS 5 AND OSX_VERSION MATCHES "^([0-9]+\\.[0-9]+)") - set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1}) + set(XCTest_BUILD_OPTIONS -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_MATCH_1} -DCMAKE_OSX_SYSROOT=macosx) ADD_TEST_MACRO(XCTest ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -V) endif() diff --git a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake new file mode 100644 index 0000000..a93e7f5 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake @@ -0,0 +1,22 @@ +string(TIMESTAMP timestamp "[%Y-%m-%d %H:%M:%S] %s" UTC) + +string(TIMESTAMP unix_time "%s") + +string(TIMESTAMP year "%Y" UTC) +string(TIMESTAMP days "%j" UTC) + +# Doing proper date calculations here to verify unix timestamps +# could be error prone. +# At the very least use some safe lower and upper bounds to +# see if we are somewhere in the right region. + +math(EXPR years_since_epoch "${year} - 1970") +math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days}) * 86400") +math(EXPR upper_bound "((${years_since_epoch} * 366) + ${days}) * 86400") + + +if(unix_time GREATER lower_bound AND unix_time LESS upper_bound) + message("~${unix_time}~") +else() + message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound}]") +endif() diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 92e70c3..aba35fe 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -36,6 +36,8 @@ set(TIMESTAMP-IncompleteSpecifier-RESULT 0) set(TIMESTAMP-IncompleteSpecifier-STDERR "~foobar%~") set(TIMESTAMP-AllSpecifiers-RESULT 0) set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~") +set(TIMESTAMP-UnixTime-RESULT 0) +set(TIMESTAMP-UnixTime-STDERR "~[1-9][0-9]+~") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(String @@ -58,6 +60,7 @@ check_cmake_test(String TIMESTAMP-UnknownSpecifier TIMESTAMP-IncompleteSpecifier TIMESTAMP-AllSpecifiers + TIMESTAMP-UnixTime ) # Execute each test listed in StringTestScript.cmake: @@ -68,9 +71,12 @@ set(number_of_tests_expected 70) include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") execute_all_script_tests(${scriptname} number_of_tests_executed) +string(TIMESTAMP timestamp "[%Y-%m-%d %H:%M:%S] UTC %s" UTC) + # And verify that number_of_tests_executed is at least as many as we know # about as of this writing... # +message(STATUS "timestamp='${timestamp}'") message(STATUS "scriptname='${scriptname}'") message(STATUS "number_of_tests_executed='${number_of_tests_executed}'") message(STATUS "number_of_tests_expected='${number_of_tests_expected}'") diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt index 8e21c32..56fcc5d 100644 --- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -1,6 +1,7 @@ -if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile" AND + NOT CMake_TEST_NO_FindPackageModeMakefileTest) # Test whether the make is GNU make, and only add the test in this case, # since the configured makefile in this test uses $(shell ...), which diff --git a/Tests/QtAutogen/Adir/CMakeLists.txt b/Tests/QtAutogen/Adir/CMakeLists.txt index 0c7848d..a1c36ff 100644 --- a/Tests/QtAutogen/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/Adir/CMakeLists.txt @@ -3,6 +3,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) -add_library(libA SHARED libA.cpp foo.cpp bar/foo.cpp) +add_library(libA SHARED libA.cpp) target_link_libraries(libA LINK_PUBLIC ${QT_QTCORE_TARGET}) generate_export_header(libA) diff --git a/Tests/QtAutogen/Adir/bar/foo.cpp b/Tests/QtAutogen/Adir/bar/foo.cpp deleted file mode 100644 index 3f5e0a9..0000000 --- a/Tests/QtAutogen/Adir/bar/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -bar::foo::foo() {} -bar::foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/bar/foo.h b/Tests/QtAutogen/Adir/bar/foo.h deleted file mode 100644 index daf2367..0000000 --- a/Tests/QtAutogen/Adir/bar/foo.h +++ /dev/null @@ -1,10 +0,0 @@ -#include <QObject> - -namespace bar { - class foo: public QObject { - Q_OBJECT - public: - foo(); - ~foo(); - }; -} diff --git a/Tests/QtAutogen/Adir/foo.cpp b/Tests/QtAutogen/Adir/foo.cpp deleted file mode 100644 index 86e4d8e..0000000 --- a/Tests/QtAutogen/Adir/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -foo::foo() {} -foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/foo.h b/Tests/QtAutogen/Adir/foo.h deleted file mode 100644 index a51960c..0000000 --- a/Tests/QtAutogen/Adir/foo.h +++ /dev/null @@ -1,8 +0,0 @@ -#include <QObject> - -class foo: public QObject { - Q_OBJECT -public: - foo(); - ~foo(); -}; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0a388c5..5bef629 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -236,6 +236,10 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(SolutionGlobalSections) endif() +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^6789]|[6789][0-9])") + add_RunCMake_test(VS10Project) +endif() + if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) endif() diff --git a/Tests/RunCMake/VS10Project/CMakeLists.txt b/Tests/RunCMake/VS10Project/CMakeLists.txt new file mode 100644 index 0000000..91baae7 --- /dev/null +++ b/Tests/RunCMake/VS10Project/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5.0) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake new file mode 100644 index 0000000..cc2cc2e --- /dev/null +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -0,0 +1,2 @@ +include(RunCMake) +run_cmake(VsConfigurationType) diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake new file mode 100644 index 0000000..4690970 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake @@ -0,0 +1,24 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(propertyFound FALSE) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$") + set(propertyFound TRUE) + set(expectedValue "MyValue") + set(actualValue ${CMAKE_MATCH_1}) + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT propertyFound) + set(RunCMake_TEST_FAILED "Property ConfigurationType not found in project file.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake new file mode 100644 index 0000000..a73dfe8 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +add_library(foo foo.cpp) +set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue") diff --git a/Tests/RunCMake/VS10Project/foo.cpp b/Tests/RunCMake/VS10Project/foo.cpp new file mode 100644 index 0000000..2fb55ee --- /dev/null +++ b/Tests/RunCMake/VS10Project/foo.cpp @@ -0,0 +1 @@ +void foo() { } diff --git a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake index 72c82ab..028bfaf 100644 --- a/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/CornerCases.cmake @@ -29,6 +29,26 @@ macro(foo) endmacro() foo(FOO foo) +TEST(_FOO1_FOO foo) +TEST(_FOO2_FOO foo) +# Make sure a list is split +foo(FOO "foo;bar") TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") TEST(_FOO2_FOO foo) +TEST(_FOO2_UNPARSED_ARGUMENTS "bar") + +# Do not split if argn is quoted +foo(FOO "foo\\;bar") +TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") +TEST(_FOO2_FOO foo;bar) +TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED") + +# Do not split if argn is quoted +foo(FOO "foo\\\\;bar") +TEST(_FOO1_FOO foo) +TEST(_FOO1_UNPARSED_ARGUMENTS "bar") +TEST(_FOO2_FOO foo;bar) +TEST(_FOO2_UNPARSED_ARGUMENTS "UNDEFINED") diff --git a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake index 462f923..b4199ea 100644 --- a/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake +++ b/Tests/RunCMake/cmake_parse_arguments/Initialization.cmake @@ -25,6 +25,9 @@ TEST(pref_OPT1 TRUE) cmake_parse_arguments(pref "OPT1;OPT2" "" "" OPT1 OPT2) TEST(pref_OPT1 TRUE) TEST(pref_OPT2 TRUE) +cmake_parse_arguments(pref "OPT1;OPT2" "" "" "OPT1;OPT2") +TEST(pref_OPT1 TRUE) +TEST(pref_OPT2 TRUE) cmake_parse_arguments(pref "OPT1;OPT2" "" "") TEST(pref_OPT1 FALSE) TEST(pref_OPT2 FALSE) @@ -44,6 +47,9 @@ TEST(pref_SINGLE1 foo) cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" SINGLE1 foo SINGLE2 bar) TEST(pref_SINGLE1 foo) TEST(pref_SINGLE2 bar) +cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "" "SINGLE1;foo;SINGLE2;bar") +TEST(pref_SINGLE1 foo) +TEST(pref_SINGLE2 bar) cmake_parse_arguments(pref "" "SINGLE1;SINGLE2" "") TEST(pref_SINGLE1 UNDEFINED) TEST(pref_SINGLE2 UNDEFINED) @@ -63,6 +69,9 @@ TEST(pref_MULTI1 foo) cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" MULTI1 foo bar MULTI2 bar foo) TEST(pref_MULTI1 foo bar) TEST(pref_MULTI2 bar foo) +cmake_parse_arguments(pref "" "" "MULTI1;MULTI2" "MULTI1;foo;bar;MULTI2;bar;foo") +TEST(pref_MULTI1 foo bar) +TEST(pref_MULTI2 bar foo) cmake_parse_arguments(pref "" "" "MULTI1;MULTI2") TEST(pref_MULTI1 UNDEFINED) TEST(pref_MULTI2 UNDEFINED) diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt new file mode 100644 index 0000000..406e315 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-stderr.txt @@ -0,0 +1,12 @@ +^CMake Error at DOWNLOAD-hash-mismatch.cmake:[0-9]+ \(file\): + file DOWNLOAD HASH mismatch + + for file: \[.*/Tests/RunCMake/file/DOWNLOAD-hash-mismatch-build/hash-mismatch.txt\] + expected hash: \[0123456789abcdef0123456789abcdef01234567\] + actual hash: \[da39a3ee5e6b4b0d3255bfef95601890afd80709\] + status: \[0;"No error"\] + +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +status='1;HASH mismatch: expected: 0123456789abcdef0123456789abcdef01234567 actual: da39a3ee5e6b4b0d3255bfef95601890afd80709'$ diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake new file mode 100644 index 0000000..ca72692 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.cmake @@ -0,0 +1,7 @@ +file(DOWNLOAD + "file://${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-hash-mismatch.txt" + ${CMAKE_CURRENT_BINARY_DIR}/hash-mismatch.txt + EXPECTED_HASH SHA1=0123456789abcdef0123456789abcdef01234567 + STATUS status + ) +message("status='${status}'") diff --git a/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/file/DOWNLOAD-hash-mismatch.txt diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index d3dfb1b..5f85bba 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -1,5 +1,6 @@ include(RunCMake) +run_cmake(DOWNLOAD-hash-mismatch) run_cmake(INSTALL-DIRECTORY) run_cmake(INSTALL-MESSAGE-bad) run_cmake(FileOpenFailRead) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 6cdbafa..43ce998 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -16,6 +16,10 @@ run_cmake(BadSources2) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) +run_cmake(TargetTypeExe) +run_cmake(TargetTypeInvalid) +run_cmake(TargetTypeStatic) + run_cmake(CMP0056) if(RunCMake_GENERATOR MATCHES "Make|Ninja") diff --git a/Tests/RunCMake/try_compile/TargetTypeExe.cmake b/Tests/RunCMake/try_compile/TargetTypeExe.cmake new file mode 100644 index 0000000..9b6e727 --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeExe.cmake @@ -0,0 +1,14 @@ +enable_language(C) +set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + OUTPUT_VARIABLE out + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy + COPY_FILE_ERROR copy_err + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() +if(copy_err) + message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}") +endif() diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt new file mode 100644 index 0000000..08b281a --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at TargetTypeInvalid.cmake:2 \(try_compile\): + Invalid value 'INVALID' for CMAKE_TRY_COMPILE_TARGET_TYPE. Only + 'EXECUTABLE' and 'STATIC_LIBRARY' are allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake new file mode 100644 index 0000000..0bbc4ac --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeInvalid.cmake @@ -0,0 +1,2 @@ +set(CMAKE_TRY_COMPILE_TARGET_TYPE INVALID) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c) diff --git a/Tests/RunCMake/try_compile/TargetTypeStatic.cmake b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake new file mode 100644 index 0000000..006b8b8 --- /dev/null +++ b/Tests/RunCMake/try_compile/TargetTypeStatic.cmake @@ -0,0 +1,14 @@ +enable_language(C) +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +try_compile(result ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/other.c + OUTPUT_VARIABLE out + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copy + COPY_FILE_ERROR copy_err + ) +if(NOT result) + message(FATAL_ERROR "try_compile failed:\n${out}") +endif() +if(copy_err) + message(FATAL_ERROR "try_compile COPY_FILE failed:\n${copy_err}") +endif() diff --git a/Tests/RunCMake/try_compile/other.c b/Tests/RunCMake/try_compile/other.c new file mode 100644 index 0000000..6c24f10 --- /dev/null +++ b/Tests/RunCMake/try_compile/other.c @@ -0,0 +1 @@ +int other(void) { return 0; } |