Skip to content

Commit

Permalink
Improved CMakeLists.txt
Browse files Browse the repository at this point in the history
The python module now only link with pointmatcher instead of building it.
The python module can now be installed.
  • Loading branch information
aguenette committed Aug 14, 2020
1 parent b80b5ac commit c519c15
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ endif()

# ========================= Python module =============================
option(BUILD_PYTHON_MODULE "Build the python module for libpointmatcher" OFF)
set(PYTHON_INSTALL_TARGET "" CACHE PATH "Target where to install the python module")

if (BUILD_PYTHON_MODULE)
add_subdirectory(python)
Expand Down
61 changes: 33 additions & 28 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
cmake_minimum_required(VERSION 2.8.12)
find_package(pybind11 2.5.0 REQUIRED)

include_directories(${CMAKE_SOURCE_DIR}/pointmatcher)
include_directories(${CMAKE_SOURCE_DIR}/pointmatcher/DataPointsFilters)
include_directories(${CMAKE_SOURCE_DIR}/pointmatcher/DataPointsFilters/utils)
include_directories(${CMAKE_SOURCE_DIR}/pointmatcher/ErrorMinimizers)
if ("${PYTHON_INSTALL_TARGET}" STREQUAL "")
message(STATUS "PYTHON_INSTALL_TARGET variable is not set, setting to a default one...")
execute_process(COMMAND "python3" "-c" "import site; print(site.getsitepackages()[0])"
OUTPUT_VARIABLE PYTHON_INSTALL_TARGET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

foreach (file ${POINTMATCHER_SRC})
set(PYTHON_SRC ${PYTHON_SRC} ../${file})
endforeach()
message(STATUS "The Python module will be install at this location : ${PYTHON_INSTALL_TARGET}")

set(PYBIND11_SOURCES
#pointmatcher module
#pointmatcher module
pointmatcher/datapoints.cpp
pointmatcher/datapointsfilter.cpp
pointmatcher/datapointsfilters.cpp
Expand All @@ -27,6 +24,7 @@ set(PYBIND11_SOURCES
pointmatcher/impls/transformationcheckers_impl.cpp
pointmatcher/impl.cpp
pointmatcher/inspector.cpp
pointmatcher/io.cpp
pointmatcher/matcher.cpp
pointmatcher/matches.cpp
pointmatcher/outlierfilter.cpp
Expand All @@ -37,9 +35,7 @@ set(PYBIND11_SOURCES
pointmatcher/transformationchecker.cpp
pointmatcher/transformationcheckers.cpp

modules/pointmatcher_module.cpp

#pointmatchersupport module
#pointmatchersupport module
pointmatchersupport/bibliography.cpp
pointmatchersupport/logger.cpp
pointmatchersupport/logger_impl.cpp
Expand All @@ -54,19 +50,15 @@ set(PYBIND11_SOURCES
pointmatchersupport/registrars/transformationchecker_registrar.cpp
pointmatchersupport/registrar.cpp

modules/pointmatchersupport_module.cpp

#errorminimizers module
#errorminimizers module
errorminimizers/identity.cpp
errorminimizers/pointtoplane.cpp
errorminimizers/pointtoplanewithcov.cpp
errorminimizers/pointtopoint.cpp
errorminimizers/pointtopointsimilarity.cpp
errorminimizers/pointtopointwithcov.cpp

modules/errorminimizers_module.cpp

#datapointfilters module
#datapointfilters module
datapointsfilters/boundingbox.cpp
datapointsfilters/covariancesampling.cpp
datapointsfilters/cutatdescriptorthreshold.cpp
Expand All @@ -92,21 +84,34 @@ set(PYBIND11_SOURCES
datapointsfilters/sphericality.cpp
datapointsfilters/surfacenormal.cpp

modules/pointmatcher_module.cpp
modules/pointmatchersupport_module.cpp
modules/datapointsfilters_module.cpp
modules/errorminimizers_module.cpp

# main module
# main module
pypointmatcher.cpp)

find_package(pybind11 REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/pointmatcher
${CMAKE_SOURCE_DIR}/pointmatcher/DataPointsFilters
${CMAKE_SOURCE_DIR}/pointmatcher/DataPointsFilters/utils
${CMAKE_SOURCE_DIR}/pointmatcher/ErrorMinimizers)

if (pybind11_FOUND)
message(STATUS "pybind11 v${pybind11_VERSION}\n")
message(STATUS "pybind11 v${pybind11_VERSION}")

pybind11_add_module(pypointmatcher ${PYBIND11_SOURCES})

pybind11_add_module(pypointmatcher
${PYTHON_SRC}
${PYBIND11_SOURCES})
target_link_libraries(pypointmatcher
PRIVATE
pointmatcher
${EXTERNAL_LIBS})

target_link_libraries(pypointmatcher PRIVATE ${EXTERNAL_LIBS})
add_dependencies(pypointmatcher pointmatcher)

add_dependencies(pypointmatcher ${EXTRA_DEPS})
install(TARGETS pypointmatcher LIBRARY DESTINATION ${PYTHON_INSTALL_TARGET})
else ()
message(FATAL_ERROR "pybind11 version required! Please follow the \"Compiling \
libpointmatcher's with Python\" instructions from the official libpointmatcher's documentation.")
endif ()

0 comments on commit c519c15

Please sign in to comment.