mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
@@ -103,7 +103,8 @@ void cmExportBuildPackageInfoGenerator::GenerateInterfacePropertiesConfig(
|
||||
Json::Value component =
|
||||
this->GenerateInterfaceConfigProperties(suffix, properties);
|
||||
if (!component.empty()) {
|
||||
configurations[config] = std::move(component);
|
||||
configurations[config.empty() ? std::string{ "noconfig" } : config] =
|
||||
std::move(component);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -117,7 +117,7 @@ void cmExportInstallPackageInfoGenerator::GenerateImportTargetsConfig(
|
||||
{
|
||||
Json::Value root;
|
||||
root["name"] = this->GetPackageName();
|
||||
root["configuration"] = config;
|
||||
root["configuration"] = (config.empty() ? "noconfig" : config);
|
||||
|
||||
Json::Value& components = root["components"];
|
||||
|
||||
|
@@ -20,6 +20,11 @@ function(expect_array content expected_length)
|
||||
_expect("length" EQUAL "${actual_length}" "${expected_length}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(expect_object content)
|
||||
string(JSON actual_type TYPE "${content}" ${ARGN})
|
||||
_expect("type" STREQUAL "${actual_type}" "OBJECT" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(expect_null content)
|
||||
string(JSON actual_type TYPE "${content}" ${ARGN})
|
||||
_expect("type" STREQUAL "${actual_type}" "NULL" ${ARGN})
|
||||
|
@@ -0,0 +1,14 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
||||
|
||||
set(out_dir "${RunCMake_BINARY_DIR}/PerConfigGeneration-build")
|
||||
|
||||
file(READ "${out_dir}/foo.cps" content)
|
||||
|
||||
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
expect_object("${content}" "components" "foo" "configurations" ${config})
|
||||
endforeach()
|
||||
else()
|
||||
include(${RunCMake_TEST_BINARY_DIR}/build_type.cmake)
|
||||
expect_object("${content}" "components" "foo" "configurations" ${config})
|
||||
endif()
|
13
Tests/RunCMake/ExportPackageInfo/PerConfigGeneration.cmake
Normal file
13
Tests/RunCMake/ExportPackageInfo/PerConfigGeneration.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
project(PerConfigGeneration CXX)
|
||||
|
||||
set(config ${CMAKE_BUILD_TYPE})
|
||||
if(NOT config)
|
||||
set(config noconfig)
|
||||
endif()
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_type.cmake" "set(config \"${config}\")")
|
||||
|
||||
add_library(foo foo.cxx)
|
||||
|
||||
install(TARGETS foo EXPORT foo)
|
||||
export(EXPORT foo PACKAGE_INFO foo)
|
@@ -40,3 +40,4 @@ run_cmake(Requirements)
|
||||
run_cmake(TargetTypes)
|
||||
run_cmake(DependsMultiple)
|
||||
run_cmake(LinkOnly)
|
||||
run_cmake(PerConfigGeneration)
|
||||
|
@@ -20,6 +20,11 @@ function(expect_array content expected_length)
|
||||
_expect("length" EQUAL "${actual_length}" "${expected_length}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(expect_object content)
|
||||
string(JSON actual_type TYPE "${content}" ${ARGN})
|
||||
_expect("type" STREQUAL "${actual_type}" "OBJECT" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(expect_null content)
|
||||
string(JSON actual_type TYPE "${content}" ${ARGN})
|
||||
_expect("type" STREQUAL "${actual_type}" "NULL" ${ARGN})
|
||||
|
@@ -0,0 +1,24 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Assertions.cmake)
|
||||
|
||||
set(out_dir "${RunCMake_BINARY_DIR}/PerConfigGeneration-build/CMakeFiles/Export/510c5684a4a8a792eadfb55bc9744983")
|
||||
|
||||
macro(check_config)
|
||||
string(TOLOWER "${config}" config_lower)
|
||||
if(NOT EXISTS "${out_dir}/foo@${config_lower}.cps")
|
||||
set(RunCMake_TEST_FAILED
|
||||
"Configuration file for '${config}' does not exist")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(READ "${out_dir}/foo@${config_lower}.cps" content)
|
||||
expect_value("${content}" "${config}" "configuration")
|
||||
endmacro()
|
||||
|
||||
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
check_config()
|
||||
endforeach()
|
||||
else()
|
||||
include(${RunCMake_TEST_BINARY_DIR}/build_type.cmake)
|
||||
check_config()
|
||||
endif()
|
13
Tests/RunCMake/InstallPackageInfo/PerConfigGeneration.cmake
Normal file
13
Tests/RunCMake/InstallPackageInfo/PerConfigGeneration.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
project(PerConfigGeneration CXX)
|
||||
|
||||
set(config ${CMAKE_BUILD_TYPE})
|
||||
if(NOT config)
|
||||
set(config noconfig)
|
||||
endif()
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/build_type.cmake" "set(config \"${config}\")")
|
||||
|
||||
add_library(foo foo.cxx)
|
||||
|
||||
install(TARGETS foo EXPORT foo)
|
||||
install(PACKAGE_INFO foo DESTINATION cps EXPORT foo)
|
@@ -48,4 +48,5 @@ run_cmake(Requirements)
|
||||
run_cmake(TargetTypes)
|
||||
run_cmake(DependsMultiple)
|
||||
run_cmake(DependsMultipleNotInstalled)
|
||||
run_cmake(PerConfigGeneration)
|
||||
run_cmake_install(Destination)
|
||||
|
Reference in New Issue
Block a user