Skip to content

Commit c7bd777

Browse files
committed
Support the link of inference library on mac.
1 parent 5b3cf4e commit c7bd777

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

paddle/inference/CMakeLists.txt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ if(PTOOLS_INC_DIR AND PTOOLS_SHARED_LIB)
3030
endif()
3131

3232
add_executable(example example.cc)
33-
target_link_libraries(example
34-
-Wl,--start-group -Wl,--whole-archive paddle_fluid
35-
-Wl,--no-whole-archive -Wl,--end-group
36-
${PTOOLS_LIB})
33+
if(APPLE)
34+
set(OPTIONAL_LINK_FLAGS)
35+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
36+
set(OPTIONAL_LINK_FLAGS "-undefined dynamic_lookup")
37+
endif()
38+
target_link_libraries(example
39+
-Wl,-force_load paddle_fluid
40+
${OPTIONAL_LINK_FLAGS}
41+
${PTOOLS_LIB})
42+
else()
43+
target_link_libraries(example
44+
-Wl,--start-group -Wl,--whole-archive paddle_fluid
45+
-Wl,--no-whole-archive -Wl,--end-group
46+
${PTOOLS_LIB})
47+
endif()

0 commit comments

Comments
 (0)