Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Python headers #43

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 10 additions & 22 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)

# link solver, eigenpy, Boost.Python
target_link_libraries(${PYLIB_NAME} PUBLIC ${PROJECT_NAME} eigenpy::eigenpy)
Expand All @@ -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)
Expand Down
File renamed without changes.
Loading