2016-02-22 13:55:06 -08:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
2016-06-10 14:12:15 -07:00
|
|
|
project(ray)
|
2016-02-22 13:55:06 -08:00
|
|
|
|
2016-05-16 09:29:50 -07:00
|
|
|
set(THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty")
|
|
|
|
|
2016-03-10 12:40:05 -08:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
|
2016-06-10 13:16:07 -07:00
|
|
|
set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/" ${CMAKE_PREFIX_PATH})
|
|
|
|
|
2016-03-10 12:40:05 -08:00
|
|
|
find_package(PythonInterp REQUIRED)
|
2016-07-08 16:31:21 -07:00
|
|
|
|
|
|
|
if(NOT APPLE)
|
|
|
|
find_package(PythonLibs REQUIRED)
|
|
|
|
else(NOT APPLE)
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
|
|
|
|
"import sys; skip = 2 if sys.platform.startswith('win') else 1; print 'python' + sys.version[0:3:skip]"
|
|
|
|
OUTPUT_VARIABLE PYTHON_LIBRARY_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
|
|
|
|
"import sys; print sys.exec_prefix"
|
|
|
|
OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
FIND_LIBRARY(PYTHON_LIBRARIES
|
|
|
|
NAMES ${PYTHON_LIBRARY_NAME}
|
|
|
|
HINTS "${PYTHON_PREFIX}"
|
|
|
|
PATH_SUFFIXES "lib" "libs"
|
|
|
|
NO_DEFAULT_PATH)
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c
|
|
|
|
"from distutils.sysconfig import *; print get_python_inc()"
|
|
|
|
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
if(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
|
|
|
|
SET(PYTHONLIBS_FOUND TRUE)
|
|
|
|
message("-- Found PythonLibs: " ${PYTHON_LIBRARIES})
|
|
|
|
message("-- -- Used custom search path")
|
|
|
|
else(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
|
|
|
|
find_package(PythonLibs REQUIRED)
|
|
|
|
message("-- -- Used find_package(PythonLibs)")
|
|
|
|
endif(PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS)
|
|
|
|
endif(NOT APPLE)
|
|
|
|
|
2016-03-10 12:40:05 -08:00
|
|
|
find_package(NumPy REQUIRED)
|
2016-02-22 13:55:06 -08:00
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
|
2016-07-10 19:48:56 +03:00
|
|
|
find_package(Boost)
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS}) # This was required to find boost for macports
|
|
|
|
|
2016-02-22 13:55:06 -08:00
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/include")
|
2016-02-22 17:35:03 -08:00
|
|
|
include_directories("/usr/local/include")
|
2016-06-10 13:16:07 -07:00
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/thirdparty/grpc/include/")
|
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/thirdparty/grpc/third_party/protobuf/src")
|
2016-03-10 12:35:31 -08:00
|
|
|
include_directories("${PYTHON_INCLUDE_DIRS}")
|
2016-03-10 12:40:05 -08:00
|
|
|
include_directories("${NUMPY_INCLUDE_DIR}")
|
2016-02-22 13:55:06 -08:00
|
|
|
|
|
|
|
set(PROTO_PATH "${CMAKE_SOURCE_DIR}/protos")
|
|
|
|
|
2016-06-27 12:16:59 -07:00
|
|
|
set(GRAPH_PROTO "${PROTO_PATH}/graph.proto")
|
2016-06-10 14:12:15 -07:00
|
|
|
set(RAY_PROTO "${PROTO_PATH}/ray.proto")
|
2016-02-22 13:55:06 -08:00
|
|
|
set(TYPES_PROTO "${PROTO_PATH}/types.proto")
|
|
|
|
set(GENERATED_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/generated")
|
|
|
|
file(MAKE_DIRECTORY ${GENERATED_PROTOBUF_PATH})
|
|
|
|
|
2016-06-27 12:16:59 -07:00
|
|
|
set(GRAPH_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/graph.pb.cc")
|
|
|
|
set(GRAPH_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/graph.pb.h")
|
|
|
|
|
2016-06-10 14:12:15 -07:00
|
|
|
set(RAY_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/ray.pb.cc")
|
|
|
|
set(RAY_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/ray.pb.h")
|
|
|
|
set(RAY_GRPC_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/ray.grpc.pb.cc")
|
|
|
|
set(RAY_GRPC_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/ray.grpc.pb.h")
|
2016-02-22 13:55:06 -08:00
|
|
|
|
|
|
|
set(TYPES_PB_CPP_FILE "${GENERATED_PROTOBUF_PATH}/types.pb.cc")
|
|
|
|
set(TYPES_PB_H_FILE "${GENERATED_PROTOBUF_PATH}/types.pb.h")
|
2016-06-27 12:16:59 -07:00
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${GRAPH_PB_H_FILE}"
|
|
|
|
"${GRAPH_PB_CPP_FILE}"
|
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/protobuf/protoc
|
|
|
|
ARGS "--proto_path=${PROTO_PATH}"
|
|
|
|
"--cpp_out=${GENERATED_PROTOBUF_PATH}"
|
|
|
|
"${GRAPH_PROTO}"
|
|
|
|
)
|
2016-02-22 13:55:06 -08:00
|
|
|
|
|
|
|
add_custom_command(
|
2016-06-10 14:12:15 -07:00
|
|
|
OUTPUT "${RAY_PB_H_FILE}"
|
|
|
|
"${RAY_PB_CPP_FILE}"
|
|
|
|
"${RAY_GRPC_PB_H_FILE}"
|
|
|
|
"${RAY_GRPC_PB_CPP_FILE}"
|
2016-06-10 13:16:07 -07:00
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/protobuf/protoc
|
2016-02-22 13:55:06 -08:00
|
|
|
ARGS "--proto_path=${PROTO_PATH}"
|
|
|
|
"--cpp_out=${GENERATED_PROTOBUF_PATH}"
|
2016-06-10 14:12:15 -07:00
|
|
|
"${RAY_PROTO}"
|
2016-06-10 13:16:07 -07:00
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/protobuf/protoc
|
2016-02-22 13:55:06 -08:00
|
|
|
ARGS "--proto_path=${PROTO_PATH}"
|
|
|
|
"--grpc_out=${GENERATED_PROTOBUF_PATH}"
|
2016-06-10 13:16:07 -07:00
|
|
|
"--plugin=protoc-gen-grpc=${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/grpc_cpp_plugin"
|
2016-06-10 14:12:15 -07:00
|
|
|
"${RAY_PROTO}"
|
2016-02-22 13:55:06 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${TYPES_PB_H_FILE}"
|
|
|
|
"${TYPES_PB_CPP_FILE}"
|
2016-06-10 13:16:07 -07:00
|
|
|
COMMAND ${CMAKE_SOURCE_DIR}/thirdparty/grpc/bins/opt/protobuf/protoc
|
2016-02-22 13:55:06 -08:00
|
|
|
ARGS "--proto_path=${PROTO_PATH}"
|
|
|
|
"--cpp_out=${GENERATED_PROTOBUF_PATH}"
|
|
|
|
"${TYPES_PROTO}"
|
|
|
|
)
|
|
|
|
|
2016-06-27 12:16:59 -07:00
|
|
|
set(GENERATED_PROTOBUF_FILES
|
|
|
|
${GRAPH_PB_H_FILE} ${GRAPH_PB_CPP_FILE}
|
|
|
|
${RAY_PB_H_FILE} ${RAY_PB_CPP_FILE}
|
2016-06-10 14:12:15 -07:00
|
|
|
${RAY_GRPC_PB_H_FILE} ${RAY_GRPC_PB_CPP_FILE}
|
2016-06-27 12:16:59 -07:00
|
|
|
${TYPES_PB_H_FILE} ${TYPES_PB_CPP_FILE})
|
2016-02-22 13:55:06 -08:00
|
|
|
|
|
|
|
include_directories(${GENERATED_PROTOBUF_PATH})
|
2016-06-10 13:16:07 -07:00
|
|
|
|
|
|
|
link_libraries(${CMAKE_SOURCE_DIR}/thirdparty/grpc/libs/opt/libgrpc++_unsecure.a
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/grpc/libs/opt/libgrpc++.a
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/grpc/libs/opt/libgrpc.a
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/grpc/libs/opt/protobuf/libprotobuf.a
|
|
|
|
pthread)
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
link_libraries(rt)
|
2016-02-22 17:35:03 -08:00
|
|
|
endif()
|
2016-02-22 13:55:06 -08:00
|
|
|
|
2016-06-10 13:16:07 -07:00
|
|
|
if(APPLE)
|
|
|
|
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
|
|
|
|
endif(APPLE)
|
|
|
|
|
|
|
|
set(ARROW_LIB ${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/build/release/libarrow.a)
|
|
|
|
|
|
|
|
add_definitions(-fPIC)
|
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/thirdparty/arrow/cpp/src/")
|
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/thirdparty/numbuf/cpp/src/")
|
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/thirdparty/numbuf/python/src/")
|
|
|
|
add_library(pynumbuf STATIC ${CMAKE_SOURCE_DIR}/thirdparty/numbuf/cpp/src/numbuf/tensor.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/cpp/src/numbuf/types.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/cpp/src/numbuf/metadata.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/cpp/src/numbuf/dict.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/python/src/pynumbuf/serialize.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/python/src/pynumbuf/adapters/numpy.cc
|
|
|
|
${CMAKE_SOURCE_DIR}/thirdparty/numbuf/python/src/pynumbuf/adapters/python.cc)
|
|
|
|
target_link_libraries(pynumbuf ${ARROW_LIB} ${PYTHON_LIBRARIES})
|
|
|
|
|
2016-06-19 12:45:34 -07:00
|
|
|
add_executable(objstore src/objstore.cc src/ipc.cc src/utils.cc ${GENERATED_PROTOBUF_FILES})
|
2016-07-10 19:48:56 +03:00
|
|
|
target_link_libraries(objstore ${ARROW_LIB} pynumbuf)
|
2016-06-19 12:45:34 -07:00
|
|
|
add_executable(scheduler src/scheduler.cc src/computation_graph.cc src/utils.cc ${GENERATED_PROTOBUF_FILES})
|
2016-07-10 19:48:56 +03:00
|
|
|
target_link_libraries(scheduler)
|
2016-06-19 12:45:34 -07:00
|
|
|
add_library(raylib SHARED src/raylib.cc src/worker.cc src/ipc.cc src/utils.cc ${GENERATED_PROTOBUF_FILES})
|
2016-07-10 19:48:56 +03:00
|
|
|
target_link_libraries(raylib ${ARROW_LIB} pynumbuf)
|
2016-02-22 13:55:06 -08:00
|
|
|
|
2016-06-25 15:40:01 -07:00
|
|
|
get_filename_component(PYTHON_SHARED_LIBRARY ${PYTHON_LIBRARIES} NAME)
|
|
|
|
if(APPLE)
|
|
|
|
add_custom_command(TARGET raylib
|
|
|
|
POST_BUILD COMMAND
|
|
|
|
${CMAKE_INSTALL_NAME_TOOL} -change ${PYTHON_SHARED_LIBRARY} ${PYTHON_LIBRARIES} libraylib.so)
|
|
|
|
endif(APPLE)
|
|
|
|
|
2016-06-10 14:12:15 -07:00
|
|
|
install(TARGETS objstore scheduler raylib DESTINATION ${CMAKE_SOURCE_DIR}/lib/python/ray)
|