Commit fe22fccc authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

add library cmake definition

1 merge request!1release v0.1.0.0
Pipeline #42592 failed with stage
in 1 minute and 11 seconds
Showing with 91 additions and 0 deletions
+91 -0
cmake_minimum_required(VERSION 3.15)
project(
EvalHyd-Python
LANGUAGES CXX C
VERSION 0.0.1
DESCRIPTION "Python bindings for evalhyd utility"
)
add_library(
evalhyd-python MODULE
${CMAKE_CURRENT_SOURCE_DIR}/src/evalhyd-python.cpp
)
# ------------------------------------------------------------------------------
# dependencies and build
# ------------------------------------------------------------------------------
if(SKBUILD)
find_package(PythonExtensions REQUIRED)
find_package(NumPy REQUIRED)
python_extension_module(evalhyd-python)
else()
find_package(Python COMPONENTS Interpreter Development NumPy REQUIRED)
target_link_libraries(evalhyd-python Python::NumPy)
# use only header if numpy target links to libpython
#target_include_directories(evalhyd-python SYSTEM PRIVATE "${Python_NumPy_INCLUDE_DIRS}")
endif()
find_package(xtensor REQUIRED)
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
find_package(xtensor-python REQUIRED)
message(STATUS "Found xtensor-python: ${xtensor-python_INCLUDE_DIRS}/xtensor-python")
find_package(pybind11 REQUIRED)
message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIRS}/pybind11")
if(DEFINED EVALHYD_SRC)
set(EVALHYD_BUILD_TEST OFF CACHE BOOL "configure and compile tests")
add_subdirectory(${EVALHYD_SRC} deps/evalhyd)
else()
find_package(EvalHyd REQUIRED)
endif()
target_link_libraries(
evalhyd-python
EvalHyd::evalhyd
xtensor-python
pybind11::module
pybind11::lto
pybind11::windows_extras
)
set_target_properties(
evalhyd-python PROPERTIES
OUTPUT_NAME evalhyd
)
pybind11_extension(evalhyd-python)
if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
# Strip unnecessary sections of the binary on Linux/macOS
pybind11_strip(evalhyd-python)
endif()
set_target_properties(
evalhyd-python PROPERTIES
CXX_VISIBILITY_PRESET "hidden"
CUDA_VISIBILITY_PRESET "hidden"
)
# add include directories
target_include_directories(
evalhyd-python
PUBLIC
${NUMPY_INCLUDE_DIRS}
)
# ------------------------------------------------------------------------------
# installation
# ------------------------------------------------------------------------------
if(SKBUILD)
install(
TARGETS evalhyd-python
DESTINATION evalhyd-python
)
endif()
......@@ -2,7 +2,10 @@
requires = [
"setuptools>=42",
"wheel",
"scikit-build",
"cmake",
"pybind11>=2.8.0",
"ninja",
"numpy>1.16",
]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment