mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
CPS: Fix C features
Fix a typo in the logic that generates CPS compile features for C language standards. Update tests to cover both C and C++. Fixes: #27618
This commit is contained in:
@@ -465,7 +465,7 @@ void cmExportPackageInfoGenerator::GenerateInterfaceCompileFeatures(
|
||||
for (auto const& value : cmList{ iter->second }) {
|
||||
if (cmHasLiteralPrefix(value, "c_std_")) {
|
||||
auto suffix = cm::string_view{ value }.substr(6, 2);
|
||||
features.emplace(cmStrCat("cxx", suffix));
|
||||
features.emplace(cmStrCat("c", suffix));
|
||||
} else if (cmHasLiteralPrefix(value, "cxx_std_")) {
|
||||
auto suffix = cm::string_view{ value }.substr(8, 2);
|
||||
features.emplace(cmStrCat("c++", suffix));
|
||||
|
||||
@@ -10,8 +10,9 @@ string(JSON component GET "${content}" "components" "foo")
|
||||
expect_value("${component}" "interface" "type")
|
||||
expect_array("${component}" 1 "includes")
|
||||
expect_value("${component}" "${CMAKE_CURRENT_LIST_DIR}/foo" "includes" 0)
|
||||
expect_array("${component}" 1 "compile_features")
|
||||
expect_array("${component}" 2 "compile_features")
|
||||
expect_value("${component}" "c++23" "compile_features" 0)
|
||||
expect_value("${component}" "c17" "compile_features" 1)
|
||||
expect_array("${component}" 1 "compile_flags")
|
||||
expect_value("${component}" "-ffast-math" "compile_flags" 0)
|
||||
expect_null("${component}" "definitions" "*" "FOO")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
add_library(foo INTERFACE)
|
||||
|
||||
target_compile_features(foo INTERFACE cxx_std_23)
|
||||
target_compile_features(foo INTERFACE c_std_17 cxx_std_23)
|
||||
target_compile_options(foo INTERFACE -ffast-math)
|
||||
target_compile_definitions(foo INTERFACE -DFOO -DBAR=BAR)
|
||||
target_include_directories(
|
||||
|
||||
@@ -10,8 +10,9 @@ string(JSON component GET "${content}" "components" "foo")
|
||||
expect_value("${component}" "interface" "type")
|
||||
expect_array("${component}" 1 "includes")
|
||||
expect_value("${component}" "@prefix@/include/foo" "includes" 0)
|
||||
expect_array("${component}" 1 "compile_features")
|
||||
expect_array("${component}" 2 "compile_features")
|
||||
expect_value("${component}" "c++23" "compile_features" 0)
|
||||
expect_value("${component}" "c17" "compile_features" 1)
|
||||
expect_array("${component}" 1 "compile_flags")
|
||||
expect_value("${component}" "-ffast-math" "compile_flags" 0)
|
||||
expect_null("${component}" "definitions" "*" "FOO")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
add_library(foo INTERFACE)
|
||||
|
||||
target_compile_features(foo INTERFACE cxx_std_23)
|
||||
target_compile_features(foo INTERFACE c_std_17 cxx_std_23)
|
||||
target_compile_options(foo INTERFACE -ffast-math)
|
||||
target_compile_definitions(foo INTERFACE -DFOO -DBAR=BAR)
|
||||
target_include_directories(
|
||||
|
||||
Reference in New Issue
Block a user