De-duplicates persists using "SHELL:" inside generator
I've been trying to add multiple -gencode
options to CUDA using 3.14.
I've done some web search and tried a few times to find a perfect solution but failed.
Without using generator, SHELL:
works perfectly. However, mixing CXX and CUDA kinda requires using generators.
After some trying, I found I could only get it working with 2 -gencode
. Like this:
target_compile_options(foo PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:
SHELL:-gencode arch=compute_52,code=sm_52
-gencode arch=compute_50,code=sm_50
>
)
or this:
target_compile_options(foo PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:
-gencode arch=compute_50,code=sm_50
SHELL:-gencode arch=compute_52,code=sm_52
>
)
Everything else I've tried failed to prevent de-duplicates. For instance, adding another -gencode
with or without SHELL:
.
Adding another target_compile_options
does work, either.
I don't know if a perfect solution exists right now. Please let me know.
PS: a minimum CMakeLists.txt
I used for testing is provided below.
cmake_minimum_required(VERSION 3.14)
project(test LANGUAGES CUDA)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_library(foo SHARED main.cu)
target_compile_options(foo PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:
SHELL:-gencode arch=compute_52,code=sm_52
-gencode arch=compute_50,code=sm_50
>
)