OpenACC - CUDA interop with CMake

CMakeLists.txt (772 Bytes)
Makefile.txt (1.0 KB)
openacc_c_main.c.txt (1002 Bytes)
saxpy_cuda.cu.txt (1.0 KB)

Uploaded a minimal example with a failing link step. All files have .txt added so I can upload them.
With the makefile you can add -lz to the linker LDFLAGS and it will link correctly.
With CMake either the cuda linking fails with <LINK_LIBRARIES> there (acc_deviceptr returning host pointer, causing cudaIllegalAddress) or zlib linking fails with removed <LINK_LIBRARIES>.

The CMake line with added LINK_LIBRARIES:

set(CMAKE_CUDA_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

It would be preferable to have an elegant solution work, without the cmake list mangling for example. Is it possible?

Thank you for your speedy answer again, and looking forward to resolve this issue.