diff options
87 files changed, 563 insertions, 366 deletions
diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index 11c59f2..1f68535 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -12,9 +12,10 @@ multiple configurations at once with :variable:`CMAKE_CONFIGURATION_TYPES` instead of only one configuration with :variable:`CMAKE_BUILD_TYPE`. One ``build-<Config>.ninja`` file will be generated for each of these configurations (with ``<Config>`` being the configuration name.) These files -are intended to be run with ``ninja -f build-<Config>.ninja``. No -``build.ninja`` file is generated by default (see below for how to generate -it.) +are intended to be run with ``ninja -f build-<Config>.ninja``. A +``build.ninja`` file is also generated, using the configuration from either +:variable:`CMAKE_DEFAULT_BUILD_TYPE` or the first item from +:variable:`CMAKE_CONFIGURATION_TYPES`. ``cmake --build . --config <Config>`` will always use ``build-<Config>.ninja`` to build. If no ``--config`` argument is specified, ``cmake --build .`` will @@ -35,7 +36,7 @@ The ``Ninja Multi-Config`` generator recognizes the following variables: Specifies the total set of configurations to build. See the variable's documentation for more information. -:variable:`CMAKE_NMC_CROSS_CONFIGS` +:variable:`CMAKE_CROSS_CONFIGS` Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of configurations available from all ``build-<Config>.ninja`` files. This variable activates cross-config mode. @@ -49,36 +50,36 @@ The ``Ninja Multi-Config`` generator recognizes the following variables: The value of this variable must be a subset of :variable:`CMAKE_CONFIGURATION_TYPES`. -:variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` +:variable:`CMAKE_DEFAULT_BUILD_TYPE` Specifies the configuration to use by default in a ``build.ninja`` file. If - this variable is specified, a ``build.ninja`` file is generated which uses - build rules from ``build-<Config>.ninja`` by default. All custom commands are - executed with this configuration. If the variable is not specified, no - ``build.ninja`` file is generated. + this variable is specified, ``build.ninja`` uses build rules from + ``build-<Config>.ninja`` by default. All custom commands are executed with + this configuration. If the variable is not specified, the first item from + :variable:`CMAKE_CONFIGURATION_TYPES` is used instead. The value of this variable must be one of the items from :variable:`CMAKE_CONFIGURATION_TYPES`. -:variable:`CMAKE_NMC_DEFAULT_CONFIGS` +:variable:`CMAKE_DEFAULT_CONFIGS` Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of configurations to build for a target in ``build.ninja`` if no ``:<Config>`` suffix is specified. If it is set to ``all``, all - configurations from :variable:`CMAKE_NMC_CROSS_CONFIGS` are used. If + configurations from :variable:`CMAKE_CROSS_CONFIGS` are used. If it is not specified, it defaults to - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG`. + :variable:`CMAKE_DEFAULT_BUILD_TYPE`. For example, if you set - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` to ``Release``, but - set :variable:`CMAKE_NMC_DEFAULT_CONFIGS` to ``Debug`` or ``all``, + :variable:`CMAKE_DEFAULT_BUILD_TYPE` to ``Release``, but + set :variable:`CMAKE_DEFAULT_CONFIGS` to ``Debug`` or ``all``, all ``<target>`` aliases in ``build.ninja`` will resolve to ``<target>:Debug`` or ``<target>:all``, but custom commands will still use the ``Release`` configuration. The value of this variable must be a subset of - :variable:`CMAKE_NMC_CROSS_CONFIGS` or be the same as - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG`. It must not be - specified if :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` or - :variable:`CMAKE_NMC_CROSS_CONFIGS` is not used. + :variable:`CMAKE_CROSS_CONFIGS` or be the same as + :variable:`CMAKE_DEFAULT_BUILD_TYPE`. It must not be + specified if :variable:`CMAKE_DEFAULT_BUILD_TYPE` or + :variable:`CMAKE_CROSS_CONFIGS` is not used. Consider the following example: @@ -104,8 +105,8 @@ This would build the ``Debug`` configuration of ``generator``, which would be used to generate ``generated.c``, which would be used to build the ``Debug`` configuration of ``generated``. -But if :variable:`CMAKE_NMC_CROSS_CONFIGS` is set to ``all``, and you -run the following instead: +But if :variable:`CMAKE_CROSS_CONFIGS` is set to ``all``, and you run the +following instead: .. code-block:: shell diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt index 4bf6024..f64c6ac 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt @@ -8,10 +8,20 @@ target_include_directories(MathFunctions # does this system provide the log and exp functions? include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(log "math.h" HAVE_LOG) check_symbol_exists(exp "math.h" HAVE_EXP) +if(NOT (HAVE_LOG AND HAVE_EXP)) + unset(HAVE_LOG CACHE) + unset(HAVE_EXP CACHE) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + if(HAVE_LOG AND HAVE_EXP) + target_link_libraries(MathFunctions PRIVATE m) + endif() +endif() +# add compile definitions if(HAVE_LOG AND HAVE_EXP) target_compile_definitions(MathFunctions PRIVATE "HAVE_LOG" "HAVE_EXP") diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index a844cbf..4fbcd4c 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -386,7 +386,7 @@ these functions using the :module:`CheckSymbolExists` module in the top-level .. literalinclude:: Step6/MathFunctions/CMakeLists.txt :language: cmake :start-after: # does this system provide the log and exp functions? - :end-before: if(HAVE_LOG AND HAVE_EXP) + :end-before: # add compile definitions Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them from ``mysqrt.cxx``: diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 1023a66..a639b5d 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -372,11 +372,14 @@ Variables that Control the Build /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX + /variable/CMAKE_CROSS_CONFIGS /variable/CMAKE_CTEST_ARGUMENTS /variable/CMAKE_CUDA_SEPARABLE_COMPILATION /variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS /variable/CMAKE_CUDA_RUNTIME_LIBRARY /variable/CMAKE_DEBUG_POSTFIX + /variable/CMAKE_DEFAULT_BUILD_TYPE + /variable/CMAKE_DEFAULT_CONFIGS /variable/CMAKE_DISABLE_PRECOMPILE_HEADERS /variable/CMAKE_ENABLE_EXPORTS /variable/CMAKE_EXE_LINKER_FLAGS @@ -428,9 +431,6 @@ Variables that Control the Build /variable/CMAKE_MODULE_LINKER_FLAGS_INIT /variable/CMAKE_MSVCIDE_RUN_PATH /variable/CMAKE_MSVC_RUNTIME_LIBRARY - /variable/CMAKE_NMC_CROSS_CONFIGS - /variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG - /variable/CMAKE_NMC_DEFAULT_CONFIGS /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED diff --git a/Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst b/Help/variable/CMAKE_CROSS_CONFIGS.rst index 6eb6494..c850af2 100644 --- a/Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst +++ b/Help/variable/CMAKE_CROSS_CONFIGS.rst @@ -1,5 +1,5 @@ -CMAKE_NMC_CROSS_CONFIGS -------------------------------- +CMAKE_CROSS_CONFIGS +------------------- Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of configurations available from all ``build-<Config>.ninja`` files in the diff --git a/Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst b/Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst index c0eab56..62ee0d2 100644 --- a/Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst +++ b/Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst @@ -1,5 +1,5 @@ -CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG -------------------------------------------- +CMAKE_DEFAULT_BUILD_TYPE +------------------------ Specifies the configuration to use by default in a ``build.ninja`` file in the :generator:`Ninja Multi-Config` generator. See the generator's documentation diff --git a/Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst b/Help/variable/CMAKE_DEFAULT_CONFIGS.rst index e2bb017..86d8a5a 100644 --- a/Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst +++ b/Help/variable/CMAKE_DEFAULT_CONFIGS.rst @@ -1,5 +1,5 @@ -CMAKE_NMC_DEFAULT_CONFIGS ---------------------------------- +CMAKE_DEFAULT_CONFIGS +--------------------- Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of configurations to build for a target in ``build.ninja`` if no ``:<Config>`` suffix is specified in diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 7efe5c4..f539b46 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -27,7 +27,7 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON) set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON) set(CMAKE_AUTOMOC_PATH_PREFIX ON) -set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE") +set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE" "Q_NAMESPACE_EXPORT") # basically all general purpose OSs support shared libs set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index f0fde8d..3354bfb 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -103,8 +103,6 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) if(NOT _SRC_EXT) set(_SRC_EXT F) endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) @@ -132,10 +130,10 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS} "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index a3e5d5d..f858b84 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -98,8 +98,6 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) if(NOT _SRC_EXT) set(_SRC_EXT F90) endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) @@ -127,10 +125,10 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS} -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}" COMPILE_OUTPUT_VARIABLE OUTPUT diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 381080b..13e4498 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -101,3 +101,7 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) # Require symbols through Fortran. add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) + +file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[ +set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>") +]]) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 33de6c6..c75067b 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -43,17 +43,11 @@ set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED}) unset(FortranCInterface_COMPILED CACHE) # Locate the sample project executable. +set(FortranCInterface_EXE) if(FortranCInterface_COMPILED) - find_program(FortranCInterface_EXE - NAMES FortranCInterface${CMAKE_EXECUTABLE_SUFFIX} - PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Release - NO_DEFAULT_PATH - ) - set(FortranCInterface_EXE ${FortranCInterface_EXE}) - unset(FortranCInterface_EXE CACHE) + include(${FortranCInterface_BINARY_DIR}/exe-Release.cmake OPTIONAL) else() set(_result "Failed to compile") - set(FortranCInterface_EXE) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Fortran/C interface test project failed with the following output:\n" "${FortranCInterface_OUTPUT}\n") diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 31fb0bf..c63a414 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200227) +set(CMake_VERSION_PATCH 20200302) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index b5c7e96..f6c1e47 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -488,24 +488,8 @@ struct cmCPluginAPISourceFile // Keep a map from real cmSourceFile instances stored in a makefile to // the CPluginAPI proxy source file. -class cmCPluginAPISourceFileMap - : public std::map<cmSourceFile*, cmCPluginAPISourceFile*> -{ -public: - using derived = std::map<cmSourceFile*, cmCPluginAPISourceFile*>; - using iterator = derived::iterator; - using value_type = derived::value_type; - cmCPluginAPISourceFileMap() = default; - ~cmCPluginAPISourceFileMap() - { - for (auto const& i : *this) { - delete i.second; - } - } - cmCPluginAPISourceFileMap(const cmCPluginAPISourceFileMap&) = delete; - cmCPluginAPISourceFileMap& operator=(const cmCPluginAPISourceFileMap&) = - delete; -}; +using cmCPluginAPISourceFileMap = + std::map<cmSourceFile*, std::unique_ptr<cmCPluginAPISourceFile>>; cmCPluginAPISourceFileMap cmCPluginAPISourceFiles; void* CCONV cmCreateSourceFile(void) @@ -536,7 +520,7 @@ void CCONV* cmGetSource(void* arg, const char* name) auto i = cmCPluginAPISourceFiles.find(rsf); if (i == cmCPluginAPISourceFiles.end()) { // Create a proxy source file object for this source. - cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile; + auto sf = cm::make_unique<cmCPluginAPISourceFile>(); sf->RealSourceFile = rsf; sf->FullPath = rsf->ResolveFullPath(); sf->SourceName = @@ -545,10 +529,9 @@ void CCONV* cmGetSource(void* arg, const char* name) cmSystemTools::GetFilenameLastExtension(sf->FullPath); // Store the proxy in the map so it can be re-used and deleted later. - cmCPluginAPISourceFileMap::value_type entry(rsf, sf); - i = cmCPluginAPISourceFiles.insert(entry).first; + i = cmCPluginAPISourceFiles.emplace(rsf, std::move(sf)).first; } - return i->second; + return i->second.get(); } return nullptr; } @@ -569,15 +552,16 @@ void* CCONV cmAddSource(void* arg, void* arg2) } // Create the proxy for the real source file. - cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile; + auto sf = cm::make_unique<cmCPluginAPISourceFile>(); sf->RealSourceFile = rsf; sf->FullPath = osf->FullPath; sf->SourceName = osf->SourceName; sf->SourceExtension = osf->SourceExtension; // Store the proxy in the map so it can be re-used and deleted later. - cmCPluginAPISourceFiles[rsf] = sf; - return sf; + auto value = sf.get(); + cmCPluginAPISourceFiles[rsf] = std::move(sf); + return value; } const char* CCONV cmSourceFileGetSourceName(void* arg) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 04f75bd..fb100b1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -16,6 +16,9 @@ #include <utility> #include <vector> +#include <cm/memory> +#include <cmext/algorithm> + #include "cmsys/Base64.h" #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" @@ -32,9 +35,6 @@ # include <unistd.h> // IWYU pragma: keep #endif -#include <cm/memory> -#include <cmext/algorithm> - #include "cmCTestBuildAndTestHandler.h" #include "cmCTestBuildHandler.h" #include "cmCTestConfigureHandler.h" @@ -201,7 +201,7 @@ struct cmCTest::Private int SubmitIndex = 0; - cmGeneratedFileStream* OutputLogFile = nullptr; + std::unique_ptr<cmGeneratedFileStream> OutputLogFile; int OutputLogFileLastTag = -1; bool OutputTestOutputOnTestFailure = false; @@ -362,10 +362,7 @@ cmCTest::cmCTest() cmSystemTools::EnableVSConsoleOutput(); } -cmCTest::~cmCTest() -{ - delete this->Impl->OutputLogFile; -} +cmCTest::~cmCTest() = default; int cmCTest::GetParallelLevel() const { @@ -3086,12 +3083,10 @@ bool cmCTest::RunCommand(std::vector<std::string> const& args, void cmCTest::SetOutputLogFileName(const char* name) { - if (this->Impl->OutputLogFile) { - delete this->Impl->OutputLogFile; - this->Impl->OutputLogFile = nullptr; - } if (name) { - this->Impl->OutputLogFile = new cmGeneratedFileStream(name); + this->Impl->OutputLogFile = cm::make_unique<cmGeneratedFileStream>(name); + } else { + this->Impl->OutputLogFile.reset(); } } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 613ae06..379836a 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -5,6 +5,9 @@ #include <cstring> #include <iostream> #include <sstream> +#include <utility> + +#include <cm/memory> #include "cmCommandArgumentLexer.h" #include "cmMakefile.h" @@ -40,10 +43,10 @@ const char* cmCommandArgumentParserHelper::AddString(const std::string& str) if (str.empty()) { return ""; } - char* stVal = new char[str.size() + 1]; - strcpy(stVal, str.c_str()); - this->Variables.push_back(stVal); - return stVal; + auto stVal = cm::make_unique<char[]>(str.size() + 1); + strcpy(stVal.get(), str.c_str()); + this->Variables.push_back(std::move(stVal)); + return this->Variables.back().get(); } const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( @@ -136,11 +139,11 @@ const char* cmCommandArgumentParserHelper::CombineUnions(const char* in1, return in1; } size_t len = strlen(in1) + strlen(in2) + 1; - char* out = new char[len]; - strcpy(out, in1); - strcat(out, in2); - this->Variables.push_back(out); - return out; + auto out = cm::make_unique<char[]>(len); + strcpy(out.get(), in1); + strcat(out.get(), in2); + this->Variables.push_back(std::move(out)); + return this->Variables.back().get(); } void cmCommandArgumentParserHelper::AllocateParserType( @@ -153,11 +156,11 @@ void cmCommandArgumentParserHelper::AllocateParserType( if (len == 0) { return; } - char* out = new char[len + 1]; - memcpy(out, str, len); - out[len] = 0; - pt->str = out; - this->Variables.push_back(out); + auto out = cm::make_unique<char[]>(len + 1); + memcpy(out.get(), str, len); + out.get()[len] = 0; + pt->str = out.get(); + this->Variables.push_back(std::move(out)); } bool cmCommandArgumentParserHelper::HandleEscapeSymbol( @@ -235,10 +238,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb) void cmCommandArgumentParserHelper::CleanupParser() { - for (char* var : this->Variables) { - delete[] var; - } - this->Variables.erase(this->Variables.begin(), this->Variables.end()); + this->Variables.clear(); } int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen) diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h index 25e6892..b46edcb 100644 --- a/Source/cmCommandArgumentParserHelper.h +++ b/Source/cmCommandArgumentParserHelper.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <memory> #include <string> #include <vector> @@ -69,7 +70,7 @@ private: void CleanupParser(); void SetError(std::string const& msg); - std::vector<char*> Variables; + std::vector<std::unique_ptr<char[]>> Variables; const cmMakefile* Makefile; std::string Result; std::string ErrorString; diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 516bbbf..fc1bbdd 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -8,6 +8,7 @@ #include <iostream> #include <utility> +#include <cm/memory> #include <cm/string_view> #include "cmsys/FStream.hxx" @@ -169,10 +170,11 @@ void cmDependsJavaParserHelper::AllocateParserType( return; } this->UnionsAvailable++; - pt->str = new char[len + 1]; + auto up = cm::make_unique<char[]>(len + 1); + pt->str = up.get(); strncpy(pt->str, str, len); pt->str[len] = 0; - this->Allocates.push_back(pt->str); + this->Allocates.push_back(std::move(up)); } void cmDependsJavaParserHelper::StartClass(const char* cls) @@ -275,10 +277,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) void cmDependsJavaParserHelper::CleanupParser() { - for (char* allocate : this->Allocates) { - delete[] allocate; - } - this->Allocates.erase(this->Allocates.begin(), this->Allocates.end()); + this->Allocates.clear(); } int cmDependsJavaParserHelper::LexInput(char* buf, int maxlen) diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h index a673b5b..c545ee2 100644 --- a/Source/cmDependsJavaParserHelper.h +++ b/Source/cmDependsJavaParserHelper.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <memory> #include <string> #include <vector> @@ -81,7 +82,7 @@ private: int CurrentDepth; int Verbose; - std::vector<char*> Allocates; + std::vector<std::unique_ptr<char[]>> Allocates; void PrintClasses(); diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx index 0b72a94..a3731c1 100644 --- a/Source/cmDynamicLoader.cxx +++ b/Source/cmDynamicLoader.cxx @@ -6,6 +6,7 @@ #include <string> #include <utility> +namespace { class cmDynamicLoaderCache { public: @@ -15,14 +16,15 @@ public: cmsys::DynamicLoader::LibraryHandle& /*p*/); bool FlushCache(const char* path); void FlushCache(); - static cmDynamicLoaderCache* GetInstance(); + static cmDynamicLoaderCache& GetInstance(); private: std::map<std::string, cmsys::DynamicLoader::LibraryHandle> CacheMap; - static cmDynamicLoaderCache* Instance; + static cmDynamicLoaderCache Instance; }; -cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = nullptr; +cmDynamicLoaderCache cmDynamicLoaderCache::Instance; +} cmDynamicLoaderCache::~cmDynamicLoaderCache() = default; @@ -64,15 +66,11 @@ void cmDynamicLoaderCache::FlushCache() for (auto const& it : this->CacheMap) { cmsys::DynamicLoader::CloseLibrary(it.second); } - delete cmDynamicLoaderCache::Instance; - cmDynamicLoaderCache::Instance = nullptr; + this->CacheMap.clear(); } -cmDynamicLoaderCache* cmDynamicLoaderCache::GetInstance() +cmDynamicLoaderCache& cmDynamicLoaderCache::GetInstance() { - if (!cmDynamicLoaderCache::Instance) { - cmDynamicLoaderCache::Instance = new cmDynamicLoaderCache; - } return cmDynamicLoaderCache::Instance; } @@ -80,15 +78,15 @@ cmsys::DynamicLoader::LibraryHandle cmDynamicLoader::OpenLibrary( const char* libname) { cmsys::DynamicLoader::LibraryHandle lh; - if (cmDynamicLoaderCache::GetInstance()->GetCacheFile(libname, lh)) { + if (cmDynamicLoaderCache::GetInstance().GetCacheFile(libname, lh)) { return lh; } lh = cmsys::DynamicLoader::OpenLibrary(libname); - cmDynamicLoaderCache::GetInstance()->CacheFile(libname, lh); + cmDynamicLoaderCache::GetInstance().CacheFile(libname, lh); return lh; } void cmDynamicLoader::FlushCache() { - cmDynamicLoaderCache::GetInstance()->FlushCache(); + cmDynamicLoaderCache::GetInstance().FlushCache(); } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index ac48287..0546186 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -12,6 +12,8 @@ #include <cstdlib> #include <iterator> #include <map> +#include <sstream> +#include <stdexcept> #include <utility> #include <cm/memory> @@ -354,6 +356,21 @@ bool HandleInMode(std::vector<std::string> const& args, return true; } +bool TryParseInteger(cmExecutionStatus& status, const std::string& str, int& i) +{ + try { + i = std::stoi(str); + } catch (std::invalid_argument&) { + std::ostringstream e; + e << "Invalid integer: '" << str << "'"; + status.SetError(e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + + return true; +} + } // anonymous namespace bool cmForEachCommand(std::vector<std::string> const& args, @@ -376,16 +393,28 @@ bool cmForEachCommand(std::vector<std::string> const& args, int stop = 0; int step = 0; if (args.size() == 3) { - stop = std::stoi(args[2]); + if (!TryParseInteger(status, args[2], stop)) { + return false; + } } if (args.size() == 4) { - start = std::stoi(args[2]); - stop = std::stoi(args[3]); + if (!TryParseInteger(status, args[2], start)) { + return false; + } + if (!TryParseInteger(status, args[3], stop)) { + return false; + } } if (args.size() == 5) { - start = std::stoi(args[2]); - stop = std::stoi(args[3]); - step = std::stoi(args[4]); + if (!TryParseInteger(status, args[2], start)) { + return false; + } + if (!TryParseInteger(status, args[3], stop)) { + return false; + } + if (!TryParseInteger(status, args[4], step)) { + return false; + } } if (step == 0) { if (start > stop) { @@ -399,6 +428,7 @@ bool cmForEachCommand(std::vector<std::string> const& args, status.SetError( cmStrCat("called with incorrect range specification: start ", start, ", stop ", stop, ", step ", step)); + cmSystemTools::SetFatalErrorOccured(); return false; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ff6ad9d..0404715 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1361,8 +1361,43 @@ void cmGlobalGenerator::ComputeBuildFileGenerators() } } +bool cmGlobalGenerator::UnsupportedVariableIsDefined(const std::string& name, + bool supported) const +{ + if (!supported && this->Makefiles.front()->GetDefinition(name)) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not support variable\n" + " " << name << "\n" + "but it has been specified." + ; + /* clang-format on */ + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return true; + } + + return false; +} + bool cmGlobalGenerator::Compute() { + // Make sure unsupported variables are not used. + if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_BUILD_TYPE", + this->SupportsDefaultBuildType())) { + return false; + } + if (this->UnsupportedVariableIsDefined("CMAKE_CROSS_CONFIGS", + this->SupportsCrossConfigs())) { + return false; + } + if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_CONFIGS", + this->SupportsDefaultConfigs())) { + return false; + } + // Some generators track files replaced during the Generate. // Start with an empty vector: this->FilesReplacedDuringGenerate.clear(); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0e7e03d..ba997b2 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -455,6 +455,10 @@ public: /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; + virtual bool SupportsDefaultBuildType() const { return false; } + virtual bool SupportsCrossConfigs() const { return false; } + virtual bool SupportsDefaultConfigs() const { return false; } + static std::string EscapeJSON(const std::string& s); void ProcessEvaluationFiles(); @@ -674,6 +678,9 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; } + bool UnsupportedVariableIsDefined(const std::string& name, + bool supported) const; + // Cache directory content and target files to be built. struct DirectoryContent { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 12a5167..86b1e0b 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2490,8 +2490,7 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams() return false; } *this->DefaultFileStream - << "# This file is a convenience file generated by\n" - << "# CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.\n\n" + << "# Build using rules for '" << this->DefaultFileConfig << "'.\n\n" << "include " << GetNinjaImplFilename(this->DefaultFileConfig) << "\n\n"; } @@ -2608,9 +2607,6 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables() std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const { - if (this->DefaultFileConfig.empty()) { - return "Debug"; - } return ""; } @@ -2626,12 +2622,14 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( std::set<std::string> configs(configsVec.cbegin(), configsVec.cend()); this->DefaultFileConfig = - state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG"); - if (!this->DefaultFileConfig.empty() && - !configs.count(this->DefaultFileConfig)) { + state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE"); + if (this->DefaultFileConfig.empty()) { + this->DefaultFileConfig = configsVec.front(); + } + if (!configs.count(this->DefaultFileConfig)) { std::ostringstream msg; msg << "The configuration specified by " - << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG (" << this->DefaultFileConfig + << "CMAKE_DEFAULT_BUILD_TYPE (" << this->DefaultFileConfig << ") is not present in CMAKE_CONFIGURATION_TYPES"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); @@ -2639,12 +2637,12 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( } std::vector<std::string> crossConfigsVec; - cmExpandList(state.GetSafeCacheEntryValue("CMAKE_NMC_CROSS_CONFIGS"), + cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CROSS_CONFIGS"), crossConfigsVec); auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec); if (!crossConfigs) { std::ostringstream msg; - msg << "CMAKE_NMC_CROSS_CONFIGS is not a subset of " + msg << "CMAKE_CROSS_CONFIGS is not a subset of " << "CMAKE_CONFIGURATION_TYPES"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); @@ -2653,7 +2651,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( this->CrossConfigs = *crossConfigs; auto defaultConfigsString = - state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_CONFIGS"); + state.GetSafeCacheEntryValue("CMAKE_DEFAULT_CONFIGS"); if (defaultConfigsString.empty()) { defaultConfigsString = this->DefaultFileConfig; } @@ -2661,9 +2659,8 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( defaultConfigsString != this->DefaultFileConfig && (this->DefaultFileConfig.empty() || this->CrossConfigs.empty())) { std::ostringstream msg; - msg << "CMAKE_NMC_DEFAULT_CONFIGS cannot be used without " - << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or " - << "CMAKE_NMC_CROSS_CONFIGS"; + msg << "CMAKE_DEFAULT_CONFIGS cannot be used without " + << "CMAKE_DEFAULT_BUILD_TYPE or CMAKE_CROSS_CONFIGS"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); return false; @@ -2677,8 +2674,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( this->CrossConfigs, defaultConfigsVec); if (!defaultConfigs) { std::ostringstream msg; - msg << "CMAKE_NMC_DEFAULT_CONFIGS is not a subset of " - << "CMAKE_NMC_CROSS_CONFIGS"; + msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); return false; diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 3db8356..5668dd1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -640,6 +640,10 @@ public: bool ReadCacheEntriesForBuild(const cmState& state) override; + bool SupportsDefaultBuildType() const override { return true; } + bool SupportsCrossConfigs() const override { return true; } + bool SupportsDefaultConfigs() const override { return true; } + protected: bool OpenBuildFileStreams() override; void CloseBuildFileStreams() override; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d123830..7daca74 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -41,7 +41,6 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm) #else this->UseLinkScript = true; #endif - this->CommandDatabase = nullptr; this->IncludeDirective = "include"; this->DefineWindowsNULL = false; @@ -49,6 +48,8 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm) this->UnixCD = true; } +cmGlobalUnixMakefileGenerator3::~cmGlobalUnixMakefileGenerator3() = default; + void cmGlobalUnixMakefileGenerator3::EnableLanguage( std::vector<std::string> const& languages, cmMakefile* mf, bool optional) { @@ -157,10 +158,9 @@ void cmGlobalUnixMakefileGenerator3::Generate() this->WriteMainMakefile2(); this->WriteMainCMakefile(); - if (this->CommandDatabase != nullptr) { + if (this->CommandDatabase) { *this->CommandDatabase << std::endl << "]"; - delete this->CommandDatabase; - this->CommandDatabase = nullptr; + this->CommandDatabase.reset(); } } @@ -168,11 +168,12 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( const std::string& sourceFile, const std::string& workingDirectory, const std::string& compileCommand) { - if (this->CommandDatabase == nullptr) { + if (!this->CommandDatabase) { std::string commandDatabaseName = this->GetCMakeInstance()->GetHomeOutputDirectory() + "/compile_commands.json"; - this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName); + this->CommandDatabase = + cm::make_unique<cmGeneratedFileStream>(commandDatabaseName); *this->CommandDatabase << "[" << std::endl; } else { *this->CommandDatabase << "," << std::endl; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 340a7ef..19b2b85 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -68,6 +68,13 @@ public: new cmGlobalGeneratorSimpleFactory<cmGlobalUnixMakefileGenerator3>()); } + ~cmGlobalUnixMakefileGenerator3() override; + + cmGlobalUnixMakefileGenerator3(const cmGlobalUnixMakefileGenerator3&) = + delete; + cmGlobalUnixMakefileGenerator3& operator=( + const cmGlobalUnixMakefileGenerator3&) = delete; + //! Get the name for the generator. std::string GetName() const override { @@ -232,7 +239,7 @@ protected: std::set<cmGeneratorTarget const*>& emitted); size_t CountProgressMarksInAll(const cmLocalGenerator& lg); - cmGeneratedFileStream* CommandDatabase; + std::unique_ptr<cmGeneratedFileStream> CommandDatabase; private: const char* GetBuildIgnoreErrorsFlag() const override { return "-i"; } diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 2c53a28..6e3508c 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -7,6 +7,8 @@ #include <sstream> #include <utility> +#include <cm/memory> + #ifndef CMAKE_BOOTSTRAP # include "cmExportInstallAndroidMKGenerator.h" #endif @@ -33,18 +35,15 @@ cmInstallExportGenerator::cmInstallExportGenerator( { if (android) { #ifndef CMAKE_BOOTSTRAP - this->EFGen = new cmExportInstallAndroidMKGenerator(this); + this->EFGen = cm::make_unique<cmExportInstallAndroidMKGenerator>(this); #endif } else { - this->EFGen = new cmExportInstallFileGenerator(this); + this->EFGen = cm::make_unique<cmExportInstallFileGenerator>(this); } exportSet->AddInstallation(this); } -cmInstallExportGenerator::~cmInstallExportGenerator() -{ - delete this->EFGen; -} +cmInstallExportGenerator::~cmInstallExportGenerator() = default; bool cmInstallExportGenerator::Compute(cmLocalGenerator* lg) { diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index cf28b35..43dd00d 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -7,6 +7,7 @@ #include <cstddef> #include <iosfwd> +#include <memory> #include <string> #include <vector> @@ -30,8 +31,12 @@ public: bool exclude_from_all, std::string filename, std::string name_space, bool exportOld, bool android); + cmInstallExportGenerator(const cmInstallExportGenerator&) = delete; ~cmInstallExportGenerator() override; + cmInstallExportGenerator& operator=(const cmInstallExportGenerator&) = + delete; + cmExportSet* GetExportSet() { return this->ExportSet; } bool Compute(cmLocalGenerator* lg) override; @@ -61,7 +66,7 @@ protected: std::string TempDir; std::string MainImportFile; - cmExportInstallFileGenerator* EFGen; + std::unique_ptr<cmExportInstallFileGenerator> EFGen; }; #endif diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index 6cbed36..53112e0 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -79,14 +79,14 @@ public: // A load_command and its associated data struct RawLoadCommand { - uint32_t type(const cmMachOHeaderAndLoadCommands* m) const + uint32_t type(const cmMachOHeaderAndLoadCommands& m) const { if (this->LoadCommand.size() < sizeof(load_command)) { return 0; } const load_command* cmd = reinterpret_cast<const load_command*>(&this->LoadCommand[0]); - return m->swap(cmd->cmd); + return m.swap(cmd->cmd); } std::vector<char> LoadCommand; }; @@ -186,8 +186,11 @@ class cmMachOInternal { public: cmMachOInternal(const char* fname); + cmMachOInternal(const cmMachOInternal&) = delete; ~cmMachOInternal(); + cmMachOInternal& operator=(const cmMachOInternal&) = delete; + // read a Mach-O file bool read_mach_o(uint32_t file_offset); @@ -202,7 +205,7 @@ public: std::string ErrorMessage; // the list of Mach-O's - std::vector<cmMachOHeaderAndLoadCommands*> MachOList; + std::vector<std::unique_ptr<cmMachOHeaderAndLoadCommands>> MachOList; }; cmMachOInternal::cmMachOInternal(const char* fname) @@ -260,12 +263,7 @@ cmMachOInternal::cmMachOInternal(const char* fname) } } -cmMachOInternal::~cmMachOInternal() -{ - for (auto& i : this->MachOList) { - delete i; - } -} +cmMachOInternal::~cmMachOInternal() = default; bool cmMachOInternal::read_mach_o(uint32_t file_offset) { @@ -280,25 +278,25 @@ bool cmMachOInternal::read_mach_o(uint32_t file_offset) return false; } - cmMachOHeaderAndLoadCommands* f = nullptr; + std::unique_ptr<cmMachOHeaderAndLoadCommands> f; if (magic == MH_CIGAM || magic == MH_MAGIC) { bool swap = false; if (magic == MH_CIGAM) { swap = true; } - f = new cmMachOHeaderAndLoadCommandsImpl<mach_header>(swap); + f = cm::make_unique<cmMachOHeaderAndLoadCommandsImpl<mach_header>>(swap); } else if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64) { bool swap = false; if (magic == MH_CIGAM_64) { swap = true; } - f = new cmMachOHeaderAndLoadCommandsImpl<mach_header_64>(swap); + f = + cm::make_unique<cmMachOHeaderAndLoadCommandsImpl<mach_header_64>>(swap); } if (f && f->read_mach_o(this->Fin)) { - this->MachOList.push_back(f); + this->MachOList.push_back(std::move(f)); } else { - delete f; this->ErrorMessage = "Failed to read Mach-O header."; return false; } @@ -333,11 +331,12 @@ bool cmMachO::GetInstallName(std::string& install_name) } // grab the first Mach-O and get the install name from that one - cmMachOHeaderAndLoadCommands* macho = this->Internal->MachOList[0]; + std::unique_ptr<cmMachOHeaderAndLoadCommands>& macho = + this->Internal->MachOList[0]; for (size_t i = 0; i < macho->load_commands().size(); i++) { const cmMachOHeaderAndLoadCommands::RawLoadCommand& cmd = macho->load_commands()[i]; - uint32_t lc_cmd = cmd.type(macho); + uint32_t lc_cmd = cmd.type(*macho); if (lc_cmd == LC_ID_DYLIB || lc_cmd == LC_LOAD_WEAK_DYLIB || lc_cmd == LC_LOAD_DYLIB) { if (sizeof(dylib_command) < cmd.LoadCommand.size()) { diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 3b2e5f3..434fb68 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -59,16 +59,12 @@ cmServer::cmServer(cmConnection* conn, bool supportExperimental) , SupportExperimental(supportExperimental) { // Register supported protocols: - this->RegisterProtocol(new cmServerProtocol1); + this->RegisterProtocol(cm::make_unique<cmServerProtocol1>()); } cmServer::~cmServer() { Close(); - - for (cmServerProtocol* p : this->SupportedProtocols) { - delete p; - } } void cmServer::ProcessRequest(cmConnection* connection, @@ -117,22 +113,22 @@ void cmServer::ProcessRequest(cmConnection* connection, } } -void cmServer::RegisterProtocol(cmServerProtocol* protocol) +void cmServer::RegisterProtocol(std::unique_ptr<cmServerProtocol> protocol) { if (protocol->IsExperimental() && !this->SupportExperimental) { - delete protocol; + protocol.reset(); return; } auto version = protocol->ProtocolVersion(); assert(version.first >= 0); assert(version.second >= 0); - auto it = std::find_if(this->SupportedProtocols.begin(), - this->SupportedProtocols.end(), - [version](cmServerProtocol* p) { - return p->ProtocolVersion() == version; - }); + auto it = std::find_if( + this->SupportedProtocols.begin(), this->SupportedProtocols.end(), + [version](const std::unique_ptr<cmServerProtocol>& p) { + return p->ProtocolVersion() == version; + }); if (it == this->SupportedProtocols.end()) { - this->SupportedProtocols.push_back(protocol); + this->SupportedProtocols.push_back(std::move(protocol)); } } @@ -297,19 +293,20 @@ void cmServer::WriteJsonObject(cmConnection* connection, } cmServerProtocol* cmServer::FindMatchingProtocol( - const std::vector<cmServerProtocol*>& protocols, int major, int minor) + const std::vector<std::unique_ptr<cmServerProtocol>>& protocols, int major, + int minor) { cmServerProtocol* bestMatch = nullptr; - for (auto protocol : protocols) { + for (const auto& protocol : protocols) { auto version = protocol->ProtocolVersion(); if (major != version.first) { continue; } if (minor == version.second) { - return protocol; + return protocol.get(); } if (!bestMatch || bestMatch->ProtocolVersion().second < version.second) { - bestMatch = protocol; + bestMatch = protocol.get(); } } return minor < 0 ? bestMatch : nullptr; diff --git a/Source/cmServer.h b/Source/cmServer.h index 3d7027b..ec40738 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -103,7 +103,7 @@ public: cmFileMonitor* FileMonitor() const; private: - void RegisterProtocol(cmServerProtocol* protocol); + void RegisterProtocol(std::unique_ptr<cmServerProtocol> protocol); // Callbacks from cmServerConnection: @@ -149,12 +149,13 @@ private: const DebugInfo* debug) const; static cmServerProtocol* FindMatchingProtocol( - const std::vector<cmServerProtocol*>& protocols, int major, int minor); + const std::vector<std::unique_ptr<cmServerProtocol>>& protocols, int major, + int minor); const bool SupportExperimental; cmServerProtocol* Protocol = nullptr; - std::vector<cmServerProtocol*> SupportedProtocols; + std::vector<std::unique_ptr<cmServerProtocol>> SupportedProtocols; friend class cmServerProtocol; friend class cmServerRequest; diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 8c3ec9f..155068cb 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -4,6 +4,8 @@ #include <utility> +#include <cm/memory> + #include "cmStringAlgorithms.h" class cmSourceGroupInternals @@ -16,7 +18,7 @@ cmSourceGroup::cmSourceGroup(std::string name, const char* regex, const char* parentName) : Name(std::move(name)) { - this->Internal = new cmSourceGroupInternals; + this->Internal = cm::make_unique<cmSourceGroupInternals>(); this->SetGroupRegex(regex); if (parentName) { this->FullName = cmStrCat(parentName, '\\'); @@ -24,10 +26,7 @@ cmSourceGroup::cmSourceGroup(std::string name, const char* regex, this->FullName += this->Name; } -cmSourceGroup::~cmSourceGroup() -{ - delete this->Internal; -} +cmSourceGroup::~cmSourceGroup() = default; cmSourceGroup::cmSourceGroup(cmSourceGroup const& r) { @@ -36,7 +35,7 @@ cmSourceGroup::cmSourceGroup(cmSourceGroup const& r) this->GroupRegex = r.GroupRegex; this->GroupFiles = r.GroupFiles; this->SourceFiles = r.SourceFiles; - this->Internal = new cmSourceGroupInternals(*r.Internal); + this->Internal = cm::make_unique<cmSourceGroupInternals>(*r.Internal); } cmSourceGroup& cmSourceGroup::operator=(cmSourceGroup const& r) diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 581dc5d..623cded 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <memory> #include <set> #include <string> #include <vector> @@ -122,7 +123,7 @@ private: */ std::vector<const cmSourceFile*> SourceFiles; - cmSourceGroupInternals* Internal; + std::unique_ptr<cmSourceGroupInternals> Internal; }; #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9127c50..d8cd705 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -25,6 +25,9 @@ #endif #if !defined(CMAKE_BOOTSTRAP) +# if defined(_WIN32) +# include <cm/memory> +# endif # include "cmCryptoHash.h" #endif @@ -908,7 +911,6 @@ std::string cmSystemTools::ComputeCertificateThumbprint( std::string thumbprint; #if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) - BYTE* certData = NULL; CRYPT_INTEGER_BLOB cryptBlob; HCERTSTORE certStore = NULL; PCCERT_CONTEXT certContext = NULL; @@ -920,12 +922,12 @@ std::string cmSystemTools::ComputeCertificateThumbprint( if (certFile != INVALID_HANDLE_VALUE && certFile != NULL) { DWORD fileSize = GetFileSize(certFile, NULL); if (fileSize != INVALID_FILE_SIZE) { - certData = new BYTE[fileSize]; + auto certData = cm::make_unique<BYTE[]>(fileSize); if (certData != NULL) { DWORD dwRead = 0; - if (ReadFile(certFile, certData, fileSize, &dwRead, NULL)) { + if (ReadFile(certFile, certData.get(), fileSize, &dwRead, NULL)) { cryptBlob.cbData = fileSize; - cryptBlob.pbData = certData; + cryptBlob.pbData = certData.get(); // Verify that this is a valid cert if (PFXIsPFXBlob(&cryptBlob)) { @@ -961,7 +963,6 @@ std::string cmSystemTools::ComputeCertificateThumbprint( } } } - delete[] certData; } } CloseHandle(certFile); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8da113e..121ff6e 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -981,17 +981,11 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) // If the resource was NOT added using a relative path (which should // be the default), we have to provide a link here if (!useRelativePath) { - std::string link; - if (obj.find(srcDir) == 0) { - link = obj.substr(srcDir.length() + 1); - } else if (obj.find(binDir) == 0) { - link = obj.substr(binDir.length() + 1); - } else { + std::string link = this->GetCSharpSourceLink(oi); + if (link.empty()) { link = cmsys::SystemTools::GetFilenameName(obj); } - if (!link.empty()) { - e2.Element("Link", link); - } + e2.Element("Link", link); } // Determine if this is a generated resource from a .Designer.cs file std::string designerResource = @@ -1054,25 +1048,6 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0) Elem e2(e1, xamlType); this->WriteSource(e2, oi); e2.SetHasElements(); - if (this->ProjectType == csproj && !this->InSourceBuild) { - // add <Link> tag to written XAML source if necessary - const std::string& srcDir = - this->Makefile->GetCurrentSourceDirectory(); - const std::string& binDir = - this->Makefile->GetCurrentBinaryDirectory(); - std::string link; - if (obj.find(srcDir) == 0) { - link = obj.substr(srcDir.length() + 1); - } else if (obj.find(binDir) == 0) { - link = obj.substr(binDir.length() + 1); - } else { - link = cmsys::SystemTools::GetFilenameName(obj); - } - if (!link.empty()) { - ConvertToWindowsSlash(link); - e2.Element("Link", link); - } - } e2.Element("SubType", "Designer"); } } @@ -1442,13 +1417,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule( } else { Elem e1(e0, "ItemGroup"); Elem e2(e1, "None"); - std::string link; - this->GetCSharpSourceLink(source, link); this->WriteSource(e2, source); e2.SetHasElements(); - if (!link.empty()) { - e2.Element("Link", link); - } } for (std::string const& c : this->Configurations) { cmCustomCommandGenerator ccg(command, c, lg); @@ -1805,30 +1775,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, std::string copyToOutDir; std::string includeInVsix; std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); - if (this->ProjectType == csproj) { - // EVERY extra source file must have a <Link>, otherwise it might not - // be visible in Visual Studio at all. The path relative to current - // source- or binary-dir is used within the link, if the file is - // in none of these paths, it is added with the plain filename without - // any path. This means the file will show up at root-level of the csproj - // (where CMakeLists.txt etc. are). - if (!this->InSourceBuild) { - toolHasSettings = true; - std::string fullFileName = sf->GetFullPath(); - std::string srcDir = this->Makefile->GetCurrentSourceDirectory(); - std::string binDir = this->Makefile->GetCurrentBinaryDirectory(); - if (fullFileName.find(binDir) != std::string::npos) { - sourceLink.clear(); - } else if (fullFileName.find(srcDir) != std::string::npos) { - sourceLink = fullFileName.substr(srcDir.length() + 1); - } else { - // fallback: add plain filename without any path - sourceLink = cmsys::SystemTools::GetFilenameName(fullFileName); - } - if (!sourceLink.empty()) { - ConvertToWindowsSlash(sourceLink); - } - } + if (this->ProjectType == csproj && !this->InSourceBuild) { + toolHasSettings = true; } if (ext == "hlsl") { tool = "FXCompile"; @@ -2047,9 +1995,6 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, if (!settingsLastGenOutput.empty()) { e2.Element("LastGenOutput", settingsLastGenOutput); } - if (!sourceLink.empty()) { - e2.Element("Link", sourceLink); - } if (!subType.empty()) { e2.Element("SubType", subType); } @@ -2102,6 +2047,20 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, ConvertToWindowsSlash(sourceFile); e2.Attribute("Include", sourceFile); + if (this->ProjectType == csproj && !this->InSourceBuild) { + // For out of source projects we have to provide a link (if not specified + // via property) for every source file (besides .cs files) otherwise they + // will not be visible in VS at all. + // First we check if the file is in a source group, then we check if the + // file path is relative to current source- or binary-dir, otherwise it is + // added with the plain filename without any path. This means the file will + // show up at root-level of the csproj (where CMakeLists.txt etc. are). + std::string link = this->GetCSharpSourceLink(sf); + if (link.empty()) + link = cmsys::SystemTools::GetFilenameName(sf->GetFullPath()); + e2.Element("Link", link); + } + ToolSource toolSource = { sf, forceRelative }; this->Tools[e2.Tag].push_back(toolSource); } @@ -2461,12 +2420,6 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( std::string f = source->GetFullPath(); using CsPropMap = std::map<std::string, std::string>; CsPropMap sourceFileTags; - // set <Link> tag if necessary - std::string link; - this->GetCSharpSourceLink(source, link); - if (!link.empty()) { - sourceFileTags["Link"] = link; - } this->GetCSharpSourceProperties(&sf, sourceFileTags); // write source file specific tags if (!sourceFileTags.empty()) { @@ -4869,24 +4822,34 @@ void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties( } } -void cmVisualStudio10TargetGenerator::GetCSharpSourceLink( - cmSourceFile const* sf, std::string& link) +std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink( + cmSourceFile const* source) { - std::string const& sourceFilePath = sf->GetFullPath(); - std::string const& binaryDir = LocalGenerator->GetCurrentBinaryDirectory(); - - if (!cmSystemTools::IsSubDirectory(sourceFilePath, binaryDir)) { - const std::string& stripFromPath = - this->Makefile->GetCurrentSourceDirectory(); - if (sourceFilePath.find(stripFromPath) == 0) { - if (const char* l = sf->GetProperty("VS_CSHARP_Link")) { - link = l; - } else { - link = sourceFilePath.substr(stripFromPath.length() + 1); - } - ConvertToWindowsSlash(link); - } - } + // For out of source files, we first check if a matching source group + // for this file exists, otherwise we check if the path relative to current + // source- or binary-dir is used within the link and return that + std::string link; + std::string const& fullFileName = source->GetFullPath(); + std::string const& srcDir = this->Makefile->GetCurrentSourceDirectory(); + std::string const& binDir = this->Makefile->GetCurrentBinaryDirectory(); + // unfortunately we have to copy the source groups, because + // FindSourceGroup uses a regex which is modifying the group + std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups(); + cmSourceGroup* sourceGroup = + this->Makefile->FindSourceGroup(fullFileName, sourceGroups); + if (sourceGroup && !sourceGroup->GetFullName().empty()) { + link = sourceGroup->GetFullName() + "/" + + cmsys::SystemTools::GetFilenameName(fullFileName); + } else if (fullFileName.find(srcDir) == 0) { + link = fullFileName.substr(srcDir.length() + 1); + } else if (fullFileName.find(binDir) == 0) { + link = fullFileName.substr(binDir.length() + 1); + } else if (const char* l = source->GetProperty("VS_CSHARP_Link")) { + link = l; + } + + ConvertToWindowsSlash(link); + return link; } std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath( diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 30027c9..4977c1a 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -183,7 +183,7 @@ private: std::map<std::string, std::string>& tags); void WriteCSharpSourceProperties( Elem& e2, const std::map<std::string, std::string>& tags); - void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link); + std::string GetCSharpSourceLink(cmSourceFile const* source); private: friend class cmVS10GeneratorOptions; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 33c7514..6f86a5f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1605,7 +1605,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH DEPENDS ExternalProjectUpdateSetup ) # do each of the tutorial steps - function(add_tutorial_test step_name use_mymath) + function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex) set(tutorial_test_name Tutorial${step_name}) set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}") if (use_mymath) @@ -1623,19 +1623,28 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH ${build_generator_args} --build-project Tutorial --build-options ${tutorial_build_options} - --test-command Tutorial 25.0) + --test-command Tutorial ${tutorial_arg}) + set_tests_properties(${tutorial_test_name} PROPERTIES + PASS_REGULAR_EXPRESSION ${pass_regex}) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build") endfunction() if(NOT CMake_TEST_EXTERNAL_CMAKE) foreach(STP RANGE 2 12) - add_tutorial_test(Step${STP} TRUE) + if (STP EQUAL 6) + set(pass_regex ".*using log and exp") + else() + set(pass_regex "The square root of 25 is 5") + endif() + add_tutorial_test(Step${STP} TRUE 25 ${pass_regex}) endforeach() - add_tutorial_test(Complete TRUE) + set(pass_regex "The square root of 25 is 5") + add_tutorial_test(Complete TRUE 25 ${pass_regex}) foreach(STP RANGE 3 12) - add_tutorial_test(Step${STP} FALSE) + add_tutorial_test(Step${STP} FALSE 25 ${pass_regex}) endforeach() - add_tutorial_test(Complete FALSE) + add_tutorial_test(Complete FALSE 25 ${pass_regex}) endif() add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt index 82049c7..42cbe2e 100644 --- a/Tests/CSharpOnly/CMakeLists.txt +++ b/Tests/CSharpOnly/CMakeLists.txt @@ -2,7 +2,9 @@ project (CSharpOnly CSharp) # C# does not make any difference between STATIC and SHARED libs -add_library(lib1 STATIC lib1.cs) +add_library(lib1 STATIC lib1.cs nested/lib1.cs) +#without the source group this test will fail to compile +source_group(nested FILES nested/lib1.cs) add_library(lib2 SHARED lib2.cs) add_executable(CSharpOnly csharponly.cs) diff --git a/Tests/CSharpOnly/csharponly.cs b/Tests/CSharpOnly/csharponly.cs index ad4641a..3890c82 100644 --- a/Tests/CSharpOnly/csharponly.cs +++ b/Tests/CSharpOnly/csharponly.cs @@ -5,10 +5,8 @@ namespace CSharpOnly public static void Main(string[] args) { int val = Lib1.getResult(); - Lib2 l = new Lib2(); - val = l.myVal; - + val = val + l.myVal + nested.Lib1.getResult(); return; } } diff --git a/Tests/CSharpOnly/nested/lib1.cs b/Tests/CSharpOnly/nested/lib1.cs new file mode 100644 index 0000000..c2fde4b --- /dev/null +++ b/Tests/CSharpOnly/nested/lib1.cs @@ -0,0 +1,13 @@ +namespace CSharpOnly +{ + namespace nested + { + public class Lib1 + { + public static int getResult() + { + return 23; + } + } + } +} diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index d945375..4327c2f 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -51,40 +51,36 @@ add_custom_target(checksayhello ALL ) add_dependencies(checksayhello sayhello) -# Exclude this test on IBM XL for now because the check strangely -# fails with 'ld: 0706-029 Use a number with the -H flag'. -if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL XL) - set(err_log ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log) - file(REMOVE "${err_log}") - include(CheckFortranSourceCompiles) - unset(HAVE_PRINT CACHE) - CHECK_Fortran_SOURCE_COMPILES([[ +set(err_log ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log) +file(REMOVE "${err_log}") +include(CheckFortranSourceCompiles) +unset(HAVE_PRINT CACHE) +CHECK_Fortran_SOURCE_COMPILES([[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' END ]] HAVE_PRINT) - if(NOT HAVE_PRINT) - if(EXISTS "${err_log}") - file(READ "${err_log}" err) - endif() - string(REPLACE "\n" "\n " err " ${err}") - message(SEND_ERROR "CHECK_Fortran_SOURCE_COMPILES for HAVE_PRINT failed:\n" - "${err}") +if(NOT HAVE_PRINT) + if(EXISTS "${err_log}") + file(READ "${err_log}" err) endif() + string(REPLACE "\n" "\n " err " ${err}") + message(SEND_ERROR "CHECK_Fortran_SOURCE_COMPILES for HAVE_PRINT failed:\n" + "${err}") +endif() - unset(Fortran_BOGUS_FLAG CACHE) - include(CheckFortranCompilerFlag) - CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG) - if (Fortran_BOGUS_FLAG) - message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed") - endif() +unset(Fortran_BOGUS_FLAG CACHE) +include(CheckFortranCompilerFlag) +CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG) +if (Fortran_BOGUS_FLAG) + message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed") +endif() - unset(Fortran_RUN_FLAG CACHE) - include(CheckFortranSourceRuns) - check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90) - if(NOT Fortran_RUN_FLAG) - message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed") - endif() +unset(Fortran_RUN_FLAG CACHE) +include(CheckFortranSourceRuns) +check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90) +if(NOT Fortran_RUN_FLAG) + message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed") endif() # Test generation of preprocessed sources. diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt new file mode 100644 index 0000000..a5d149d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_CROSS_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake new file mode 100644 index 0000000..75d0c47 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_CROSS_CONFIGS "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt new file mode 100644 index 0000000..8aa3ed3 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_BUILD_TYPE + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake new file mode 100644 index 0000000..64c7feb --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_BUILD_TYPE "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt new file mode 100644 index 0000000..040bf4d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake new file mode 100644 index 0000000..5b65172 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_CONFIGS "") diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 76d843c..9fd4499 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -50,3 +50,9 @@ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(RemoveCache) file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") run_cmake(RemoveCache) + +if(NOT RunCMake_GENERATOR MATCHES "^Ninja Multi-Config$") + run_cmake(NoCMAKE_CROSS_CONFIGS) + run_cmake(NoCMAKE_DEFAULT_BUILD_TYPE) + run_cmake(NoCMAKE_DEFAULT_CONFIGS) +endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt index 6e165e8..76c5ecf 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error: - CMAKE_NMC_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES + CMAKE_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt index 114a8a3..5aa9038 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt @@ -1,6 +1,6 @@ ^CMake Error: - The configuration specified by CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG - \(RelWithDebInfo\) is not present in CMAKE_CONFIGURATION_TYPES + The configuration specified by CMAKE_DEFAULT_BUILD_TYPE \(RelWithDebInfo\) is + not present in CMAKE_CONFIGURATION_TYPES CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt index 8d52189..6c2df86 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS is not a subset of CMAKE_NMC_CROSS_CONFIGS + CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt index f9cb56d..5d090a0 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt @@ -1,6 +1,6 @@ ^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS cannot be used without - CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or CMAKE_NMC_CROSS_CONFIGS + CMAKE_DEFAULT_CONFIGS cannot be used without CMAKE_DEFAULT_BUILD_TYPE or + CMAKE_CROSS_CONFIGS CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt deleted file mode 100644 index f9cb56d..0000000 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt +++ /dev/null @@ -1,6 +0,0 @@ -^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS cannot be used without - CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or CMAKE_NMC_CROSS_CONFIGS - - -CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index a608e9e..b07b4f7 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -81,7 +81,9 @@ endfunction() set(RunCMake_TEST_NO_CLEAN 1) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Simple-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +# IMPORTANT: Setting RelWithDebInfo as the first item in CMAKE_CONFIGURATION_TYPES +# generates a build.ninja file with that configuration +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo\\;Debug\\;Release\\;MinSizeRel;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Simple) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -113,7 +115,7 @@ run_ninja(Simple default-build-file-clean-minsizerel build.ninja clean:MinSizeRe run_ninja(Simple default-build-file-all build.ninja all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAlias-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(SimpleDefaultBuildAlias) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -122,7 +124,7 @@ run_ninja(SimpleDefaultBuildAlias all build.ninja all) run_ninja(SimpleDefaultBuildAlias clean build.ninja clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasList-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(SimpleDefaultBuildAliasList) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -133,7 +135,7 @@ run_ninja(SimpleDefaultBuildAliasList all-relwithdebinfo build.ninja all:RelWith run_ninja(SimpleDefaultBuildAliasList clean-configs build.ninja clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasListCross-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo;-DCMAKE_NMC_DEFAULT_CONFIGS=all;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=Debug\\;Release") run_cmake_configure(SimpleDefaultBuildAliasListCross) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -141,27 +143,23 @@ run_ninja(SimpleDefaultBuildAliasListCross target-configs build.ninja simpleexe) unset(RunCMake_TEST_BINARY_DIR) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo") run_cmake(InvalidCrossConfigs) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo") run_cmake(InvalidDefaultBuildFileConfig) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release\\;RelWithDebInfo") run_cmake(InvalidDefaultConfigsCross) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all") -run_cmake(InvalidDefaultConfigsNoDefaultFile) -unset(RunCMake_TEST_OPTIONS) - -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all") run_cmake(InvalidDefaultConfigsNoCross) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release") run_cmake(DefaultBuildFileConfig) unset(RunCMake_TEST_OPTIONS) @@ -178,7 +176,7 @@ run_ninja(SimpleNoCross all-all build-Debug.ninja all:all) run_cmake_build(SimpleNoCross all-clean Debug clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleCrossConfigs-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release") run_cmake_configure(SimpleCrossConfigs) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_ninja(SimpleCrossConfigs release-in-release-graph build-Release.ninja simpleexe) @@ -192,21 +190,21 @@ run_cmake_build(SimpleCrossConfigs all-all-in-release-graph Release all:all) run_cmake_build(SimpleCrossConfigs all-relwithdebinfo-in-release-graph Release all:RelWithDebInfo) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Framework-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Framework) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_cmake_build(Framework framework Debug all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FrameworkDependencyAutogen-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(FrameworkDependencyAutogen) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_cmake_build(FrameworkDependencyAutogen framework Release test2:Debug) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(CustomCommandGenerator) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -223,7 +221,7 @@ run_ninja(CustomCommandGenerator release-in-debug-graph build-Debug.ninja genera run_cmake_command(CustomCommandGenerator-release-in-debug-graph-generated "${TARGET_FILE_generated_Release}") set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandsAndTargets-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(CustomCommandsAndTargets) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -243,7 +241,7 @@ unset(RunCMake_TEST_BINARY_DIR) run_cmake(CustomCommandDepfile) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(PostfixAndLocation) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -258,14 +256,14 @@ run_ninja(Clean release-notall build-Release.ninja exenotall) run_cmake_build(Clean release-clean Release clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AdditionalCleanFiles-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(AdditionalCleanFiles) unset(RunCMake_TEST_OPTIONS) run_cmake_build(AdditionalCleanFiles release-clean Release clean) run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Install) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -287,7 +285,7 @@ endif() if(CMake_TEST_Qt5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") + set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Qt5) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) diff --git a/Tests/RunCMake/VS10Project/CSharpSourceGroup/foo.cs b/Tests/RunCMake/VS10Project/CSharpSourceGroup/foo.cs new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/CSharpSourceGroup/foo.cs @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile.cmake b/Tests/RunCMake/VS10Project/CSharpSourceGroup/images/empty.bmp index e69de29..e69de29 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile.cmake +++ b/Tests/RunCMake/VS10Project/CSharpSourceGroup/images/empty.bmp diff --git a/Tests/RunCMake/VS10Project/CSharpSourceGroup/nested/baz.cs b/Tests/RunCMake/VS10Project/CSharpSourceGroup/nested/baz.cs new file mode 100644 index 0000000..d5d334a --- /dev/null +++ b/Tests/RunCMake/VS10Project/CSharpSourceGroup/nested/baz.cs @@ -0,0 +1,3 @@ +void baz() +{ +} diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index ff31a74..3ca7cc0 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -3,12 +3,12 @@ cmake_policy(SET CMP0057 NEW) include(RunCMake) cmake_policy(SET CMP0054 NEW) +run_cmake(VsCsharpSourceGroup) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) run_cmake(RuntimeLibrary) run_cmake(SourceGroupCMakeLists) run_cmake(SourceGroupTreeCMakeLists) - run_cmake(VsConfigurationType) run_cmake(VsTargetsFileReferences) run_cmake(VsCustomProps) diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake new file mode 100644 index 0000000..3b5c70f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake @@ -0,0 +1,22 @@ +set(csProjFile "${RunCMake_TEST_BINARY_DIR}/VsCsharpSourceGroup.csproj") +if(NOT EXISTS "${csProjFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjFile} does not exist.") + return() +endif() + +file(STRINGS "${csProjFile}" lines) + +include(${RunCMake_TEST_SOURCE_DIR}/VsCsharpSourceGroupHelpers.cmake) + +set(SOURCE_GROUPS_TO_FIND + "CSharpSourceGroup" + "CSharpSourceGroup/nested" + "Images" +) + +foreach(GROUP_NAME IN LISTS ${SOURCE_GROUPS_TO_FIND}) + find_source_group("${lines}" ${GROUP_NAME}) + if(NOT ${SOURCE_GROUP_FOUND}) + return() + endif() +endforeach() diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake new file mode 100644 index 0000000..024993c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake @@ -0,0 +1,16 @@ +enable_language(CSharp) +set(CMAKE_CONFIGURATION_TYPES Debug) + +set(SRC_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/foo.cs + ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/nested/baz.cs +) + +set(IMAGE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/Images/empty.bmp +) + +add_library(VsCsharpSourceGroup SHARED ${SRC_FILES} ${IMAGE_FILES}) +source_group("CSharpSourceGroup" FILES ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/foo.cs) +source_group("CSharpSourceGroup/nested" FILES ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/nested/baz.cs) +source_group("Images" FILES ${IMAGE_FILES}) diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroupHelpers.cmake b/Tests/RunCMake/VS10Project/VsCsharpSourceGroupHelpers.cmake new file mode 100644 index 0000000..bfa9a67 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroupHelpers.cmake @@ -0,0 +1,15 @@ +function(find_source_group LINES NAME) + set(foundSourceGroupLink 0) + foreach(line IN LISTS LINES) + if(line MATCHES "<Link>${NAME}</Link>") + set(foundSourceGroupLink 1) + endif() + endforeach() + + if(NOT foundSourceGroupLink) + set(RunCMake_TEST_FAILED "Source group link for ${NAME} not found." PARENT_SCOPE) + set(SOURCE_GROUP_FOUND 0 PARENT_SCOPE) + return() + endif() + set(SOURCE_GROUP_FOUND 1 PARENT_SCOPE) +endfunction() diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake index 8f50203..22a0a75 100644 --- a/Tests/RunCMake/foreach/RunCMakeTest.cmake +++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake @@ -12,3 +12,10 @@ run_cmake(foreach-ZIP_LISTS-with-LISTS-mix-test) run_cmake(foreach-ZIP_LISTS-multiple-iter-vars-test) run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-1) run_cmake(foreach-ZIP_LISTS-iter-vars-mismatch-test-2) +run_cmake(foreach-RANGE-non-int-test-1) +run_cmake(foreach-RANGE-non-int-test-2-1) +run_cmake(foreach-RANGE-non-int-test-2-2) +run_cmake(foreach-RANGE-non-int-test-3-1) +run_cmake(foreach-RANGE-non-int-test-3-2) +run_cmake(foreach-RANGE-non-int-test-3-3) +run_cmake(foreach-RANGE-invalid-test) diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt new file mode 100644 index 0000000..66efdc1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-invalid-test\.cmake:[0-9]+ \(foreach\): + foreach called with incorrect range specification: start 2, stop 1, step 1 +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake new file mode 100644 index 0000000..2f8eaba --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-invalid-test.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 2 1 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt new file mode 100644 index 0000000..78355dc --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake new file mode 100644 index 0000000..452fbdf --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt new file mode 100644 index 0000000..787ffc1 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-2-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake new file mode 100644 index 0000000..885c805 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt new file mode 100644 index 0000000..70cc73f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-2-2\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake new file mode 100644 index 0000000..d52aeb9 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-2-2.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 b) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt new file mode 100644 index 0000000..5803fe8 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-1\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake new file mode 100644 index 0000000..33a488d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-1.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE b 1 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt new file mode 100644 index 0000000..189c60d --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-2\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake new file mode 100644 index 0000000..ff119d3 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-2.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 b 1) +endforeach() diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt new file mode 100644 index 0000000..ee9e62c --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at foreach-RANGE-non-int-test-3-3\.cmake:[0-9]+ \(foreach\): + foreach Invalid integer: 'b' +Call Stack \(most recent call first\): + CMakeLists\.txt:3 \(include\)$ diff --git a/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake new file mode 100644 index 0000000..fdebdf0 --- /dev/null +++ b/Tests/RunCMake/foreach/foreach-RANGE-non-int-test-3-3.cmake @@ -0,0 +1,2 @@ +foreach(a RANGE 1 1 b) +endforeach() |