Skip to content

Commit

Permalink
Allow building python core with setup.py
Browse files Browse the repository at this point in the history
This essentially entails that the user can install the python core with
setup.py directly, assuming all dependancies are installed. In effect
mio and mpark need to be considered to be external requirements.

The normal build sequence makes use of the same configuration to build
the core. However, here mio and mpark is added as subdirectories to the
project and was not exported to the build tree.

To unify the to cases, the normal build sequence need to export mio and
mpark to the build tree when building the c++ core. Then set the
appropriate environment variables so cmake can find them when when
building the python core.
  • Loading branch information
ErlendHaa committed Sep 14, 2019
1 parent c93089d commit fe154b8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions env_vars.sh
@@ -1,3 +1,6 @@
#! /bin/sh

export CPLUS_INCLUDE_PATH=$PWD/boost_1_66_0:${CPLUS_INCLUDE_PATH}

export mio_DIR=$PWD/build-centos5/external/mio
export mpark_DIR=$PWD/build-centos5/external/mpark
11 changes: 11 additions & 0 deletions external/mio/CMakeLists.txt
Expand Up @@ -9,3 +9,14 @@ target_include_directories(mio
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)

export(
TARGETS
mio
NAMESPACE
mio::
FILE
mio-config.cmake
)

set(MIO_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "")
12 changes: 12 additions & 0 deletions external/mpark/CMakeLists.txt
Expand Up @@ -10,3 +10,15 @@ target_include_directories(mpark-variant
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)

#add_library(variant ALIAS mpark-variant)
export(
TARGETS
mpark-variant
NAMESPACE
mpark::
FILE
mpark-config.cmake
)

set(MPARK_LIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "")
2 changes: 2 additions & 0 deletions python/CMakeLists.txt
Expand Up @@ -54,6 +54,8 @@ add_custom_target(
${DLISIO_PYTHON_BUILD_TYPE}
-- # cmake to the extension
-Ddlisio_DIR=${DLISIO_LIB_BINARY_DIR}
-Dmio_DIR=${MIO_LIB_BINARY_DIR}
-Dmpark_DIR=${MPARK_LIB_BINARY_DIR}
# "install" to the python/dlisio dir with rpath, so there's no need
# to fiddle with environment in ctest to load the core library from
# the build tree
Expand Down
4 changes: 3 additions & 1 deletion python/setup-CMakeLists.txt
Expand Up @@ -7,14 +7,16 @@ set(CMAKE_C_VISIBILITY_PRESET "hidden")

find_package(PythonExtensions REQUIRED)
find_package(dlisio REQUIRED)
find_package(mio REQUIRED)
find_package(mpark REQUIRED)

add_library(core MODULE dlisio/ext/core.cpp)
target_include_directories(core
PRIVATE
${PYBIND11_INCLUDE_DIRS}
)
python_extension_module(core)
target_link_libraries(core dlisio dlisio-extension)
target_link_libraries(core dlisio dlisio-extension mio::mio mpark::mpark-variant)

if (MSVC)
target_compile_options(core
Expand Down

0 comments on commit fe154b8

Please sign in to comment.