Skip to content
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

Fixed cmake error: No known features for C compiler when using the assimp library from another project #4256

Merged
merged 2 commits into from Dec 16, 2021
Merged

Fixed cmake error: No known features for C compiler when using the assimp library from another project #4256

merged 2 commits into from Dec 16, 2021

Conversation

rumgot
Copy link
Contributor

@rumgot rumgot commented Dec 14, 2021

This is the fix for the cmake error:

CMake Error in CMakeLists.txt:
  No known features for C compiler
  ""
  version.
CMake Generate step failed. Build files cannot be regenerated correctly.

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 in assimp/code/CMakeLists.txt), specifically in the command:

set_target_properties (assimp::assimp PROPERTIES
  INTERFACE_COMPILE_FEATURES "c_std_99"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:/usr/lib/x86_64-linux-gnu/libz.so>;\$<\$<CONFIG:DEBUG>:/usr/lib/x86_64-linux-gnu/libz.so>;minizip;/usr/lib/x86_64-linux-gnu/librt.so"
)

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:

  • the main (root) CMakeLists.txt file of your project in the project() command specifies ONLY the C++ programming language (CXX).
  • the main project connects the subdirectory with the add_subdirectory() command in the corresponding CMakeLists.txt file of which the project() command does not specify any programming languages ​​at all or both C and C++ are specified (C and CXX).

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:

set_target_properties(assimp::assimp PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<\$<NOT:\$<CONFIG:DEBUG>>:/usr/lib/x86_64-linux-gnu/libz.so>;\$<\$<CONFIG:DEBUG>:/usr/lib/x86_64-linux-gnu/libz.so>;minizip;/usr/lib/x86_64-linux-gnu/librt.so"
)

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

@kimkulling kimkulling merged commit 6693e7e into assimp:master Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake error: No known features for C compiler
2 participants