@@ -24,20 +24,24 @@ function(shortfin_public_library)
24
24
"COMPONENTS"
25
25
${ARGN}
26
26
)
27
- shortfin_components_to_static_libs(_STATIC_COMPONENTS ${_RULE_COMPONENTS} )
28
- shortfin_components_to_dynamic_libs(_DYLIB_COMPONENTS ${_RULE_COMPONENTS} )
29
- # Static library.
30
- add_library ("${_RULE_NAME} -static" STATIC )
31
- target_link_libraries (
32
- "${_RULE_NAME} -static" PUBLIC ${_STATIC_COMPONENTS}
33
- )
27
+ if (SHORTFIN_BUILD_STATIC)
28
+ # Static library.
29
+ shortfin_components_to_static_libs(_STATIC_COMPONENTS ${_RULE_COMPONENTS} )
30
+ add_library ("${_RULE_NAME} -static" STATIC )
31
+ target_link_libraries (
32
+ "${_RULE_NAME} -static" PUBLIC ${_STATIC_COMPONENTS}
33
+ )
34
+ endif ()
34
35
35
- # Dylib library.
36
- add_library ("${_RULE_NAME} " SHARED)
37
- target_compile_definitions ("${_RULE_NAME} " INTERFACE _SHORTFIN_USING_DYLIB)
38
- target_link_libraries (
39
- "${_RULE_NAME} " PUBLIC ${_DYLIB_COMPONENTS}
40
- )
36
+ if (SHORTFIN_BUILD_DYNAMIC)
37
+ # Dylib library.
38
+ shortfin_components_to_dynamic_libs(_DYLIB_COMPONENTS ${_RULE_COMPONENTS} )
39
+ add_library ("${_RULE_NAME} " SHARED)
40
+ target_compile_definitions ("${_RULE_NAME} " INTERFACE _SHORTFIN_USING_DYLIB)
41
+ target_link_libraries (
42
+ "${_RULE_NAME} " PUBLIC ${_DYLIB_COMPONENTS}
43
+ )
44
+ endif ()
41
45
endfunction ()
42
46
43
47
function (shortfin_cc_component)
@@ -48,50 +52,52 @@ function(shortfin_cc_component)
48
52
"HDRS;SRCS;DEPS;COMPONENTS"
49
53
${ARGN}
50
54
)
51
- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
52
- set (_STATIC_OBJECTS_NAME "${_RULE_NAME} .objects" )
53
- set (_DYLIB_OBJECTS_NAME "${_RULE_NAME} .dylib.objects" )
54
-
55
- shortfin_components_to_static_libs(_STATIC_COMPONENTS ${_RULE_COMPONENTS} )
56
- shortfin_components_to_dynamic_libs(_DYLIB_COMPONENTS ${_RULE_COMPONENTS} )
57
-
58
- # Static object library.
59
- add_library (${_STATIC_OBJECTS_NAME} OBJECT)
60
- target_sources (${_STATIC_OBJECTS_NAME}
61
- PRIVATE
62
- ${_RULE_SRCS}
63
- ${_RULE_HDRS}
64
- )
65
- target_compile_options (${_STATIC_OBJECTS_NAME} PRIVATE ${SHORTFIN_DEFAULT_COPTS} )
66
- target_link_libraries (${_STATIC_OBJECTS_NAME}
67
- PUBLIC
68
- _shortfin_defs
69
- ${_STATIC_COMPONENTS}
70
- ${_RULE_DEPS}
71
- )
55
+ if (SHORTFIN_BUILD_STATIC)
56
+ # Static object library.
57
+ set (_STATIC_OBJECTS_NAME "${_RULE_NAME} .objects" )
58
+ shortfin_components_to_static_libs(_STATIC_COMPONENTS ${_RULE_COMPONENTS} )
59
+ add_library (${_STATIC_OBJECTS_NAME} OBJECT)
60
+ target_sources (${_STATIC_OBJECTS_NAME}
61
+ PRIVATE
62
+ ${_RULE_SRCS}
63
+ ${_RULE_HDRS}
64
+ )
65
+ target_compile_options (${_STATIC_OBJECTS_NAME} PRIVATE ${SHORTFIN_DEFAULT_COPTS} )
66
+ target_link_libraries (${_STATIC_OBJECTS_NAME}
67
+ PUBLIC
68
+ _shortfin_defs
69
+ ${_STATIC_COMPONENTS}
70
+ ${_RULE_DEPS}
71
+ )
72
+ endif ()
72
73
73
- # Dylib object library.
74
- add_library (${_DYLIB_OBJECTS_NAME} OBJECT)
75
- target_sources (${_DYLIB_OBJECTS_NAME}
76
- PRIVATE
77
- ${_RULE_SRCS}
78
- ${_RULE_HDRS}
79
- )
80
- target_compile_options (${_DYLIB_OBJECTS_NAME} PRIVATE ${SHORTFIN_DEFAULT_COPTS} )
81
- target_link_libraries (${_DYLIB_OBJECTS_NAME}
82
- PUBLIC
83
- _shortfin_defs
84
- ${_DYLIB_COMPONENTS}
85
- ${_RULE_DEPS}
86
- )
87
- set_target_properties (
88
- ${_DYLIB_OBJECTS_NAME} PROPERTIES
89
- CXX_VISIBILITY_PRESET hidden
90
- C_VISIBILITY_PRESET hidden
91
- VISIBILITY_INLINES_HIDDEN ON
92
- )
93
- target_compile_definitions (${_DYLIB_OBJECTS_NAME}
94
- PRIVATE _SHORTFIN_BUILDING_DYLIB)
74
+ if (SHORTFIN_BUILD_DYNAMIC)
75
+ set (CMAKE_POSITION_INDEPENDENT_CODE ON )
76
+ set (_DYLIB_OBJECTS_NAME "${_RULE_NAME} .dylib.objects" )
77
+ shortfin_components_to_dynamic_libs(_DYLIB_COMPONENTS ${_RULE_COMPONENTS} )
78
+ # Dylib object library.
79
+ add_library (${_DYLIB_OBJECTS_NAME} OBJECT)
80
+ target_sources (${_DYLIB_OBJECTS_NAME}
81
+ PRIVATE
82
+ ${_RULE_SRCS}
83
+ ${_RULE_HDRS}
84
+ )
85
+ target_compile_options (${_DYLIB_OBJECTS_NAME} PRIVATE ${SHORTFIN_DEFAULT_COPTS} )
86
+ target_link_libraries (${_DYLIB_OBJECTS_NAME}
87
+ PUBLIC
88
+ _shortfin_defs
89
+ ${_DYLIB_COMPONENTS}
90
+ ${_RULE_DEPS}
91
+ )
92
+ set_target_properties (
93
+ ${_DYLIB_OBJECTS_NAME} PROPERTIES
94
+ CXX_VISIBILITY_PRESET hidden
95
+ C_VISIBILITY_PRESET hidden
96
+ VISIBILITY_INLINES_HIDDEN ON
97
+ )
98
+ target_compile_definitions (${_DYLIB_OBJECTS_NAME}
99
+ PRIVATE _SHORTFIN_BUILDING_DYLIB)
100
+ endif ()
95
101
endfunction ()
96
102
97
103
function (shortfin_components_to_static_libs out_static_libs)
@@ -122,7 +128,7 @@ function(shortfin_gtest_test)
122
128
add_executable (${_RULE_NAME} ${_RULE_SRCS} )
123
129
target_link_libraries (${_RULE_NAME} PRIVATE
124
130
${_RULE_DEPS}
125
- shortfin
131
+ ${SHORTFIN_LINK_LIBRARY_NAME}
126
132
GTest::gmock
127
133
GTest::gtest_main
128
134
)
0 commit comments