File: CMakeLists.txt

package info (click to toggle)
poselib 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,592 kB
  • sloc: cpp: 15,023; python: 182; sh: 85; makefile: 10
file content (44 lines) | stat: -rw-r--r-- 1,678 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# setup PYTHON_EXECUTABLE

find_package (Python COMPONENTS Interpreter Development)
message(STATUS "Python_EXECUTABLE: " ${Python_EXECUTABLE})

option(GENERATE_STUBS "Whether to generate stubs" ON)

add_subdirectory(pybind11)

pybind11_add_module(pyposelib MODULE pyposelib.cc)
target_link_libraries(pyposelib PUBLIC PoseLib::PoseLib Eigen3::Eigen)
set_target_properties(pyposelib PROPERTIES OUTPUT_NAME _core)
set_compile_flags(pyposelib)

# Install the compiled module
install(TARGETS pyposelib LIBRARY DESTINATION . COMPONENT python)

if(GENERATE_STUBS)
    message(STATUS "Enabling stubs generation")
    set(STUBGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/_core")
    add_custom_command(
        TARGET pyposelib POST_BUILD
        COMMAND
          "${CMAKE_COMMAND}" -E env
          "PYTHONPATH=$<TARGET_FILE_DIR:pyposelib>$<SEMICOLON>$ENV{PYTHONPATH}"
          "${Python_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/pybind/generate_stubs.py" "${Python_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}"
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        COMMENT "Generating pybind11 stubs"
        VERBATIM
    )
    
    # Install the generated stub file (handle both single file and directory cases)
    # Most pybind11_stubgen versions create a single .pyi file
    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/_core.pyi" 
            DESTINATION .
            COMPONENT python
            OPTIONAL)  # OPTIONAL in case it doesn't exist
            
    # Some versions might create a directory instead
    install(DIRECTORY "${STUBGEN_OUTPUT_DIR}/" 
            DESTINATION .
            COMPONENT python
            OPTIONAL)  # OPTIONAL in case it doesn't exist
endif()