CMake build failed: `unknown argument -fconcepts` with Clang 15
GavinRay97 opened this issue ยท 6 comments
FetchContent_Declare(llfio
GIT_REPOSITORY https://github.com/ned14/llfio
GIT_TAG 82ea3ddb718d5a8f9633a7ee786d2a4961ade4f3
)
FetchContent_MakeAvailable(llfio)
target_link_libraries(myapp
PRIVATE llfio)
build] FAILED: _deps/llfio-build/CMakeFiles/llfio_dl.dir/src/llfio.cpp.o
[build] /usr/bin/ccache /usr/bin/clang++ -DLLFIO_DYN_LINK=1 -DLLFIO_ENABLE_TEST_IO_MULTIPLEXERS=1 -DLLFIO_INCLUDE_STORAGE_PROFILE=1 -DLLFIO_SOURCE=1 -DQUICKCPPLIB_ENABLE_VALGRIND=1 -Dllfio_dl_EXPORTS -isystem /home/user/projects/seastar-demo/build/install/include -g -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fcolor-diagnostics -fexceptions -frtti -fstack-protector-strong -Wall -Wextra -Wdocumentation -fcomment-block-commands=raceguarantees,complexity,exceptionmodel -fconcepts -std=gnu++20 -MD -MT _deps/llfio-build/CMakeFiles/llfio_dl.dir/src/llfio.cpp.o -MF _deps/llfio-build/CMakeFiles/llfio_dl.dir/src/llfio.cpp.o.d -o _deps/llfio-build/CMakeFiles/llfio_dl.dir/src/llfio.cpp.o -c /home/user/projects/seastar-demo/build/_deps/llfio-src/src/llfio.cpp
[build] clang-15: error: unknown argument: '-fconcepts'
It seems to be a property in the cppquick
library, which can be configured with CXX_CONCEPTS_FLAGS
I've tried setting it like the below, as I am using -std=c++2b
set(HAVE_CONCEPTS 1)
set(CXX_CONCEPTS_FLAGS "" CACHE STRING "The flags to enable C++ Concepts for this compiler" FORCE)
set(CXX_HAS_CONCEPTS "1" CACHE STRING "Whether this compiler supports C++ Concepts or not" FORCE)
But it still seems to want to pick up the -fconcepts
flag from somewhere unfortunately =/
Partial fix: ned14/quickcpplib#36
Funnily enough the quickcpplib script had no support for clang's concepts flag at all, so that's now fixed. Thanks to @BurningEnlightenment for that fix.
Your issue is likely caused by configuring cmake with disparate toolchains, so the above might result if you configured it using a GCC toolchain but then used the clang toolchain to consume the exported targets. Consistently using an identical toolchain for everything in a build will make your life easier - see CMAKE_TOOLCHAIN_FILE
in the cmake docs.
Alternatively, setting C++ 20 for everything would enable Concepts without needing additional compiler flags. We've been on C++ 20 at work for some time now, so it's fairly mature give or take. For C++ 20, you're better off choosing GCC and libstdc++, clang and libc++ has quality of implementation issues for C++ 20.
Is there anything else that needs to be done? If not I'd like to close this issue.
The fix was merged? Unless OP has anything further to add, I guess this issue is done?
Whoops, sorry!