forked from davidhodo/pymoos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
108 lines (86 loc) · 3.72 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
103
104
105
106
107
108
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
FIND_PACKAGE(Boost)
IF(NOT Boost_FOUND)
MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?")
ENDIF()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/config/)
find_package(Python32Interp REQUIRED)
find_package(Python32Libs REQUIRED)
IF(NOT PYTHON3LIBS_FOUND)
MESSAGE(FATAL_ERROR "Failed to find the python libraries")
ENDIF()
# determine directory to install python files in
EXECUTE_PROCESS(COMMAND
${PYTHON3_EXECUTABLE} -c "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_lib(0,0,\"\"))"
OUTPUT_VARIABLE PYTHON_INSTALL
ERROR_VARIABLE PYTHON_STDERR
RESULT_VARIABLE PYTHON_ERR
)
SET(PYTHON_INSTDIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL})
MESSAGE(STATUS "Python files and libraries will be installed in ${PYTHON_INSTDIR}")
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib )
set( CMAKE_SHARED_LIBRARY_SUFFIX ".so" )
IF(WIN32)
ADD_DEFINITIONS(-DWINDOWS_NT -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
IF(UNIX)
ADD_DEFINITIONS(-DUNIX)
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
ADD_DEFINITIONS( -DPLATFORM_DARWIN )
#some support for macport installed libraries
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
MESSAGE(STATUS "Cmake library path ${CMAKE_LIBRARY_PATH}")
SET( PLATFORM_DARWIN 1 )
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
ADD_DEFINITIONS( -DPLATFORM_LINUX )
SET( PLATFORM_LINUX 1 )
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
ENDIF(UNIX)
INCLUDE_DIRECTORIES(
${Boost_INCLUDE_DIRS}
${PYTHON3_INCLUDE_DIRS}
"../")
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
IF (NOT BOOST_PYTHON3_LIBRARY)
find_library(BOOST_PYTHON3_LIBRARY boost_python-py32)
ENDIF()
FIND_PACKAGE(MOOS)
INCLUDE_DIRECTORIES( ${MOOS_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${MOOS_LIBRARY_DIRS} )
ADD_LIBRARY(CMOOSMsg SHARED src/pyMOOSMsg.cpp )
TARGET_LINK_LIBRARIES(CMOOSMsg ${BOOST_PYTHON3_LIBRARY} ${MOOS_LIBRARIES} ${PYTHON3_LIBRARIES})
SET_TARGET_PROPERTIES(CMOOSMsg PROPERTIES PREFIX "") # remove 'lib' prefix
ADD_LIBRARY(XPCTcpSocket SHARED src/pyXPCTcpSocket.cpp)
TARGET_LINK_LIBRARIES(XPCTcpSocket ${BOOST_PYTHON3_LIBRARY} ${MOOS_LIBRARIES} ${PYTHON3_LIBRARIES})
SET_TARGET_PROPERTIES(XPCTcpSocket PROPERTIES PREFIX "")
ADD_LIBRARY(CMOOSCommPkt SHARED src/pyMOOSCommPkt.cpp ${CMOOSMsg_SRC} )
TARGET_LINK_LIBRARIES(CMOOSCommPkt ${BOOST_PYTHON3_LIBRARY} ${MOOS_LIBRARIES} ${PYTHON3_LIBRARIES})
SET_TARGET_PROPERTIES(CMOOSCommPkt PROPERTIES PREFIX "")
SET(CMOOSCommObject_SRC
src/pyMOOSCommObject.cpp
src/pyMOOSCommPkt.cpp
)
ADD_LIBRARY(CMOOSCommObject SHARED ${CMOOSCommObject_SRC} )
TARGET_LINK_LIBRARIES(CMOOSCommObject ${BOOST_PYTHON3_LIBRARY} ${MOOS_LIBRARIES} ${PYTHON3_LIBRARIES})
SET_TARGET_PROPERTIES(CMOOSCommObject PROPERTIES PREFIX "")
file(COPY python/MOOSCommClient.py DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
INSTALL(FILES python/MOOSCommClient.py
python/__init__.py
${CMAKE_BINARY_DIR}/lib/CMOOSCommObject.so
${CMAKE_BINARY_DIR}/lib/CMOOSCommPkt.so
${CMAKE_BINARY_DIR}/lib/CMOOSMsg.so
${CMAKE_BINARY_DIR}/lib/XPCTcpSocket.so
DESTINATION ${PYTHON_INSTDIR}/pymoos/
)