|
| 1 | +if (NOT pinocchio_FOUND) |
| 2 | + if (NOT Python3_FOUND) |
| 3 | + set(pinocchio_FOUND FALSE) |
| 4 | + if (pinocchio_FIND_REQUIRED) |
| 5 | + message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.") |
| 6 | + endif() |
| 7 | + return() |
| 8 | + endif() |
| 9 | + |
| 10 | + # Check if the include directory exists |
| 11 | + cmake_path(APPEND Python3_SITELIB cmeel.prefix include OUTPUT_VARIABLE pinocchio_INCLUDE_DIRS) |
| 12 | + if (NOT EXISTS ${pinocchio_INCLUDE_DIRS}) |
| 13 | + set(pinocchio_FOUND FALSE) |
| 14 | + if (pinocchio_FIND_REQUIRED) |
| 15 | + message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.") |
| 16 | + endif() |
| 17 | + return() |
| 18 | + endif() |
| 19 | + |
| 20 | + # Check if the library file exists |
| 21 | + cmake_path(APPEND Python3_SITELIB cmeel.prefix lib libpinocchio.so OUTPUT_VARIABLE pinocchio_library_path) |
| 22 | + if (NOT EXISTS ${pinocchio_library_path}) |
| 23 | + set(pinocchio_FOUND FALSE) |
| 24 | + if (pinocchio_FIND_REQUIRED) |
| 25 | + message(FATAL_ERROR "Could not find pinocchio. Please install pinocchio using pip.") |
| 26 | + endif() |
| 27 | + return() |
| 28 | + endif() |
| 29 | + |
| 30 | + # Extract version from the library filename |
| 31 | + file(GLOB pinocchio_dist_info "${Python3_SITELIB}/pin-*.dist-info") |
| 32 | + cmake_path(GET pinocchio_dist_info FILENAME pinocchio_library_filename) |
| 33 | + string(REPLACE "pin-" "" pinocchio_VERSION "${pinocchio_library_filename}") |
| 34 | + string(REPLACE ".dist-info" "" pinocchio_VERSION "${pinocchio_VERSION}") |
| 35 | + |
| 36 | + # Create the imported target |
| 37 | + add_library(pinocchio::pinocchio SHARED IMPORTED) |
| 38 | + target_include_directories(pinocchio::pinocchio INTERFACE ${pinocchio_INCLUDE_DIRS}) |
| 39 | + set_target_properties( |
| 40 | + pinocchio::pinocchio |
| 41 | + PROPERTIES |
| 42 | + IMPORTED_LOCATION "${pinocchio_library_path}" |
| 43 | + ) |
| 44 | + set(pinocchio_FOUND TRUE) |
| 45 | +endif() |
0 commit comments