From 7f9eec28baf2a99006bc88a79fe7c5c67b14187a Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Tue, 19 Dec 2023 11:03:48 +0100 Subject: [PATCH] [bindings/python] move Python bindings' headers + [cmake] remove symlinking of headers to build-dir hierarchy + fix install of headers using install(DIRECTORY) flow + set include directories of Python target --- bindings/python/CMakeLists.txt | 32 ++++++------------- .../proxsuite-nlp/python}/function.hpp | 0 .../proxsuite-nlp/python}/fwd.hpp | 0 .../proxsuite-nlp/python}/policies.hpp | 0 .../proxsuite-nlp/python}/residuals.hpp | 0 .../proxsuite-nlp/python}/utils/namespace.hpp | 0 6 files changed, 10 insertions(+), 22 deletions(-) rename bindings/python/{ => include/proxsuite-nlp/python}/function.hpp (100%) rename bindings/python/{ => include/proxsuite-nlp/python}/fwd.hpp (100%) rename bindings/python/{ => include/proxsuite-nlp/python}/policies.hpp (100%) rename bindings/python/{ => include/proxsuite-nlp/python}/residuals.hpp (100%) rename bindings/python/{ => include/proxsuite-nlp/python}/utils/namespace.hpp (100%) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index db9447b4..bcbf7133 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -10,19 +10,14 @@ include(${PROJECT_SOURCE_DIR}/cmake/python-helpers.cmake) include(${PROJECT_SOURCE_DIR}/cmake/stubs.cmake) # identify bindings C++ source files -file(GLOB_RECURSE ${PYLIB_NAME}_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - -file(GLOB_RECURSE ${PYLIB_NAME}_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) - -set(PY_HEADERS ${${PYLIB_NAME}_HEADERS}) -set(PY_SOURCES ${${PYLIB_NAME}_SOURCES}) +file(GLOB_RECURSE PY_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE PY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) add_header_group(PY_HEADERS) function(MAKE_BINDINGS) add_library(${PYLIB_NAME} SHARED ${PY_SOURCES} ${PY_HEADERS}) - target_include_directories(${PYLIB_NAME} SYSTEM PRIVATE ${PYTHON_INCLUDE_DIRS}) set_target_properties( ${PYLIB_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "proxsuite_nlp" @@ -36,6 +31,9 @@ function(MAKE_BINDINGS) target_compile_options(${PYLIB_NAME} PRIVATE -Wno-conversion -Wno-comment) target_compile_definitions(${PYLIB_NAME} PRIVATE MODULE_NAME=${PYLIB_NAME}) + target_include_directories( + ${PYLIB_NAME} PUBLIC $ + $) # link solver, eigenpy, Boost.Python target_link_libraries(${PYLIB_NAME} PUBLIC ${PROJECT_NAME} eigenpy::eigenpy) @@ -47,21 +45,11 @@ endfunction() make_bindings() -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/python - ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/python/utils) - -# copy headers to build/include/ directory -# TODO: fix include path -foreach(pyheader ${PY_HEADERS}) - string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" pyheader ${pyheader}) - get_filename_component(headerPath ${pyheader} PATH) - execute_process(COMMAND ${CMAKE_COMMAND} -E ${LINK} ${CMAKE_CURRENT_SOURCE_DIR}/${pyheader} - ${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/python/${pyheader}) - install( - FILES ${pyheader} - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/proxsuite-nlp/python/${headerPath} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) -endforeach(pyheader) +install( + DIRECTORY include/${PROJECT_NAME} + DESTINATION "include" + FILES_MATCHING + PATTERN "*.hpp") # COPY PYTHON FILES INTO OUTPUT FOLDER set(${PYLIB_NAME}_PYFILES __init__.py casadi_utils.py utils.py) diff --git a/bindings/python/function.hpp b/bindings/python/include/proxsuite-nlp/python/function.hpp similarity index 100% rename from bindings/python/function.hpp rename to bindings/python/include/proxsuite-nlp/python/function.hpp diff --git a/bindings/python/fwd.hpp b/bindings/python/include/proxsuite-nlp/python/fwd.hpp similarity index 100% rename from bindings/python/fwd.hpp rename to bindings/python/include/proxsuite-nlp/python/fwd.hpp diff --git a/bindings/python/policies.hpp b/bindings/python/include/proxsuite-nlp/python/policies.hpp similarity index 100% rename from bindings/python/policies.hpp rename to bindings/python/include/proxsuite-nlp/python/policies.hpp diff --git a/bindings/python/residuals.hpp b/bindings/python/include/proxsuite-nlp/python/residuals.hpp similarity index 100% rename from bindings/python/residuals.hpp rename to bindings/python/include/proxsuite-nlp/python/residuals.hpp diff --git a/bindings/python/utils/namespace.hpp b/bindings/python/include/proxsuite-nlp/python/utils/namespace.hpp similarity index 100% rename from bindings/python/utils/namespace.hpp rename to bindings/python/include/proxsuite-nlp/python/utils/namespace.hpp