@@ -42,21 +42,27 @@ macro(enable_cuda_compilation name files)
42
42
"${CUDA_COMPILE_OPTIONS} "
43
43
)
44
44
45
- if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH} /include" )
46
- # When using libcudacxx headers files, we have to use them
47
- # for all files of F18 runtime.
48
- include_directories (AFTER ${FLANG_RT_LIBCUDACXX_PATH} /include )
49
- add_compile_definitions (RT_USE_LIBCUDACXX=1 )
50
- endif ()
45
+ # Create a .a library consisting of CUDA PTX.
46
+ # This is different from a regular static library. The CUDA_PTX_COMPILATION
47
+ # property can only be applied to object libraries and create *.ptx files
48
+ # instead of *.o files. The .a will consist of those *.ptx files only.
49
+ add_flangrt_library (obj.${name}PTX OBJECT ${files} )
50
+ set_property (TARGET obj.${name}PTX PROPERTY CUDA_PTX_COMPILATION ON )
51
+ add_flangrt_library (${name} PTX STATIC "$<TARGET_OBJECTS:obj.${name} PTX>" )
51
52
52
- # Add an OBJECT library consisting of CUDA PTX.
53
- add_flangrt_library (${name} PTX OBJECT ${files} )
54
- set_property (TARGET ${name} PTX PROPERTY CUDA_PTX_COMPILATION ON )
53
+ # Apply configuration options
55
54
if (FLANG_RT_CUDA_RUNTIME_PTX_WITHOUT_GLOBAL_VARS )
56
- target_compile_definitions (${name} PTX
55
+ target_compile_definitions (obj. ${name}PTX
57
56
PRIVATE FLANG_RT_NO_GLOBAL_VAR_DEFS
58
57
)
59
58
endif ()
59
+
60
+ # When using libcudacxx headers files, we have to use them
61
+ # for all files of Flang-RT.
62
+ if (EXISTS "${FLANG_RT_LIBCUDACXX_PATH} /include" )
63
+ target_include_directories (obj.${name}PTX AFTER PRIVATE "${FLANG_RT_LIBCUDACXX_PATH} /include" )
64
+ target_compile_definitions (obj.${name}PTX PRIVATE RT_USE_LIBCUDACXX=1 )
65
+ endif ()
60
66
endif ()
61
67
endmacro ()
62
68
0 commit comments