Fixed cmake error: No known features for C compiler when using the assimp library from another project #4256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the fix for the cmake error:
This error occurs when configuring your project with the cmake utility, which includes the assimp library in its project using cmake.
The reason for the error is in the
assimpTargets.cmake
file (which is generated by the cmake utility based on the configuration inassimp/code/CMakeLists.txt
), specifically in the command:here because of the feature installation:
INTERFACE_COMPILE_FEATURES "c_std_99"
in the future, the cmake error described at the beginning may occur if the following conditions are met:
CMakeLists.txt
file of your project in theproject()
command specifies ONLY the C++ programming language (CXX
).add_subdirectory()
command in the correspondingCMakeLists.txt
file of which theproject()
command does not specify any programming languages at all or both C and C++ are specified (C
andCXX
).This fix makes the installation of the compiler feature private so that it only affects the compilation of the assimp library and does not affect the target of the project that uses the assimp library.
With this fix, the corresponding command in the resulting
assimpTargets.cmake
file (which will be generated by cmake) will look like this:those. as you can see from it, the installation of the c_std_99 compiler feature has been removed, which is still not required when building your project with the C++ compiler.
Closes: #4257