I'm trying to use target_compile_feature in my biicode block. As far as I know, this is currently the best way to ask cmake for a specific c++ standard version, since it will know what (if any) flags to add to the compilation, and fail with an error if the compiler being used does not support the features we requested.
I added this line to my very simple CMakeLists.txt (no changes from the boost example in biicode's blog):
target_compile_features(${BII_BLOCK_TARGET} PRIVATE cxx_auto_type)
When running bii build, I'm greeted with this error:
CMake Error at bii_test/alchemist/blocks/sennin/deckbox_loader/CMakeLists.txt:13 (target_compile_features):
target_compile_features may only be set INTERFACE properties on INTERFACE
targets
Setting the cxx_auto_type at a PUBLIC or PRIVATE scope has exactly the same result.
I want to avoid using the CXX_STANDARD and CXX_STANDARD_REQUIRED because the first is a soft request (if the requested standard is not supported cmake will still allow us to attempt to build the code) and the second enforces that there is someway to request full support for the whole requested standard standard (and in the case of Visual Studio, fail, because there is no such flag).
I don't know anything about bii, but presumably BII_BLOCK_TARGET
is something it provides? And you're supposed to use it with target_link_libraries
or something?
Anyway, try the INTERFACE
keyword.
target_compile_features(${BII_BLOCK_TARGET} INTERFACE cxx_auto_type)
http://www.cmake.org/cmake/help/v3.2/manual/cmake-compile-features.7.html
http://www.cmake.org/cmake/help/v3.2/manual/cmake-buildsystem.7.html#transitive-usage-requirements