-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCMakeLists.txt
65 lines (48 loc) · 2.23 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
project(PySubnetTree C CXX)
include(cmake/CommonCMakeConfig.cmake)
# ##############################################################################
# Dependency Configuration
find_package(SWIG 1.3.30 REQUIRED)
list(APPEND Python_ADDITIONAL_VERSIONS 3)
find_package(Python 3.9 REQUIRED COMPONENTS Interpreter Development)
include_directories(BEFORE ${Python_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# ##############################################################################
# Build Python Extension
cmake_policy(SET CMP0078 NEW)
cmake_policy(SET CMP0086 NEW)
include(UseSWIG)
set_source_files_properties(SubnetTree.i PROPERTIES CPLUSPLUS true)
set(SWIG_MODULE_SubnetTree_EXTRA_DEPS include/SubnetTree.h)
swig_add_library(SubnetTree LANGUAGE python SOURCES SubnetTree.i SubnetTree.cc patricia.c)
swig_link_libraries(SubnetTree ${Python_LIBRARIES})
set_source_files_properties(${swig_generated_file_fullname} SubnetTree.cc
PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
# ##############################################################################
# Install Files
if (NOT PY_MOD_INSTALL_DIR)
# the configure wrapper was not used, default to "home" style installation
set(PY_MOD_INSTALL_DIR lib/python)
endif ()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SubnetTree.py DESTINATION ${PY_MOD_INSTALL_DIR})
install(TARGETS SubnetTree DESTINATION ${PY_MOD_INSTALL_DIR})
# ##############################################################################
# Build Summary
if (CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
endif ()
message(
"\n===============| PySubnetTree Build Summary |================="
"\n"
"\nInstall dir: ${PY_MOD_INSTALL_DIR}"
"\nDebug mode: ${ENABLE_DEBUG}"
"\n"
"\nCC: ${CMAKE_C_COMPILER}"
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
"\nCPP: ${CMAKE_CXX_COMPILER}"
"\n"
"\n================================================================\n")
include(UserChangedWarning)