-
-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathCMakeLists.txt
49 lines (40 loc) · 1.41 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cmake_minimum_required(VERSION 3.12)
project(pyf3d)
find_package(Python 3.6 COMPONENTS Interpreter Development)
find_package(pybind11 2.2 REQUIRED)
pybind11_add_module(pyf3d MODULE F3DPythonBindings.cxx)
# In case pyf3d is built separately, we need to retrieve the existing libf3d
if(TARGET libf3d)
target_link_libraries(pyf3d PRIVATE libf3d)
else()
find_package(f3d REQUIRED)
target_link_libraries(pyf3d PRIVATE f3d::libf3d)
target_include_directories(pyf3d PRIVATE "${f3d_INCLUDE_DIR}/f3d")
endif()
set_target_properties(pyf3d PROPERTIES
CXX_STANDARD 14
CXX_VISIBILITY_PRESET hidden
LIBRARY_OUTPUT_NAME "f3d"
)
if(WIN32)
# On Windows, the python module needs to be in the same folder than f3d.dll
# Usage of PATH to find the DLL is not possible, see https://stackoverflow.com/a/64303856/2609654
set_target_properties(pyf3d PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
)
endif()
if (APPLE OR UNIX)
set_target_properties(pyf3d PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif ()
# testing
if(BUILD_TESTING)
add_subdirectory(testing)
endif()
# installing
if(WIN32)
set(PYTHON_INSTALL_PATH ${CMAKE_INSTALL_BINDIR})
else()
set(PYTHON_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
endif()
install(TARGETS pyf3d
LIBRARY DESTINATION ${PYTHON_INSTALL_PATH} COMPONENT pythonmodule)