Skip to content

Commit 2920b6b

Browse files
authored
Merge pull request #138 from gangliao/master
Add Mac OS X port
2 parents 1fc4352 + efea5c8 commit 2920b6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+969
-265
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
*.DS_Store
22
build/
3+
*.user
4+
5+
.vscode
6+
.idea

cmake/cblas.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ set(OPENBLAS_ROOT $ENV{OPENBLAS_ROOT} CACHE PATH "Folder contains Openblas")
6565
set(OPENBLAS_INCLUDE_SEARCH_PATHS
6666
${OPENBLAS_ROOT}/include
6767
/usr/include
68-
/usr/include/openblas)
68+
/usr/include/openblas
69+
/usr/local/opt/openblas/include)
6970
set(OPENBLAS_LIB_SEARCH_PATHS
7071
${OPENBLAS_ROOT}/lib
7172
/usr/lib
7273
/usr/lib/blas/openblas
73-
/usr/lib/openblas)
74+
/usr/lib/openblas
75+
/usr/local/opt/openblas/lib)
7476

7577
find_path(OPENBLAS_INC_DIR NAMES cblas.h
7678
PATHS ${OPENBLAS_INCLUDE_SEARCH_PATHS})

cmake/cudnn.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
1515
$ENV{CUDNN_ROOT}/lib64
1616
$ENV{CUDNN_ROOT}/lib
1717
/usr/lib)
18-
find_library(CUDNN_LIBRARY NAMES libcudnn.so # libcudnn_static.a
18+
find_library(CUDNN_LIBRARY NAMES libcudnn.so libcudnn.dylib # libcudnn_static.a
1919
PATHS ${CUDNN_CHECK_LIBRARY_DIRS} ${CUDNN_INCLUDE_DIR} ${__libpath_hist}
2020
NO_DEFAULT_PATH
2121
DOC "Path to cuDNN library.")

cmake/util.cmake

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,55 @@
11
# Some common routine for paddle compile.
22

3-
43
# target_circle_link_libraries
54
# Link libraries to target which has circle dependencies.
65
#
76
# First Argument: target name want to be linked with libraries
87
# Rest Arguments: libraries which link together.
98
function(target_circle_link_libraries TARGET_NAME)
10-
target_link_libraries(${TARGET_NAME}
11-
-Wl,--start-group
12-
${ARGN}
13-
-Wl,--end-group)
9+
if(APPLE)
10+
set(LIBS)
11+
set(inArchive OFF)
12+
set(libsInArgn)
13+
14+
foreach(arg ${ARGN})
15+
if(${arg} STREQUAL "ARCHIVE_START")
16+
set(inArchive ON)
17+
elseif(${arg} STREQUAL "ARCHIVE_END")
18+
set(inArchive OFF)
19+
else()
20+
if(inArchive)
21+
list(APPEND LIBS "-Wl,-force_load")
22+
endif()
23+
list(APPEND LIBS ${arg})
24+
list(APPEND libsInArgn ${arg})
25+
endif()
26+
endforeach()
27+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
28+
list(APPEND LIBS "-undefined dynamic_lookup")
29+
endif()
30+
list(REVERSE libsInArgn)
31+
target_link_libraries(${TARGET_NAME}
32+
${LIBS}
33+
${libsInArgn})
34+
35+
else() # LINUX
36+
set(LIBS)
37+
38+
foreach(arg ${ARGN})
39+
if(${arg} STREQUAL "ARCHIVE_START")
40+
list(APPEND LIBS "-Wl,--whole-archive")
41+
elseif(${arg} STREQUAL "ARCHIVE_END")
42+
list(APPEND LIBS "-Wl,--no-whole-archive")
43+
else()
44+
list(APPEND LIBS ${arg})
45+
endif()
46+
endforeach()
47+
48+
target_link_libraries(${TARGET_NAME}
49+
"-Wl,--start-group"
50+
${LIBS}
51+
"-Wl,--end-group")
52+
endif()
1453
endfunction()
1554

1655
# compile_cu_as_cpp
@@ -41,20 +80,20 @@ function(link_paddle_exe TARGET_NAME)
4180
if(PADDLE_WITH_INTERNAL)
4281
set(INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter)
4382
target_circle_link_libraries(${TARGET_NAME}
44-
-Wl,--whole-archive
83+
ARCHIVE_START
4584
paddle_internal_gserver
4685
paddle_internal_owlqn
47-
-Wl,--no-whole-archive
86+
ARCHIVE_END
4887
paddle_internal_parameter)
4988
else()
5089
set(INTERAL_LIBS "")
5190
endif()
5291

5392
target_circle_link_libraries(${TARGET_NAME}
54-
-Wl,--whole-archive
93+
ARCHIVE_START
5594
paddle_gserver
5695
${METRIC_LIBS}
57-
-Wl,--no-whole-archive
96+
ARCHIVE_END
5897
paddle_pserver
5998
paddle_trainer_lib
6099
paddle_network

0 commit comments

Comments
 (0)