|
| 1 | +cmake_minimum_required(VERSION 3.12) |
| 2 | +project(krbalancing VERSION 0.0.5) |
| 3 | + |
| 4 | +list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) |
| 5 | +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) |
| 6 | + |
| 7 | +set(CMAKE_CXX_STANDARD 11) |
| 8 | + |
| 9 | +if(NOT CMAKE_BUILD_TYPE) |
| 10 | + set(CMAKE_BUILD_TYPE Release) |
| 11 | +endif() |
| 12 | + |
| 13 | +include(${CMAKE_SOURCE_DIR}/cmake/conan.cmake) |
| 14 | + |
| 15 | +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) |
| 16 | + |
| 17 | +# pybind11 config file has a bug that makes is impossible to use with |
| 18 | +# conan_cmake_configure. |
| 19 | +# https://github.com/conan-io/conan-center-index/pull/4445 |
| 20 | +conan_cmake_configure(REQUIRES |
| 21 | + # pybind11/2.6.1 |
| 22 | + eigen/3.3.9 |
| 23 | + GENERATORS cmake_find_package) |
| 24 | +# find_package(pybind11 REQUIRED) |
| 25 | + |
| 26 | +conan_cmake_autodetect(settings) |
| 27 | +conan_cmake_install(PATH_OR_REFERENCE . |
| 28 | + BUILD missing |
| 29 | + REMOTE conan-center |
| 30 | + SETTINGS ${settings}) |
| 31 | + |
| 32 | +find_package(Eigen3 REQUIRED) |
| 33 | + |
| 34 | + |
| 35 | +# hack around pybind11 bug |
| 36 | +# https://github.com/conan-io/conan-center-index/pull/4445 |
| 37 | +conan_cmake_run(REQUIRES pybind11/2.6.1 |
| 38 | + BASIC_SETUP NO_OUTPUT_DIRS CMAKE_TARGETS |
| 39 | + BUILD missing) |
| 40 | + |
| 41 | + |
| 42 | +Python3_add_library(krbalancing MODULE WITH_SOABI src/krbalancing.cpp) |
| 43 | +target_link_libraries(krbalancing PRIVATE Eigen3::Eigen CONAN_PKG::pybind11) |
| 44 | +set_target_properties(krbalancing PROPERTIES |
| 45 | + INTERPROCEDURAL_OPTIMIZATION ON |
| 46 | + VISIBLITY_INLINES_HIDDEN ON) |
| 47 | + |
| 48 | +configure_file(${CMAKE_SOURCE_DIR}/setup.py.in ${CMAKE_BINARY_DIR}/setup.py) |
| 49 | + |
| 50 | +add_custom_target(wheel ALL |
| 51 | + DEPENDS krbalancing |
| 52 | + COMMAND ${Python3_EXECUTABLE} setup.py bdist_wheel -d ${CMAKE_BINARY_DIR} |
| 53 | + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
| 54 | + COMMENT "Generating wheel") |
0 commit comments