forked from cyang-kth/fmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
43 lines (38 loc) · 1.55 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
# Make sure the swig package is loaded.
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
if (SWIG_FOUND)
message(STATUS "Swig version is ${SWIG_VERSION}")
else()
message(FATAL_ERROR "Swig not found!\n")
endif()
find_package(PythonInterp REQUIRED)
find_package(PythonLibs REQUIRED)
if (PYTHONLIBS_FOUND)
message(STATUS "Python header found at ${PYTHON_INCLUDE_DIRS}")
message(STATUS "Python library found at ${PYTHON_LIBRARIES}")
include_directories(${PYTHON_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Python library not found!\n")
endif()
execute_process(
COMMAND python -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())"
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Python packages ${PYTHON_SITE_PACKAGES}")
set_source_files_properties(
${PROJECT_SOURCE_DIR}/python/fmm.i PROPERTIES CPLUSPLUS ON)
if (${CMAKE_VERSION} VERSION_LESS 3.13.0)
message(STATUS "Using swig add module")
SWIG_ADD_MODULE(fmm python ${PROJECT_SOURCE_DIR}/python/fmm.i)
swig_link_libraries(fmm FMMLIB ${PYTHON_LIBRARIES})
install(TARGETS ${SWIG_MODULE_fmm_REAL_NAME} DESTINATION ${PYTHON_SITE_PACKAGES})
else()
message(STATUS "Using swig add library")
SWIG_ADD_LIBRARY(pyfmm
LANGUAGE python
SOURCES ${PROJECT_SOURCE_DIR}/python/fmm.i)
set_property(TARGET pyfmm PROPERTY OUTPUT_NAME fmm)
swig_link_libraries(pyfmm FMMLIB ${PYTHON_LIBRARIES})
install(TARGETS pyfmm DESTINATION ${PYTHON_SITE_PACKAGES})
endif()
install(FILES ${CMAKE_BINARY_DIR}/python/fmm.py DESTINATION ${PYTHON_SITE_PACKAGES})