Adding --ptxas-options=-v flag into Cmake

I want to embed this flag “–ptxas-options=-v” in my cmake in order to view Number of registers used per thread and shared Memory per block usage for my kernel. The project contains host and device code.

I added these statements to pass individual flags to each compiler i.e.

add_compile_options(myprog
    PRIVATE
    $<$<COMPILE_LANGUAGE:C>:-Wall>
    $<$<COMPILE_LANGUAGE:CUDA>:-arch=sm_20 -ptxas-options=-v>
)

It compiles fine but it doesn’t shows me Number of registers used per thread and shared Memory per block.

Solution:

target_compile_options(myprog PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:--ptxas-options=-v>)