提交 4315a38d 编写于 作者: G gangliao 提交者: GitHub

Merge pull request #1 from reyoung/mac_port

revise CMake for MAC OS
......@@ -14,6 +14,7 @@ find_package(CUDA QUIET)
find_package(Protobuf REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(PythonInterp 2.7 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(NumPy)
find_package(Threads REQUIRED)
find_package(Glog)
......
......@@ -58,8 +58,8 @@ set(COMMON_FLAGS
-fPIC
-fno-omit-frame-pointer
-Wall
# -Wextra
# -Werror
-Wextra
-Werror
-Wnon-virtual-dtor
-Wdelete-non-virtual-dtor
-Wno-unused-parameter
......
# MAC OS does not contain start-up and whole-archive args
if(APPLE)
set(GROUP_START "")
set(GROUP_END "")
set(ARCHIVE_START "")
set(ARCHIVE_END "")
else()
set(GROUP_START "-Wl,--start-group")
set(GROUP_END "-Wl,--end-group")
set(ARCHIVE_START "-Wl,--whole-archive")
set(ARCHIVE_END "-Wl,--no-whole-archive")
endif()
# Some common routine for paddle compile.
# target_circle_link_libraries
......@@ -23,17 +7,46 @@ endif()
# Rest Arguments: libraries which link together.
function(target_circle_link_libraries TARGET_NAME)
if(APPLE)
set(LIBS)
set(inArchive OFF)
set(libsInArgn)
foreach(arg ${ARGN})
list(APPEND OSX_LIBRARIES "-Wl,-force_load" "${arg}")
if(${arg} STREQUAL "ARCHIVE_START")
set(inArchive ON)
elseif(${arg} STREQUAL "ARCHIVE_END")
set(inArchive OFF)
else()
if(inArchive)
list(APPEND LIBS "-Wl,-force_load")
endif()
list(APPEND LIBS ${arg})
list(APPEND libsInArgn ${arg})
endif()
endforeach()
list(REVERSE libsInArgn)
target_link_libraries(${TARGET_NAME}
${OSX_LIBRARIES} -lz)
else()
${LIBS}
${libsInArgn})
else() # LINUX
set(LIBS)
foreach(arg ${ARGN})
if(${arg} STREQUAL "ARCHIVE_START")
list(APPEND LIBS "-Wl,--whole-archive")
elseif(${arg} STREQUAL "ARCHIVE_END")
list(APPEND LIBS "-Wl,--no-whole-archive")
else()
list(APPEND LIBS ${arg})
endif()
endforeach()
target_link_libraries(${TARGET_NAME}
${GROUP_START}
${ARGN}
-lz
${GROUP_END})
"-Wl,--start-group"
${LIBS}
"-Wl,--end-group")
endif()
endfunction()
......@@ -65,20 +78,20 @@ function(link_paddle_exe TARGET_NAME)
if(PADDLE_WITH_INTERNAL)
set(INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter)
target_circle_link_libraries(${TARGET_NAME}
${ARCHIVE_START}
ARCHIVE_START
paddle_internal_gserver
paddle_internal_owlqn
${ARCHIVE_END}
ARCHIVE_END
paddle_internal_parameter)
else()
set(INTERAL_LIBS "")
endif()
target_circle_link_libraries(${TARGET_NAME}
${ARCHIVE_START}
ARCHIVE_START
paddle_gserver
${METRIC_LIBS}
${ARCHIVE_END}
ARCHIVE_END
paddle_pserver
paddle_trainer_lib
paddle_network
......@@ -92,7 +105,8 @@ function(link_paddle_exe TARGET_NAME)
${CMAKE_THREAD_LIBS_INIT}
${CBLAS_LIBS}
${CMAKE_DL_LIBS}
${INTERAL_LIBS})
${INTERAL_LIBS}
${ZLIB_LIBRARIES})
if(WITH_PYTHON)
target_link_libraries(${TARGET_NAME}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册