File tree Expand file tree Collapse file tree 4 files changed +31
-32
lines changed Expand file tree Collapse file tree 4 files changed +31
-32
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,21 @@ function (add_flangrt_library name)
138
138
add_library ("${name_shared} " SHARED ${extra_args} ${ARG_ADDITIONAL_HEADERS} ${ARG_UNPARSED_ARGUMENTS} )
139
139
endif ()
140
140
141
+ # Provide a default target if building both and which exists in either setting.
142
+ if (BUILD_SHARED_LIBS )
143
+ if (build_shared )
144
+ add_library (${name} .default ALIAS ${name_shared} )
145
+ else ()
146
+ add_library (${name} .default ALIAS ${name} )
147
+ endif ()
148
+ else ()
149
+ if (build_static )
150
+ add_library (${name} .default ALIAS ${name_static} )
151
+ else ()
152
+ add_library (${name} .default ALIAS ${name} )
153
+ endif ()
154
+ endif ()
155
+
141
156
foreach (tgtname IN LISTS libtargets )
142
157
if (NOT WIN32 )
143
158
# Use same stem name for .a and .so. Common in UNIX environments.
Original file line number Diff line number Diff line change 8
8
9
9
macro (enable_cuda_compilation name files )
10
10
if (FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT STREQUAL "CUDA" )
11
- if (FLANG_RT_ENABLE_SHARED )
11
+ if (NOT FLANG_RT_ENABLE_STATIC )
12
12
message (FATAL_ERROR
13
- "FLANG_RT_ENABLE_SHARED is not supported for CUDA build of Flang-RT"
13
+ "FLANG_RT_ENABLE_STATIC is required for CUDA build of Flang-RT"
14
14
)
15
15
endif ()
16
16
Original file line number Diff line number Diff line change 6
6
#
7
7
#===------------------------------------------------------------------------===#
8
8
9
- # libCufRuntime depends on a certain version of CUDA. To be able to have
10
- # multiple build of this library with different CUDA version, the version is
11
- # added to the library name.
12
- set (CUFRT_LIBNAME CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR} )
13
9
14
- add_flangrt_library (${CUFRT_LIBNAME}
10
+ add_flangrt_library (CufRuntime STATIC
15
11
allocatable.cpp
16
12
allocator.cpp
17
13
descriptor.cpp
@@ -20,21 +16,19 @@ add_flangrt_library(${CUFRT_LIBNAME}
20
16
memory.cpp
21
17
registration.cpp
22
18
)
23
- target_include_directories (${CUFRT_LIBNAME} PRIVATE ${CUDAToolkit_INCLUDE_DIRS} )
24
19
25
- if (BUILD_SHARED_LIBS )
26
- set (CUDA_RT_TARGET CUDA::cudart )
27
- else ()
28
- set (CUDA_RT_TARGET CUDA::cudart_static )
29
- endif ()
30
-
31
- target_link_libraries (${CUFRT_LIBNAME}
32
- PRIVATE
33
- flang_rt
34
- ${CUDA_RT_TARGET}
20
+ # libCufRuntime depends on a certain version of CUDA. To be able to have
21
+ # multiple build of this library with different CUDA version, the version is
22
+ # added to the library name.
23
+ set_target_properties (CufRuntime
24
+ PROPERTIES
25
+ OUTPUT_NAME "CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR} "
35
26
)
36
27
37
- # Phony build target that does not include the CUDA version.
38
- add_custom_target (CufRuntime )
39
- add_dependencies (CufRuntime ${CUFRT_LIBNAME} )
28
+ target_include_directories (CufRuntime PRIVATE ${CUDAToolkit_INCLUDE_DIRS} )
40
29
30
+ target_link_libraries (CufRuntime
31
+ PUBLIC
32
+ flang_rt
33
+ CUDA::cudart_static
34
+ )
Original file line number Diff line number Diff line change @@ -12,17 +12,7 @@ add_flangrt_unittest(FlangCufRuntimeTests
12
12
Memory.cpp
13
13
)
14
14
15
- if (BUILD_SHARED_LIBS )
16
- set (CUDA_RT_TARGET CUDA::cudart )
17
- else ()
18
- set (CUDA_RT_TARGET CUDA::cudart_static )
19
- endif ()
20
-
21
15
target_link_libraries (FlangCufRuntimeTests
22
16
PRIVATE
23
- ${CUDA_RT_TARGET}
24
- CufRuntime_cuda_${CUDAToolkit_VERSION_MAJOR}
25
- flang_rt.unittest
17
+ CufRuntime
26
18
)
27
-
28
- target_include_directories (FlangCufRuntimeTests PRIVATE ${CUDAToolkit_INCLUDE_DIRS} )
You can’t perform that action at this time.
0 commit comments