Skip to content

Conversation

@zephyrbot
Copy link

Backport 917d502 from #39014

Fixes: #36558 #32577

This commit introduces CMAKE_C_COMPILE_FEATURES and
CMAKE_CXX_COMPILE_FEATURES.

This allows users to use the `target_compile_features()` in their own
code.

In Zephyr, the CMAKE_C/CXX_COMPILE_FEATURES are defined based on the
compiler and the Kconfig / CSTD setting.
Doing so ensures that a user compiling Zephyr with c99 and specifies
`target_compile_features(<target> ... c_std_11)` will get an error.
And similar if building Zephyr with C++ support and c++11, but testing
for `target_compile_features(<target> ... cxx_std_17)`.

For example in the C++ case, the user must ensure that Zephyr is
compiled with C++17, that is: CPLUSPLUS=y and STD_CPP17=y, in which case
the CMAKE_CXX_COMPILE_FEATURES will contain support for C++17 and thus
the `target_compile_features(<target> ... cxx_std_17)` will succeed.

Signed-off-by: Torsten Rasmussen <[email protected]>
nashif
nashif previously requested changes Oct 1, 2021
Copy link
Member

@nashif nashif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one looks like a feature to me, lets wait with merging.

cfriedt
cfriedt previously approved these changes Oct 2, 2021
@cfriedt cfriedt dismissed their stale review October 2, 2021 00:39

waiting for approval

@nashif nashif added this to the v2.7.1 milestone Oct 5, 2021
@tejlmand
Copy link
Contributor

tejlmand commented Oct 6, 2021

this one looks like a feature to me, lets wait with merging.

I would say it depends from the direction you look at this.
The reporters consider it a bug #36558 #32577 (both were filed as bugs), and I tend to agree as I commented here:
#36558 (comment)

BTW, is this really a bug? It sounds like an enhancement.

I would say it depends on the direction from where you see this.
The fact that we have our own toolchain testing and thus breaks the way standard CMake works could be argued as a bug.
We shouldn't break built-in features of CMake (even though Zephyr itself doesn't use this feature).

But better support for downstream users can be argued as an enhancement.

@nashif nashif merged commit 6173013 into v2.7-branch Oct 19, 2021
@nashif nashif deleted the backport-39014-to-v2.7-branch branch October 29, 2021 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants