singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [3/7] incubator-singa git commit: fix bug for python build in mac
Date Tue, 30 Aug 2016 14:35:41 GMT
fix bug for python build in mac


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/59f56e67
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/59f56e67
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/59f56e67

Branch: refs/heads/master
Commit: 59f56e676a2651375d14f74a46c20a1c46910003
Parents: 546c38b
Author: aaronwwf <dcswuw@gmail.com>
Authored: Mon Aug 29 16:34:01 2016 +0800
Committer: aaronwwf <dcswuw@gmail.com>
Committed: Mon Aug 29 16:34:01 2016 +0800

----------------------------------------------------------------------
 src/CMakeLists.txt | 50 +++++++++++++++++++++++++++----------------------
 1 file changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/59f56e67/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 87486f7..9db0eca 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,12 +20,9 @@
 
 FILE(GLOB proto_files proto/*.proto)
 protobuf_generate_cpp(proto_srcs proto_hdrs ${proto_files})
-IF (USE_PYTHON)
-    protobuf_generate_python(proto_pys ${proto_files})
-ENDIF()
 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/include")
 
-LIST(APPEND singa_sources ${proto_hdrs} ${proto_srcs} ${proto_pys})
+LIST(APPEND singa_sources ${proto_hdrs} ${proto_srcs})
 SET(PREVIOUS_LINKER_LIBS ${SINGA_LINKER_LIBS})
 
 AUX_SOURCE_DIRECTORY(utils utils_source)
@@ -61,9 +58,26 @@ LIST(APPEND singa_sources ${model_source})
 AUX_SOURCE_DIRECTORY(io io_source)
 AUX_SOURCE_DIRECTORY(io/network io_source)
 LIST(APPEND singa_sources ${io_source})
+ADD_LIBRARY(singa SHARED ${singa_sources})
+ADD_CUSTOM_TARGET(
+  copy_protobuf
+  COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/include/singa/proto"
+  DEPENDS ${proto_hdrs}
+  COMMENT "Copying Protobuf headers"
+  )
+FOREACH(fil ${proto_hdrs})
+  ADD_CUSTOM_COMMAND(
+    TARGET copy_protobuf PRE_BUILD
+    COMMAND ${CMAKE_COMMAND} -E copy ${fil} "${CMAKE_BINARY_DIR}/include/singa/proto"
+ )
+ENDFOREACH()
+ADD_DEPENDENCIES(singa copy_protobuf)
+TARGET_LINK_LIBRARIES(singa ${SINGA_LINKER_LIBS})
+#MESSAGE(STATUS "HEADERS: ${proto_hdrs}")
 
 IF(USE_PYTHON)
 
+    protobuf_generate_python(proto_pys ${proto_files})
     FILE(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/python/swig/config.i")
     CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/python/swig/config.i.in" "${CMAKE_CURRENT_SOURCE_DIR}/python/swig/config.i")
 
@@ -80,11 +94,11 @@ IF(USE_PYTHON)
 
     create_symlinks(${python_source_files})
 
-    SET(python_cxxs "${core_source};${io_source};${model_source};${utils_source}")
-    ADD_LIBRARY(_singa_wrap SHARED ${python_srcs} ${python_cxxs} ${cuda_objs})
+    ADD_LIBRARY(_singa_wrap SHARED ${python_srcs} ${singa_sources} ${cuda_objs})
     SET(WRAPPER_LINKER_LIBS "${PREVIOUS_LINKER_LIBS}")
     TARGET_LINK_LIBRARIES(_singa_wrap ${WRAPPER_LINKER_LIBS})
     TARGET_INCLUDE_DIRECTORIES(_singa_wrap PRIVATE ${PYTHON_INCLUDE_DIRS})
+    ADD_DEPENDENCIES(_singa_wrap singa)
     #message(STATUS "PREVIOUS_LINKER_LIBS ${PREVIOUS_LINKER_LIBS}")
 
     SET_TARGET_PROPERTIES(_singa_wrap
@@ -99,23 +113,15 @@ IF(USE_PYTHON)
 
     #create python/singa/proto/__init__.py
     FILE(WRITE ${CMAKE_BINARY_DIR}/python/singa/proto/__init__.py "")
+    IF(APPLE)
+        ADD_CUSTOM_TARGET(
+            change_subfix 
+            COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_BINARY_DIR}/python/singa/_singa_wrap.dylib"
"${CMAKE_BINARY_DIR}/python/singa/_singa_wrap.so"
+            DEPENDS ${_singa_wrap}
+            COMMENT "change .dylib to .so in mac system"
+        )
+    ENDIF(APPLE)
 
 ENDIF(USE_PYTHON)
 
-ADD_LIBRARY(singa SHARED ${singa_sources})
-ADD_CUSTOM_TARGET(
-  copy_protobuf
-  COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/include/singa/proto"
-  DEPENDS ${proto_hdrs}
-  COMMENT "Copying Protobuf headers"
-  )
-FOREACH(fil ${proto_hdrs})
-  ADD_CUSTOM_COMMAND(
-    TARGET copy_protobuf PRE_BUILD
-    COMMAND ${CMAKE_COMMAND} -E copy ${fil} "${CMAKE_BINARY_DIR}/include/singa/proto"
- )
-ENDFOREACH()
-ADD_DEPENDENCIES(singa copy_protobuf)
-TARGET_LINK_LIBRARIES(singa ${SINGA_LINKER_LIBS})
-#MESSAGE(STATUS "HEADERS: ${proto_hdrs}")
 


Mime
View raw message