|
| 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_default.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 | + # Check if the library file exists |
| 31 | + cmake_path(APPEND Python3_SITELIB cmeel.prefix lib libpinocchio_parsers.so OUTPUT_VARIABLE pinocchio_parsers_path) |
| 32 | + if (NOT EXISTS ${pinocchio_parsers_path}) |
| 33 | + set(pinocchio_FOUND FALSE) |
| 34 | + if (pinocchio_FIND_REQUIRED) |
| 35 | + message(FATAL_ERROR "Could not find pinocchio parsers path. Please install pinocchio using pip.") |
| 36 | + endif() |
| 37 | + return() |
| 38 | + endif() |
| 39 | + |
| 40 | + # Extract version from the library filename |
| 41 | + file(GLOB pinocchio_dist_info "${Python3_SITELIB}/pin-*.dist-info") |
| 42 | + cmake_path(GET pinocchio_dist_info FILENAME pinocchio_library_filename) |
| 43 | + string(REPLACE "pin-" "" pinocchio_VERSION "${pinocchio_library_filename}") |
| 44 | + string(REPLACE ".dist-info" "" pinocchio_VERSION "${pinocchio_VERSION}") |
| 45 | + |
| 46 | + # Create the imported target |
| 47 | + add_library(pinocchio::pinocchio SHARED IMPORTED) |
| 48 | + target_include_directories(pinocchio::pinocchio INTERFACE ${pinocchio_INCLUDE_DIRS}) |
| 49 | + set_target_properties(pinocchio::pinocchio |
| 50 | + PROPERTIES |
| 51 | + IMPORTED_LOCATION "${pinocchio_library_path}" |
| 52 | + ) |
| 53 | + |
| 54 | + add_library(pinocchio::parsers SHARED IMPORTED) |
| 55 | + target_include_directories(pinocchio::parsers INTERFACE ${pinocchio_INCLUDE_DIRS}) |
| 56 | + set_target_properties(pinocchio::parsers |
| 57 | + PROPERTIES |
| 58 | + IMPORTED_LOCATION "${pinocchio_parsers_path}" |
| 59 | + ) |
| 60 | + |
| 61 | + add_library(pinocchio::all INTERFACE IMPORTED) |
| 62 | + set_target_properties(pinocchio::all |
| 63 | + PROPERTIES |
| 64 | + INTERFACE_LINK_LIBRARIES "pinocchio::pinocchio;pinocchio::parsers" |
| 65 | + ) |
| 66 | + set(pinocchio_FOUND TRUE) |
| 67 | + |
| 68 | +endif() |
0 commit comments