Passing NVCC options from CMake











up vote
0
down vote

favorite
1












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).










share|improve this question
























  • 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















up vote
0
down vote

favorite
1












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).










share|improve this question
























  • 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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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).










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents