|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +cmake_minimum_required(VERSION 2.8) |
| 19 | + |
| 20 | +project(plasma) |
| 21 | + |
| 22 | +find_package(PythonLibsNew REQUIRED) |
| 23 | +find_package(Threads) |
| 24 | + |
| 25 | +option(PLASMA_PYTHON |
| 26 | + "Build the Plasma Python extensions" |
| 27 | + OFF) |
| 28 | + |
| 29 | +if(APPLE) |
| 30 | + SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") |
| 31 | +endif(APPLE) |
| 32 | + |
| 33 | +include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS}) |
| 34 | +include_directories("${FLATBUFFERS_INCLUDE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/" "${CMAKE_CURRENT_LIST_DIR}/thirdparty/" "${CMAKE_CURRENT_LIST_DIR}/../") |
| 35 | + |
| 36 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L") |
| 37 | + |
| 38 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-conversion") |
| 39 | + |
| 40 | +# Compile flatbuffers |
| 41 | + |
| 42 | +set(PLASMA_FBS_SRC "${CMAKE_CURRENT_LIST_DIR}/format/plasma.fbs" "${CMAKE_CURRENT_LIST_DIR}/format/common.fbs") |
| 43 | +set(OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/format/) |
| 44 | + |
| 45 | +set(PLASMA_FBS_OUTPUT_FILES |
| 46 | + "${OUTPUT_DIR}/common_generated.h" |
| 47 | + "${OUTPUT_DIR}/plasma_generated.h") |
| 48 | + |
| 49 | +add_custom_target(gen_plasma_fbs DEPENDS ${PLASMA_FBS_OUTPUT_FILES}) |
| 50 | + |
| 51 | +if(FLATBUFFERS_VENDORED) |
| 52 | + add_dependencies(gen_plasma_fbs flatbuffers_ep) |
| 53 | +endif() |
| 54 | + |
| 55 | +add_custom_command( |
| 56 | + OUTPUT ${PLASMA_FBS_OUTPUT_FILES} |
| 57 | + # The --gen-object-api flag generates a C++ class MessageT for each |
| 58 | + # flatbuffers message Message, which can be used to store deserialized |
| 59 | + # messages in data structures. This is currently used for ObjectInfo for |
| 60 | + # example. |
| 61 | + COMMAND ${FLATBUFFERS_COMPILER} -c -o ${OUTPUT_DIR} ${PLASMA_FBS_SRC} --gen-object-api |
| 62 | + DEPENDS ${PLASMA_FBS_SRC} |
| 63 | + COMMENT "Running flatc compiler on ${PLASMA_FBS_SRC}" |
| 64 | + VERBATIM) |
| 65 | + |
| 66 | +if(UNIX AND NOT APPLE) |
| 67 | + link_libraries(rt) |
| 68 | +endif() |
| 69 | + |
| 70 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") |
| 71 | + |
| 72 | +set_source_files_properties(extension.cc PROPERTIES COMPILE_FLAGS -Wno-strict-aliasing) |
| 73 | + |
| 74 | +set(PLASMA_SRCS |
| 75 | + client.cc |
| 76 | + common.cc |
| 77 | + eviction_policy.cc |
| 78 | + events.cc |
| 79 | + fling.cc |
| 80 | + io.cc |
| 81 | + malloc.cc |
| 82 | + plasma.cc |
| 83 | + protocol.cc |
| 84 | + thirdparty/ae/ae.c |
| 85 | + thirdparty/xxhash.cc) |
| 86 | + |
| 87 | +ADD_ARROW_LIB(plasma |
| 88 | + SOURCES ${PLASMA_SRCS} |
| 89 | + DEPENDENCIES gen_plasma_fbs |
| 90 | + SHARED_LINK_LIBS ${FLATBUFFERS_STATIC_LIB} ${CMAKE_THREAD_LIBS_INIT} arrow_static |
| 91 | + STATIC_LINK_LIBS ${FLATBUFFERS_STATIC_LIB} ${CMAKE_THREAD_LIBS_INIT} arrow_static) |
| 92 | + |
| 93 | +# The optimization flag -O3 is suggested by dlmalloc.c, which is #included in |
| 94 | +# malloc.cc; we set it here regardless of whether we do a debug or release build. |
| 95 | +set_source_files_properties(malloc.cc PROPERTIES COMPILE_FLAGS "-Wno-error -O3") |
| 96 | + |
| 97 | +add_executable(plasma_store store.cc) |
| 98 | +target_link_libraries(plasma_store plasma_static) |
| 99 | + |
| 100 | +ADD_ARROW_TEST(test/serialization_tests) |
| 101 | +ARROW_TEST_LINK_LIBRARIES(test/serialization_tests plasma_static) |
| 102 | +ADD_ARROW_TEST(test/client_tests) |
| 103 | +ARROW_TEST_LINK_LIBRARIES(test/client_tests plasma_static) |
| 104 | + |
| 105 | +if(PLASMA_PYTHON) |
| 106 | + add_library(plasma_extension SHARED extension.cc) |
| 107 | + |
| 108 | + if(APPLE) |
| 109 | + target_link_libraries(plasma_extension plasma_static "-undefined dynamic_lookup") |
| 110 | + else(APPLE) |
| 111 | + target_link_libraries(plasma_extension plasma_static -Wl,--whole-archive ${FLATBUFFERS_STATIC_LIB} -Wl,--no-whole-archive) |
| 112 | + endif(APPLE) |
| 113 | +endif() |
0 commit comments