I am using CMake to check for specific header files, but CMake doesn't find a specific header that does exist.
I have installed Nvidia HPC SDK through spack, and enable CUDA language support and the SDK with:
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
message(STATUS "CUDA_nvToolsExt_LIBRARY:" ${CUDA_nvToolsExt_LIBRARY})
message(STATUS "CMAKE_CUDA_TOOLKIT:" ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
include_directories(SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
message(STATUS "Include directories 1: " ${INCLUDE_DIRECTORIES})
set(INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
message(STATUS "Include directories 2: " ${INCLUDE_DIRECTORIES})
I added the toolkit include directories just in case, the output from these configuration steps are:
-- CUDA_nvToolsExt_LIBRARY:/home/primrose/installed/spack/opt/spack/linux-ubuntu22.04-zen3/gcc-11.2.0/nvhpc-22.7-fc7js2zbwveg52yofknq34rz23pcxlnr/Linux_x86_64/22.7/cuda/11.7/lib64/libnvToolsExt.so
-- CMAKE_CUDA_TOOLKIT:/home/primrose/installed/spack/opt/spack/linux-ubuntu22.04-zen3/gcc-11.2.0/nvhpc-22.7-fc7js2zbwveg52yofknq34rz23pcxlnr/Linux_x86_64/22.7/cuda/11.7/targets/x86_64-linux/include
-- Include directories 1:
-- Include directories 2: /home/primrose/installed/spack/opt/spack/linux-ubuntu22.04-zen3/gcc-11.2.0/nvhpc-22.7-fc7js2zbwveg52yofknq34rz23pcxlnr/Linux_x86_64/22.7/cuda/11.7/targets/x86_64-linux/include
I check for the header file nvToolsExt.h with the following CMake code:
include(CheckIncludeFiles)
check_include_file(nvToolsExt.h HAVE_NVTOOLSEXT_H)
This snippet is written in a module *.cmake that is included after the call to
find_package(CUDAToolkit REQUIRED)
and
include_directories(SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
set(INCLUDE_DIRECTORIES ${INCLUDE_DIRECTORIES} ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
If I check for the header manually with the output from the CMake output I can find the header:
primrose@primrosenook:~/work/Peano/build$ ls /home/primrose/installed/spack/opt/spack/linux-ubuntu22.04-zen3/gcc-11.2.0/nvhpc-22.7-fc7js2zbwveg52yofknq34rz23pcxlnr/Linux_x86_64/22.7/cuda/11.7/targets/x86_64-linux/include/nvToolsExt.h
/home/primrose/installed/spack/opt/spack/linux-ubuntu22.04-zen3/gcc-11.2.0/nvhpc-22.7-fc7js2zbwveg52yofknq34rz23pcxlnr/Linux_x86_64/22.7/cuda/11.7/targets/x86_64-linux/include/nvToolsExt.h
but the check_include_file returns:
-- Looking for nvToolsExt.h
-- Looking for nvToolsExt.h - not found
Which I think should not be the case as it is a part of the include directories, but what am I doing wrong here?
(P.S. I so far used target_include_directories only so far, but finding the header is independent of the targets and is used to generate a config.h a file which every target uses therefore I don't think I can use target_include_directories instread)