diff options
-rw-r--r-- | Help/command/add_library.rst | 6 | ||||
-rw-r--r-- | Help/manual/cmake-properties.7.rst | 1 | ||||
-rw-r--r-- | Help/prop_test/COST.rst | 14 | ||||
-rw-r--r-- | Help/prop_tgt/VS_PACKAGE_REFERENCES.rst | 13 | ||||
-rw-r--r-- | Help/release/dev/vs-add-package-references.rst | 6 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.h | 3 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake | 39 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPackageReferences.cmake | 4 |
11 files changed, 112 insertions, 5 deletions
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index b42fe42..7274e44 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -94,6 +94,12 @@ The most important properties are: See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties for more information. +An ``UNKNOWN`` library type is typically only used in the implementation of +:ref:`Find Modules`. It allows the path to an imported library (often found +using the :command:`find_library` command) to be used without having to know +what type of library it is. This is especially useful on Windows where a +static library and a DLL's import library both have the same file extension. + Object Libraries ^^^^^^^^^^^^^^^^ diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 9d2ad90..25aab8d 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -342,6 +342,7 @@ Properties on Targets /prop_tgt/VS_KEYWORD /prop_tgt/VS_MOBILE_EXTENSIONS_VERSION /prop_tgt/VS_NO_SOLUTION_DEPLOY + /prop_tgt/VS_PACKAGE_REFERENCES /prop_tgt/VS_PROJECT_IMPORT /prop_tgt/VS_SCC_AUXPATH /prop_tgt/VS_SCC_LOCALPATH diff --git a/Help/prop_test/COST.rst b/Help/prop_test/COST.rst index 0c0fca7..9300d7b 100644 --- a/Help/prop_test/COST.rst +++ b/Help/prop_test/COST.rst @@ -1,8 +1,14 @@ COST ---- -Set this to a floating point value. Tests in a test set will be run -in descending order of cost. +This property describes the cost of a test. When parallel testing is +enabled, tests in the test set will be run in descending order of cost. +Projects can explicitly define the cost of a test by setting this property +to a floating point value. -This property describes the cost of a test. You can explicitly set -this value; tests with higher ``COST`` values will run first. +When the cost of a test is not defined by the project, +:manual:`ctest <ctest(1)>` will initially use a default cost of ``0``. +It computes a weighted average of the cost each time a test is run and +uses that as an improved estimate of the cost for the next run. The more +a test is re-run in the same build directory, the more representative the +cost should become. diff --git a/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst b/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst new file mode 100644 index 0000000..5a0465b --- /dev/null +++ b/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst @@ -0,0 +1,13 @@ +VS_PACKAGE_REFERENCES +--------------------- + +Visual Studio package references for nuget. + +Adds one or more semicolon-delimited package references to a generated +Visual Studio project. The version of the package will be +underscore delimited. For example, ``boost_1.7.0;nunit_3.12.*``. + +.. code-block:: cmake + + set_property(TARGET ${TARGET_NAME} PROPERTY + VS_PACKAGE_REFERENCES "boost_1.7.0") diff --git a/Help/release/dev/vs-add-package-references.rst b/Help/release/dev/vs-add-package-references.rst new file mode 100644 index 0000000..2d260dc --- /dev/null +++ b/Help/release/dev/vs-add-package-references.rst @@ -0,0 +1,6 @@ +vs-add-package-references +------------------------- + +* A :prop_tgt:`VS_PACKAGE_REFERENCES` target property was added to + tell :ref:`Visual Studio Generators` to add references to nuget + packages. diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a3d46bc..29543b8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 20190531) +set(CMake_VERSION_PATCH 20190603) #set(CMake_VERSION_RC 1) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 3db3813..9368414 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -665,6 +665,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(e0); this->WriteAllSources(e0); this->WriteDotNetReferences(e0); + this->WritePackageReferences(e0); this->WriteImports(e0); this->WriteEmbeddedResourceGroup(e0); this->WriteXamlFilesGroup(e0); @@ -738,6 +739,33 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteGroups(); } +void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) +{ + std::vector<std::string> packageReferences; + if (const char* vsPackageReferences = + this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) { + cmSystemTools::ExpandListArgument(vsPackageReferences, packageReferences); + } + if (!packageReferences.empty()) { + Elem e1(e0, "ItemGroup"); + for (std::string const& ri : packageReferences) { + size_t versionIndex = ri.find_last_of('_'); + if (versionIndex != std::string::npos) { + WritePackageReference(e1, ri.substr(0, versionIndex), + ri.substr(versionIndex + 1)); + } + } + } +} + +void cmVisualStudio10TargetGenerator::WritePackageReference( + Elem& e1, std::string const& ref, std::string const& version) +{ + Elem e2(e1, "PackageReference"); + e2.Attribute("Include", ref); + e2.Attribute("Version", version); +} + void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) { std::vector<std::string> references; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index b83950c..860b809 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -72,6 +72,9 @@ private: void WriteExcludeFromBuild(Elem& e2, std::vector<size_t> const& exclude_configs); void WriteAllSources(Elem& e0); + void WritePackageReferences(Elem& e0); + void WritePackageReference(Elem& e1, std::string const& ref, + std::string const& version); void WriteDotNetReferences(Elem& e0); void WriteDotNetReference(Elem& e1, std::string const& ref, std::string const& hint, diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 9a0b7a9..55ca9ea 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -21,6 +21,7 @@ run_cmake(VSCSharpDefines) run_cmake(VsSdkDirectories) run_cmake(VsGlobals) run_cmake(VsProjectImport) +run_cmake(VsPackageReferences) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) run_cmake(VsJustMyCode) diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake new file mode 100644 index 0000000..4ff5327 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake @@ -0,0 +1,39 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file foo.vcxproj does not exist.") + return() +endif() + + +set(test1Library "boost") +set(test1Version "1.7.0") + + +set(test2Library "SFML") +set(test2Version "2.2.0") + +set(Library1Found FALSE) +set(Library2Found FALSE) + +file(STRINGS "${vcProjectFile}" lines) + +foreach(i 1 2) + set(testLibrary "${test${i}Library}") + set(testVersion "${test${i}Version}") + foreach(line IN LISTS lines) + if(line MATCHES "^ *<PackageReference Include=\"${testLibrary}\".*>$") + if(line MATCHES "^ *<PackageReference .* Version=\"${testVersion}\".*>$") + set(Library${i}Found TRUE) + message(STATUS "foo.vcxproj is using package reference ${testLibrary} with version ${testVersion}") + elseif() + message(STATUS "foo.vcxproj failed to define reference ${testLibrary} with version ${testVersion}") + set(Library${i}Found FALSE) + endif() + endif() + endforeach() +endforeach() + +if(NOT Library1Found OR NOT Library2Found) + set(RunCMake_TEST_FAILED "Failed to find package references") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake new file mode 100644 index 0000000..224ab18 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake @@ -0,0 +1,4 @@ +enable_language(CXX) +add_library(foo foo.cpp) + +set_property(TARGET foo PROPERTY VS_PACKAGE_REFERENCES "boost_1.7.0;SFML_2.2.0") |