Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Switch Python bindings to pybind11. #57

Merged
merged 6 commits into from
Jul 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Detect version via python.
  • Loading branch information
matz-e committed Jun 28, 2019
commit 5b7aa4e8596e6e04b9f022bcac9934baa6370836
42 changes: 31 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
project(MVDTool)
cmake_minimum_required(VERSION 3.0)

include(CTest)

set(MVDTOOL_VERSION_MAJOR 2)
set(MVDTOOL_VERSION_MINOR 0)
set(MVDTOOL_VERSION_PATCH 0)
# get version from Python package
find_package(PythonInterp REQUIRED)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but isn't that for module dependencies? We're trying to get just the version out of setup.py, without requiring any python modules to be installed, really.

execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py --version
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE PY_VERSION_FAILED
OUTPUT_VARIABLE PY_PKG_VERSION_FULL
ERROR_VARIABLE PY_VERSION_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PY_VERSION_FAILED)
message(
FATAL_ERROR
"Could not retrieve version from command '${PYTHON_EXECUTABLE} setup.py --version'\n"
${PY_VERSION_ERROR})
endif()
# keep last line of command output
string(REPLACE "\n"
";"
PY_PKG_VERSION_FULL
"${PY_PKG_VERSION_FULL}")
list(GET PY_PKG_VERSION_FULL -1 PY_PKG_VERSION_FULL)
# keep MAJOR.MINOR.PATCH
string(REGEX
REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+).*"
"\\1"
PY_PKG_VERSION
"${PY_PKG_VERSION_FULL}")

project(MVDTool VERSION ${PY_PKG_VERSION})

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake
${PROJECT_SOURCE_DIR}/CMake/portability
${PROJECT_SOURCE_DIR}/CMake/packages
${PROJECT_SOURCE_DIR}/CMake/config)

include(CTest)
include(GNUInstallDirs)
include(PackageConfig)
include(ReleaseDebugAutoFlags)


option(MVDTOOL_INSTALL_HIGHFIVE "Install header of dependency HighFive (needed for subprojects)" ON)
option(MVDTOOL_UNIT_TESTS "Enable or disable unit tests" ON)
option(BUILD_UNIT_TESTS "Enable or disable unit tests" ON)
option(BUILD_PYTHON_BINDINGS "Build python bindings?" OFF)
set(Boost_NO_BOOST_CMAKE TRUE)

Expand All @@ -26,8 +48,6 @@ find_package(Boost 1.41 QUIET REQUIRED COMPONENTS system)
find_package(HDF5 QUIET REQUIRED)
find_package(HighFive QUIET REQUIRED)

include(PackageConfig)

FILE(GLOB MVDTOOL_HEADERS "include/mvd/*.hpp")
FILE(GLOB MVDTOOLE_BITS_HEADERS "include/mvd/*/*.hpp")
set(MVDTOOL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
Expand Down