The other question I have is how to add dependency on other library targets for the header set because the header sets are not really target so I can't do target_include_directories
on them
Thank @kyle.edwards and everyone who works on this to provide this amazing features! I have been trying to use this to enable clangd language server to work on cuda header file. My cmake project has set:
project(states LANGUAGES CXX CUDA)
It seems that currently the default language set on the header is c++ when I try doing something like:
target_sources(myLib INTERFACE
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}
FILES "${myLibHeaders}"
)
set_property(TARGET myLib PROPERTY VERIFY_INTERFACE_HEADER_SETS ON)
where I can see in the compile_commands.json all the header are treated as *.hpp.cxx:
{
"directory": "/home/aznb/mycodes/testCmake/build_debug",
"command": "/usr/bin/g++ -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -I/home/aznb/mycodes/testCmake -x c++ -g --expt-relaxed-constexpr --expt-extended-lambda -Xcudafe=--diag_suppress=esa_on_defaulted_function_ignored -Xcompiler=-fopenmp -G -g -src-in-ptx -Xptxas=-g -Xcompiler=-O0 -std=c++17 -o CMakeFiles/testCmake_verify_interface_header_sets.dir/testCmake_verify_interface_header_sets/macros.hpp.cxx.o -c /home/aznb/mycodes/testCmake/build_debug/testCmake_verify_interface_header_sets/macros.hpp.cxx",
"file": "/home/aznb/mycodes/testCmake/build_debug/testCmake_verify_interface_header_sets/macros.hpp.cxx"
},
What I want to see is to have nvcc replace /usr/bin/g++
as in the case of any other *.cu file objects in the same build.
My question: how can I set the headers to be treated as CUDA so that the compilation options for them in compiler_commands.json are changed accordingly?
I have tried adding:
set_source_files_properties("${myLibHeaders}" PROPERTIES LANGUAGE CUDA)
before the target_source()
but it doesn't make a difference at all.