Skip to content

Commit

Permalink
cmake cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sc1f committed Jan 15, 2021
1 parent 98fc305 commit 9eb86d0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
10 changes: 4 additions & 6 deletions cmake/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ set(FBS_SRC
${CMAKE_BINARY_DIR}/arrow-src/cpp/src/arrow/ipc/feather.fbs)

include_directories(src)

# Build Arrow as a static library
set(ARROW_BUILD_STATIC ON)
if (PSP_WASM_BUILD)
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

add_library(arrow STATIC ${ARROW_SRCS})

target_compile_definitions(arrow PUBLIC ARROW_NO_DEPRECATED_API)
target_compile_definitions(arrow PUBLIC ARROW_STATIC)

Expand All @@ -170,12 +174,6 @@ target_link_libraries(arrow
${Boost_SYSTEM_LIBRARY}
${ARROW_TEST_LINK_TOOLCHAIN})

# python 2.7 build needs -lrt, otherwise we get an "undefined symbol:
# clock_gettime" error. TODO: remove this one if we don't need it
# if (PSP_PYTHON_BUILD AND MANYLINUX AND PSP_PYTHON_VERSION STREQUAL "2.7")
# target_link_libraries(arrow rt)
# endif()

find_package(Flatbuffers)

add_custom_command(OUTPUT ${FBS_OUTPUT_FILES}
Expand Down
25 changes: 14 additions & 11 deletions cmake/modules/FindFlatbuffers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@
# FLATBUFFERS_INCLUDE_DIR, directory containing headers
# FLATBUFFERS_STATIC_LIB, path to flatbuffers's static library
# FLATBUFFERS_COMPILER, path to flatc compiler
#
# TODO: [01-15-2021] now that we use Flatbuffers on all platforms, it might be
# a good time to figure out how we can install Flatbuffers as a dependency
# inside our CMakeLists (we would just need to build the flatc executable
# before our Arrow build starts). Right now, I've put in some hacks to make
# sure our Windows build works on Azure by pre-installing flatc (like we do on
# all other platforms), and then pulling down the headers for Windows so they
# can be included.

# this might fail
# https://gitlab.kitware.com/cmake/cmake/issues/19120

# TODO: unhack this

if (WIN32)
find_path(FLATBUFFERS_INCLUDE_DIR flatbuffers/flatbuffers.h
PATHS ${FLATBUFFERS_ROOT}/include
HINTS /usr/local /usr/local/flatbuffers /usr/local/Homebrew /usr ~/homebrew/ /usr/local/include /usr/local/flatbuffers/include /usr/include ~/homebrew/include)
PATHS ${FLATBUFFERS_ROOT}/include)

find_program(FLATBUFFERS_COMPILER flatc
PATHS ${FLATBUFFERS_ROOT}/bin
HINTS /usr/local/bin /usr/bin /usr/local/Homebrew/bin ~/homebrew/bin)
PATHS ${FLATBUFFERS_ROOT}/bin)
else()
find_path(FLATBUFFERS_INCLUDE_DIR flatbuffers/flatbuffers.h
PATHS ${FLATBUFFERS_ROOT}/include
Expand All @@ -48,11 +51,11 @@ else()
HINTS /usr/local/bin /usr/bin /usr/local/Homebrew/bin ~/homebrew/bin
NO_CMAKE_SYSTEM_PATH
NO_SYSTEM_ENVIRONMENT_PATH)
endif()

if(NOT ${FLATBUFFERS_INCLUDE_DIR})
# HACK
set(FLATBUFFERS_INCLUDE_DIR /usr/local/include)
if(NOT ${FLATBUFFERS_INCLUDE_DIR})
# HACK
set(FLATBUFFERS_INCLUDE_DIR /usr/local/include)
endif()
endif()

include(FindPackageHandleStandardArgs)
Expand Down
26 changes: 13 additions & 13 deletions cpp/perspective/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ message("${Cyan}Building minimal Apache Arrow${ColorReset}")
# Build arrow dependencies
psp_build_dep("rapidjson" "${PSP_CMAKE_MODULE_PATH}/rapidjson.txt.in")
psp_build_dep("double-conversion" "${PSP_CMAKE_MODULE_PATH}/double-conversion.txt.in")
psp_build_dep("flatbuffers" "${PSP_CMAKE_MODULE_PATH}/flatbuffers.txt.in")

# FIXME: this is a hack to get Flatbuffers working on Azure Win64 by making the
# headers accessible. The actual flatc executable is installed using
# Chocolatey for our Azure Windows job.
if (WIN32)
psp_build_dep("flatbuffers" "${PSP_CMAKE_MODULE_PATH}/flatbuffers.txt.in")
endif()

# Build minimal arrow itself
psp_build_dep("arrow" "${PSP_CMAKE_MODULE_PATH}/arrow.txt.in")
Expand Down Expand Up @@ -585,14 +591,14 @@ if (PSP_WASM_BUILD)
add_executable(perspective.async src/cpp/emscripten.cpp)
target_link_libraries(perspective.async psp "${ASYNC_MODE_FLAGS}")
target_compile_definitions(perspective.async PRIVATE PSP_ENABLE_WASM=1)

set_target_properties(perspective.async PROPERTIES COMPILE_FLAGS "${ASYNC_MODE_FLAGS}")
set_target_properties(perspective.async PROPERTIES RUNTIME_OUTPUT_DIRECTORY "./build/")
set_target_properties(perspective.async PROPERTIES OUTPUT_NAME "psp.async")
elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
if(NOT WIN32)
set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
# Look for the binary using @loader_path (relative to binary location) instead of @rpath
# and include arrow in @rpath so it can be found by libbinding/libpsp
# Look for the binary using @loader_path (relative to binary location)
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
Expand Down Expand Up @@ -631,16 +637,16 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
target_compile_options(binding PRIVATE -Wdeprecated-declarations)
endif()

# python 2.7 build needs -lrt, otherwise we get an "undefined symbol:
# clock_gettime" error.
# python 2.7 build on manylinux needs -lrt for access to time functions,
# otherwise we get an "undefined symbol: clock_gettime" error when
# building minimal arrow.
if (PSP_PYTHON_BUILD AND MANYLINUX AND PSP_PYTHON_VERSION STREQUAL "2.7")
target_link_libraries(psp rt)
target_link_libraries(binding rt)
endif()


# Link against minimal arrow static library
target_link_libraries(psp arrow)
target_link_libraries(binding arrow)

target_link_libraries(psp tbb)
target_link_libraries(binding tbb)
Expand All @@ -655,19 +661,13 @@ elseif(PSP_CPP_BUILD OR PSP_PYTHON_BUILD)
add_custom_command(TARGET binding POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:binding> ${PSP_PYTHON_SRC}/table/)

if(WIN32)
# inline arrow dlls
# file(GLOB ARROW_DLLS "${PYTHON_PYARROW_LIBRARY_DIR}/*.dll")

# add_custom_command(TARGET binding POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${ARROW_DLLS} ${PSP_PYTHON_SRC}/table/)
if(NOT TBB_FOUND)
add_custom_command(TARGET binding POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:tbb> ${PSP_PYTHON_SRC}/table/)
endif()
endif()
########################
else()
add_library(psp SHARED ${WASM_SOURCE_FILES})

# Link perspective against custom-built minimal arrow
target_link_libraries(psp arrow)
endif()

Expand Down

0 comments on commit 9eb86d0

Please sign in to comment.