CMakeLists.txt 3.92 KB
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright 2010, 2011, Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST
#
# This file is part of dynamic-graph-python.
# dynamic-graph-python is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# dynamic-graph-python is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Lesser Public License for more details.  You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph-python. If not, see <http://www.gnu.org/licenses/>.
florent's avatar
florent committed
15
16
17
18
19
20

#
# Python
#
INCLUDE(FindPythonLibs)
IF (NOT ${PYTHONLIBS_FOUND} STREQUAL TRUE)
21
22
23
  MESSAGE(FATAL_ERROR "Python has not been found.")
ELSE()
  MESSAGE(STATUS "PYTHON_LIBRARY=${PYTHON_LIBRARY}")
florent's avatar
florent committed
24
25
26
27
28
29
30
ENDIF (NOT ${PYTHONLIBS_FOUND} STREQUAL TRUE)

INCLUDE(FindPythonInterp)
IF (NOT ${PYTHONINTERP_FOUND} STREQUAL TRUE)
   MESSAGE(FATAL_ERROR "Python executable has not been found.")
ENDIF (NOT ${PYTHONINTERP_FOUND} STREQUAL TRUE)

31
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
32
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
florent's avatar
florent committed
33
34
# provide path to library libdynamic-graph.so
LINK_DIRECTORIES(${DYNAMIC_GRAPH_LIBRARY_DIRS})
florent's avatar
florent committed
35
ADD_DEFINITIONS(${DYNAMIC_GRAPH_CFLAGS})
florent's avatar
florent committed
36

37
INCLUDE(../cmake/python.cmake)
38
39
40
41
42
43
44
45
46
47
#
#
#  Python interpreter
#
#
SET(LIBRARY_NAME ${PROJECT_NAME})
ADD_LIBRARY(${LIBRARY_NAME}
  SHARED
  interpreter.cc)

48
49
50
TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
  ${Boost_LIBRARIES}
  ${PYTHON_LIBRARY})
51
52
53
54
55
56
57
58
59
SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} dynamic-graph)

INSTALL(TARGETS ${LIBRARY_NAME}
  DESTINATION lib)

SET(EXECUTABLE_NAME dg-python)
ADD_EXECUTABLE(${EXECUTABLE_NAME} dg-python.cc)
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME}
60
  ${LIBRARY_NAME} ${Boost_LIBRARIES}
61
  )
62
63
INSTALL(TARGETS dg-python DESTINATION bin)

florent's avatar
florent committed
64
65
66
67
68
69
70
71
72
73
#
#
#  Python bindings
#
#

SET(PYTHON_MODULE wrap)

ADD_LIBRARY(${PYTHON_MODULE}
	MODULE
Nicolas Mansard's avatar
IVIGIT.    
Nicolas Mansard committed
74
	exception-python.cc
75
	convert-dg-to-py.cc
76
77
78
	dynamic-graph-py.cc
	signal-base-py.cc
	entity-py.cc
florent's avatar
florent committed
79
	factory-py.cc
80
	pool-py.cc
81
	signal-caster-py.cc
82
)
florent's avatar
florent committed
83
84
85
86
87

# Remove prefix lib
SET_TARGET_PROPERTIES(${PYTHON_MODULE}
	PROPERTIES PREFIX "")

88
TARGET_LINK_LIBRARIES(${PYTHON_MODULE} ${DYNAMIC_GRAPH_LIBRARIES})
florent's avatar
florent committed
89

90
91
92
CONFIG_FILES(link-to-python.hh)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}
  ${CMAKE_CURRENT_BINARY_DIR})
florent's avatar
florent committed
93
94
95
96
97

#
# Installation
#

98
99
100
EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS
    "-c \"import sys, os; print os.sep.join(['lib', 'python' + sys.version[:3], 'site-packages'])\""
    OUTPUT_VARIABLE PYTHON_SITELIB)
florent's avatar
florent committed
101
102
103
104
105
106
107
108
109
110

MESSAGE(STATUS "PYTHON_SITELIB=${PYTHON_SITELIB}")

SET(PYTHON_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/dynamic_graph)

INSTALL(TARGETS ${PYTHON_MODULE}
	       DESTINATION
	       ${PYTHON_INSTALL_DIR})

SET (PYTHON_SOURCES
111
112
113
114
115
116
117
118
    __init__.py
    attrpath.py
    entity.py
    signal_base.py
    matlab.py
    script_shortcuts.py
    tools.py
)	
florent's avatar
florent committed
119
120

FOREACH (SOURCE ${PYTHON_SOURCES})
121
  PYTHON_INSTALL_ON_SITE(dynamic_graph ${SOURCE} )
florent's avatar
florent committed
122
123
ENDFOREACH (SOURCE)

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143


# --- ADD the wrap on the dg modules
EXEC_PROGRAM("${PKG_CONFIG_EXECUTABLE}"
             ARGS "--variable=plugindir" "dynamic-graph"
             OUTPUT_VARIABLE "DYNAMIC_GRAPH_PLUGIN_DIR")

# Tracer plugin
ADD_DEPENDENCIES(${LIBRARY_NAME} MKDIR_tracer)
ADD_CUSTOM_TARGET(MKDIR_tracer mkdir -p ../lib/dynamic_graph/tracer)
SET(TRACER_PLUGIN ${DYNAMIC_GRAPH_PLUGIN_DIR}/tracer.so)
DYNAMIC_GRAPH_PYTHON_MODULE("tracer" ${TRACER_PLUGIN} tracer/wrap)

# TracerRealTime plugin
ADD_DEPENDENCIES(${LIBRARY_NAME} MKDIR_TracerRealTime)
ADD_CUSTOM_TARGET(MKDIR_TracerRealTime mkdir -p ../lib/dynamic_graph/tracer_real_time)
SET(TRACERREALTIME_PLUGIN ${DYNAMIC_GRAPH_PLUGIN_DIR}/tracer-real-time.so)
DYNAMIC_GRAPH_PYTHON_MODULE("tracer_real_time" ${TRACERREALTIME_PLUGIN} tracer_real_time/wrap)