forked from txjmb/dnpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
102 lines (85 loc) · 3.36 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
cmake_minimum_required(VERSION 3.12)
project(dnpy3_cmake_build
LANGUAGES CXX
VERSION 0.2
HOMEPAGE_URL "https://github.com/txjmb/dnpy"
DESCRIPTION "cppyy-generated bindings for opendnp3")
if(DEFINED ENV{CONDA_PREFIX})
message(STATUS "Building in a conda environment.")
set(CONDA_ACTIVE TRUE)
set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}")
set(CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
set(CMAKE_INCLUDE_PATH "$ENV{CONDA_PREFIX}/include")
#include_directories($ENV{CONDA_PREFIX}/include)
set(CMAKE_LIBRARY_PATH "$ENV{CONDA_PREFIX}/lib")
endif()
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
#
# Add our project's cmake dir the the module path. This gives us the
# Cppyy commands and targets.
#
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
find_package(Cppyy)
#
# Make the default build us c++17 and "RELEASE" (-O3)
#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# headers and sources are listed in a cmake file.
add_subdirectory(${CMAKE_SOURCE_DIR}/deps/opendnp3)
include(${CMAKE_SOURCE_DIR}/manifest.cmake)
include(GNUInstallDirs)
#
# Set up the knn shared lib
#
# add_library(opendnp3
# SHARED
# ${LIB_SOURCES}
# )
# set_target_properties(opendnp3 PROPERTIES LINKER_LANGUAGE CXX)
# set_target_properties(opendnp3 PROPERTIES
# VERSION ${PROJECT_VERSION}
# SOVERSION 1
# )
# set_target_properties(opendnp3 PROPERTIES PUBLIC_HEADER ${LIB_HEADERS})
# target_include_directories(opendnp3
# PUBLIC
# #${CMAKE_SOURCE_DIR}/src/
# ${CMAKE_SOURCE_DIR}/deps/opendnp3/cpp/lib/include/opendnp3/
# ${CMAKE_SOURCE_DIR}/deps/opendnp3/cpp/src/
# )
#
# Set up the Cppyy bindings generation. This is a customized version defined
# in boink's cmake/ dir; it uses genreflex rather than calling rootcling directly.
# I did this because I couldn't get rootcling to properly include/exclude classes
# via the LinkDef header, and I wanted to be able to use the better syntax in
# the genreflex selection XML anyhow. Also, I think this is now the recommended /
# more modern way anyhow? Code was modified from the versions cppyy distributes.
#
cppyy_add_bindings(
"dnpy" "${PROJECT_VERSION}" "Michael Bohan" ""
LICENSE "MIT"
LANGUAGE_STANDARD "17"
SELECTION_XML ${CMAKE_SOURCE_DIR}/selection.xml
INTERFACE_FILE ${CMAKE_SOURCE_DIR}/interface.hh
HEADERS ${LIB_HEADERS}
INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/deps/opendnp3/cpp/lib/include/opendnp3
LINK_LIBRARIES libopendnp3.so
NAMESPACES opendnp3
)
#target_link_libraries(${CMAKE_SOURCE_DIR}/deps/opendnp3 PUBLIC ${CMAKE_SOURCE_DIR}/build/deps/opendnp3/cpp/lib/libopendnp3.so)
install(TARGETS opendnp3
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/opendnp3/
)
#install(CODE "message(STATUS \"Attempting pip install\" ${PY_WHEEL_FILE})")
install(CODE "message(STATUS \"Attempting pip install\" ${PY_WHEEL_FILE})"
CODE "execute_process(COMMAND pip install ${PY_WHEEL_FILE})"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)