-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target_compile_features in CMakeLists.txt triggers an error #32577
Comments
this happens because Zephyr has it own toolchain handling and compiler verification scheme, which means the normal CMake check is not performed and therefore the If you want to build using a specific language standard, you can do so by specifying: See more here for possible settings: |
The problem is that the framework is targeting windows, linux and zephyr, so at least for windows and linux we need the target_compile_features. It would be convenient to just set it in the CmakeLists file so every project using the framework has automatically the correct settings, or is it possible to somehow set it for zepyr in the cmake file? |
I see, and thanks for this additional info. Note: there is a wish in community to also be able to use the common CMake toolchain functionality, but that is a bigger task to introduce this, as several compile options are handled through Kconfig and the toolchain infrastructure, so it must be ensure the two principles doesn't conflict. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Changing to Enhancement to support CMake's |
If the whole point is to workaround the error caused by @Thurnheer, if it's just for you, you might want to |
The fix to this seems to be the same as I proposed here: but never got a reply on that message. |
Ah, I wasn't aware of the issue. Thanks! FWIW, I'm using the same workaround when I integrate a CMake based project as a Zephyr module. So +1 for this. |
Fixes: zephyrproject-rtos#36558 zephyrproject-rtos#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 <Torsten.Rasmussen@nordicsemi.no>
Fixed here: #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 <Torsten.Rasmussen@nordicsemi.no>
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 <Torsten.Rasmussen@nordicsemi.no>
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 <Torsten.Rasmussen@nordicsemi.no>
Fixes: zephyrproject-rtos#36558 zephyrproject-rtos#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 <Torsten.Rasmussen@nordicsemi.no>
I am developing a framework. In the framework's CMakeLists.txt I've the following statement:
target_compile_features(myFramework PRIVATE cxx_std_17)
The application and the framework are developed using C++.
When I now run west build, I got the following error during cmake configuration:
target_compile_features no known features for CXX compiler "GNU" version 9.2.0
Using the toolchains from the zephyr SDK fails while trying to compile a simple test program.
I'm using the zephyr SDK for compilation, develop on Ubuntu LTS 20.04, use west version 0.8.0 and zephyr master.
cmake version 3.16.3
Is there a way out of this?
The text was updated successfully, but these errors were encountered: