|
| 1 | +cmake_minimum_required(VERSION 3.15...3.26) |
| 2 | + |
| 3 | +project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX) |
| 4 | + |
| 5 | +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) |
| 6 | + |
| 7 | +include(GNUInstallDirs) |
| 8 | +include(CMakePackageConfigHelpers) |
| 9 | + |
| 10 | +find_package(Base CONFIG REQUIRED) |
| 11 | +find_package(Python COMPONENTS Interpreter Development.Module) |
| 12 | + |
| 13 | +add_executable(main src/main.cpp) |
| 14 | +add_library(other SHARED src/other.cpp) |
| 15 | +python_add_library(_module MODULE src/module.cpp WITH_SOABI) |
| 16 | + |
| 17 | +target_link_libraries(other PRIVATE base::base) |
| 18 | +target_link_libraries(main PRIVATE other) |
| 19 | +target_link_libraries(_module PRIVATE base::base) |
| 20 | + |
| 21 | +install(TARGETS main other) |
| 22 | +install(TARGETS _module DESTINATION ".") |
| 23 | + |
| 24 | +if(DO_MANUAL_REPAIR) |
| 25 | + if(APPLE) |
| 26 | + set(origin_token "@loader_path") |
| 27 | + else() |
| 28 | + set(origin_token "$ORIGIN") |
| 29 | + endif() |
| 30 | + set_property( |
| 31 | + TARGET main PROPERTY INSTALL_RPATH |
| 32 | + "${origin_token}/../${CMAKE_INSTALL_LIBDIR}") |
| 33 | + set_property( |
| 34 | + TARGET other |
| 35 | + PROPERTY INSTALL_RPATH |
| 36 | + "${origin_token}/../../base_project/${CMAKE_INSTALL_LIBDIR}") |
| 37 | + set_property( |
| 38 | + TARGET _module |
| 39 | + PROPERTY INSTALL_RPATH |
| 40 | + "${origin_token}/../base_project/${CMAKE_INSTALL_LIBDIR}") |
| 41 | + if(WIN32) |
| 42 | + install(TARGETS other RUNTIME DESTINATION ${SKBUILD_SCRIPTS_DIR}) |
| 43 | + file( |
| 44 | + WRITE ${CMAKE_CURRENT_BINARY_DIR}/__init__.py |
| 45 | + " |
| 46 | +import os |
| 47 | +import sysconfig |
| 48 | +from pathlib import Path |
| 49 | +
|
| 50 | +base_project_bindir = Path(__file__).parent / \"../base_project/${CMAKE_INSTALL_BINDIR}\" |
| 51 | +project_bindir = Path(__file__).parent / \"${CMAKE_INSTALL_BINDIR}\" |
| 52 | +os.add_dll_directory(str(base_project_bindir)) |
| 53 | +os.add_dll_directory(str(project_bindir)) |
| 54 | +") |
| 55 | + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py DESTINATION ".") |
| 56 | + endif() |
| 57 | +endif() |
0 commit comments