cmake add_custom_command() is not passing the ccbin flag to nvcc for the Fatbin and PTX cuda samples

Author: philmcmCreated Jul 16, 2026Updated Aug 28, 2026

Using Version 13.3 of CUDA Toolkit on Fedora 44. The default GCC/G++ is version 16 and is unsupported by the cuda toolkit (> 15 not supported)

After generation of makefiles using the following command which passes older GCC/G++ compiler versions: cmake -D CMAKE_C_COMPILER=gcc-15 -D CMAKE_CXX_COMPILER=g++-15 -D CMAKE_CUDA_HOST_COMPILER:STRING=g++-15 ..

nvcc is not receiving the correct compiler version via the cmake custom commands in a few samples. This only affects the samples involving the cmake custom commands used by fatbin and PTX related code. All other samples compile fine and run correctly.

I've introduced a workaround to the each of the affected CMakeLists.txt files to pass the compiler version:

Changed from: add_custom_command( ... COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE} ... )

To: COMMAND ${CMAKE_CUDA_COMPILER} ${INCLUDES} ${ALL_CCFLAGS} -Wno-deprecated-gpu-targets -ccbin=${CMAKE_CUDA_HOST_COMPILER} ${GENCODE_FLAGS} -o ${CUDA_FATBIN_FILE} -fatbin ${CUDA_KERNEL_SOURCE}

Although I think there might be a more appropriate option to pass in this case.

The affected examples are: 0_Introduction/ matrixMulDrv simpleDrvRuntime simpleTextureDrv vectorAddDrv vectorAddMMAP 2_Concepts_and_Techniques/ threadMigration 3_CUDA_Features/ memMapIPCDrv ptxjit