blt
blt copied to clipboard
CUDA compilation flags
Is there a special way to propagate defines? I am adding a library that depends on cuda, and nvcc is being invoked., but -D PARALLEL
is not being passed to nvcc. Am I doing something incorrectly?
blt_add_library( NAME vtkh_par SOURCES ${vtkh_sources} ${vtkh_par_sources} HEADERS ${vtkh_par_headers} ${vtkh_headers} DEPENDS_ON ${vtkh_thirdparty_libs} mpi icet)
blt_add_target_compile_flags(TO vtkh_par FLAGS "-D PARALLEL")
blt_register_library
has additional arguments to add flags and defines to a library target.
I am not entirely sure how blt_register_library
works when the library is generated with blt_add_library
through. @white238, can you please clarify?
To be clear, this works correctly without cuda.
the issue is for CMake cuda targets (created via macros in FindCUDA), you can't add any additional flags after the targets are created.
The work around is to add the defines to global flags CMAKE_CXX_FLAGS
before blt_add_library
and then restore the old flags after
This is actually a compelling case for adding an optional DEFINES arg to blt_add_library
We can't use blt_register_library
to solve this b/c these flags are needed to compile the lib. (And in this case the aren't needed by client code)
Update: setting CMAKE_CXX_FLAGS
doesn't work w/ BLT's current cuda support. The only path I found was to add the defs to global CUDA_NVCC_FLAGS
(along with keeping old and restoring them after adding the lib)
@mclarsen and I were able to modify CMAKE_CXX_FLAGS
before, however we were using cuda_wrap_srcs
, not cuda_add_library
, which BLT is currently using
Bit by this again in another project.
FYI: @mclarsen There is work to pivot to CMake's native cuda support: #154