Passing NVCC options from CMake
up vote
0
down vote
favorite
What would be the right way to set certain NVCC compile options for a CUDA project (to be built in visual studio) from within CMake?
For example, how can I pass options such as ‘-keep’ or ‘-rdc={true|false}’?
Surprisingly, I am able to set (and observe changes in vs project) options such as -cudart and -gencode in the following fashion:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-cudart shared>)
However using similar approach with -rdc=true does not yield any results:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-rdc=true>)
I am using VS 2017 Community and CMake 3.13.0-rc3
Any pointers in the right direction would be much appreciated.
EDIT:
So far I found out that you can set “-rdc” (relocatable device code) NVCC option by using a particular CMake property CUDA_SEPARABLE_COMPILATION
.
I was wondering if that is the reason why CMake ignores “-rdc” flag when set in the way provided above, or as suggested by @RaulLaasner; simply because CMake expects that compile option to come from the aforementioned property, rather than from anywhere else.
Furthermore, when passing “-rdc” by using target_compile_options
, upon inspecting *.vcxproj I found out that it was inserted into <AdditionalOptions> node of the <CudaCompile> node, as opposed to creating <GenerateRelocatableDeviceCode> inside <CudaCompile> node (desired effect).
visual-studio cmake cuda
add a comment |
up vote
0
down vote
favorite
What would be the right way to set certain NVCC compile options for a CUDA project (to be built in visual studio) from within CMake?
For example, how can I pass options such as ‘-keep’ or ‘-rdc={true|false}’?
Surprisingly, I am able to set (and observe changes in vs project) options such as -cudart and -gencode in the following fashion:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-cudart shared>)
However using similar approach with -rdc=true does not yield any results:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-rdc=true>)
I am using VS 2017 Community and CMake 3.13.0-rc3
Any pointers in the right direction would be much appreciated.
EDIT:
So far I found out that you can set “-rdc” (relocatable device code) NVCC option by using a particular CMake property CUDA_SEPARABLE_COMPILATION
.
I was wondering if that is the reason why CMake ignores “-rdc” flag when set in the way provided above, or as suggested by @RaulLaasner; simply because CMake expects that compile option to come from the aforementioned property, rather than from anywhere else.
Furthermore, when passing “-rdc” by using target_compile_options
, upon inspecting *.vcxproj I found out that it was inserted into <AdditionalOptions> node of the <CudaCompile> node, as opposed to creating <GenerateRelocatableDeviceCode> inside <CudaCompile> node (desired effect).
visual-studio cmake cuda
I don't know if this is the "right" way but I usually put this stuff directly intoCMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something likeset(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.
– Raul Laasner
Nov 13 at 17:51
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
What would be the right way to set certain NVCC compile options for a CUDA project (to be built in visual studio) from within CMake?
For example, how can I pass options such as ‘-keep’ or ‘-rdc={true|false}’?
Surprisingly, I am able to set (and observe changes in vs project) options such as -cudart and -gencode in the following fashion:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-cudart shared>)
However using similar approach with -rdc=true does not yield any results:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-rdc=true>)
I am using VS 2017 Community and CMake 3.13.0-rc3
Any pointers in the right direction would be much appreciated.
EDIT:
So far I found out that you can set “-rdc” (relocatable device code) NVCC option by using a particular CMake property CUDA_SEPARABLE_COMPILATION
.
I was wondering if that is the reason why CMake ignores “-rdc” flag when set in the way provided above, or as suggested by @RaulLaasner; simply because CMake expects that compile option to come from the aforementioned property, rather than from anywhere else.
Furthermore, when passing “-rdc” by using target_compile_options
, upon inspecting *.vcxproj I found out that it was inserted into <AdditionalOptions> node of the <CudaCompile> node, as opposed to creating <GenerateRelocatableDeviceCode> inside <CudaCompile> node (desired effect).
visual-studio cmake cuda
What would be the right way to set certain NVCC compile options for a CUDA project (to be built in visual studio) from within CMake?
For example, how can I pass options such as ‘-keep’ or ‘-rdc={true|false}’?
Surprisingly, I am able to set (and observe changes in vs project) options such as -cudart and -gencode in the following fashion:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-cudart shared>)
However using similar approach with -rdc=true does not yield any results:
target_compile_options(target_name PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-rdc=true>)
I am using VS 2017 Community and CMake 3.13.0-rc3
Any pointers in the right direction would be much appreciated.
EDIT:
So far I found out that you can set “-rdc” (relocatable device code) NVCC option by using a particular CMake property CUDA_SEPARABLE_COMPILATION
.
I was wondering if that is the reason why CMake ignores “-rdc” flag when set in the way provided above, or as suggested by @RaulLaasner; simply because CMake expects that compile option to come from the aforementioned property, rather than from anywhere else.
Furthermore, when passing “-rdc” by using target_compile_options
, upon inspecting *.vcxproj I found out that it was inserted into <AdditionalOptions> node of the <CudaCompile> node, as opposed to creating <GenerateRelocatableDeviceCode> inside <CudaCompile> node (desired effect).
visual-studio cmake cuda
visual-studio cmake cuda
edited Nov 15 at 14:03
asked Nov 13 at 15:12
MutomboDikey
707
707
I don't know if this is the "right" way but I usually put this stuff directly intoCMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something likeset(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.
– Raul Laasner
Nov 13 at 17:51
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08
add a comment |
I don't know if this is the "right" way but I usually put this stuff directly intoCMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something likeset(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.
– Raul Laasner
Nov 13 at 17:51
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08
I don't know if this is the "right" way but I usually put this stuff directly into
CMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something like set(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.– Raul Laasner
Nov 13 at 17:51
I don't know if this is the "right" way but I usually put this stuff directly into
CMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something like set(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.– Raul Laasner
Nov 13 at 17:51
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284015%2fpassing-nvcc-options-from-cmake%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't know if this is the "right" way but I usually put this stuff directly into
CMAKE_CUDA_FLAGS
. No changes are required in the CMake script. In my initial cache file, I include something likeset(CMAKE_CUDA_FLAGS "-O3 -m64 -arch=sm_52 -lcublas" CACHE STRING "")
.– Raul Laasner
Nov 13 at 17:51
@RaulLaasner sadly, neither -rdc, nor -keep are translated into vs project using this approach. Can’t say I understand why
– MutomboDikey
Nov 14 at 13:08