forked from OpenRTM/choreonoid-openrtm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
165 lines (137 loc) · 5.01 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
set(IS_MASTER_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(IS_MASTER_PROJECT ON)
endif()
if(NOT IS_MASTER_PROJECT)
option(BUILD_OPENRTM_PLUGIN "Building OpenRTMPlugin" OFF)
if(NOT BUILD_OPENRTM_PLUGIN)
return()
elseif(NOT (ENABLE_CORBA AND BUILD_CORBA_PLUGIN))
message(FATAL_ERROR "The OpenRTM plugin needs to ENABLE_CORBA and BUILD_CORBA_PLUGIN")
endif()
else()
cmake_minimum_required(VERSION 3.5.0)
project(ChoreonoidOpenRTM)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
if(NOT Choreonoid_FOUND)
file(GLOB choreonoid_search_path
"c:/choreonoid*/share/choreonoid/cmake"
"c:/choreonoid*/*/share/choreonoid/cmake")
endif()
if(choreonoid_search_path)
find_package(Choreonoid REQUIRED HINTS ${choreonoid_search_path})
else()
find_package(Choreonoid REQUIRED)
endif()
if(NOT CHOREONOID_ENABLE_CORBA)
message(FATAL_ERROR "CORBA is not available in Choreonoid")
endif()
if(CHOREONOID_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CHOREONOID_CXX_STANDARD})
set(CMAKE_CXX_EXTENSIONS OFF)
else()
add_compile_options(-std=c++14)
endif()
if(MSVC)
if(${MSVC_VERSION} GREATER_EQUAL 1910)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
endif()
endif()
option(INSTALL_SDK "Installing SDK files" ON)
set(CHOREONOID_INSTALL_SDK ${INSTALL_SDK})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(${CHOREONOID_INCLUDE_DIRS})
link_directories(${CHOREONOID_LIBRARY_DIRS})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${CHOREONOID_COMPILE_DEFINITIONS})
endif()
option(CHOREONOID_PLUGIN_LINK_USE_KEYWORD "Choreonoid plugin should use the PUBLIC link keyword" ON)
find_package(OpenRTM REQUIRED CONFIG)
# Check version
if(NOT OPENRTM_VERSION VERSION_LESS "1.2.0")
list(APPEND OPENRTM_DEFINITIONS -DOPENRTM_VERSION12)
if(UNIX)
list(APPEND OPENRTM_DEFINITIONS -Wno-deprecated)
endif()
elseif(OPENRTM_VERSION VERSION_EQUAL "1.1.2")
list(APPEND OPENRTM_DEFINITIONS -DOPENRTM_VERSION11)
# Remove extra "-I" from the elements of OPENRTM_INCLUDE_DIRS
unset(include_dirs)
foreach(dir ${OPENRTM_INCLUDE_DIRS})
string(REGEX REPLACE "^-I" "" stripped ${dir})
list(APPEND include_dirs ${stripped})
endforeach()
set(OPENRTM_INCLUDE_DIRS ${include_dirs})
# Remove extra "-L" from the elements of OPENRTM_LIBRARY_DIRS
unset(library_dirs)
foreach(dir ${OPENRTM_LIBRARY_DIRS})
string(REGEX REPLACE "^-L" "" stripped ${dir})
list(APPEND library_dirs ${stripped})
endforeach()
set(OPENRTM_LIBRARY_DIRS ${library_dirs})
else()
message(FATAL_ERROR "OpenRTM version is INVALID.")
endif()
add_definitions(${OPENRTM_DEFINITIONS})
include_directories(${OPENRTM_INCLUDE_DIRS})
link_directories(${OPENRTM_LIBRARY_DIRS})
if(MSVC)
add_compile_options(${OPENRTM_CFLAGS})
endif()
set(IDL_INCLUDE_DIRS ${IDL_INCLUDE_DIRS} ${OPENRTM_INCLUDE_DIRS})
option(USE_BUILTIN_CAMERA_IMAGE_IDL "Enable this option when you run hrpsys-base on Choreonoid" OFF)
if(USE_BUILTIN_CAMERA_IMAGE_IDL)
list(APPEND OPENRTM_DEFINITIONS -DUSE_BUILTIN_CAMERA_IMAGE_IDL)
else()
if(MSVC)
unset(camera_library)
foreach(dir ${OPENRTM_LIBRARY_DIRS})
file(GLOB libs "${dir}/rtmCamera*vc*.lib")
foreach(lib ${libs})
if(lib MATCHES "(rtmCamera.*d)\\.lib$")
list(APPEND camera_library debug;${CMAKE_MATCH_1})
elseif(lib MATCHES "(rtmCamera.*)\\.lib$")
list(APPEND camera_library optimized;${CMAKE_MATCH_1})
endif()
endforeach()
endforeach()
set(OPENRTM_CAMERA_LIBRARY ${camera_library})
else()
set(OPENRTM_CAMERA_LIBRARY rtmCamera)
endif()
endif()
if(IS_MASTER_PROJECT)
if(MSVC)
set(USE_BUNDLED_LIBJPEG_DEFAULT ON)
else()
set(USE_BUNDLED_LIBJPEG_DEFAULT OFF)
endif()
option(USE_BUNDLED_LIBJPEG "Use the JPEG library bunded with Choreonoid" ${USE_BUNDLED_LIBJPEG_DEFAULT})
if(NOT USE_BUNDLED_LIBJPEG)
find_package(JPEG)
endif()
if(NOT JPEG_FOUND)
set(JPEG_LIBRARY jpeg)
endif()
endif()
set(OPENRTM_CAMERA_LIBRARY ${OPENRTM_CAMERA_LIBRARY} ${JPEG_LIBRARY})
if(MSVC)
file(GLOB rtcdlls "${OPENRTM_BIN_PATH}/RTC*vc*.dll")
file(GLOB rtmcameradlls "${OPENRTM_BIN_PATH}/rtmCamera*vc*.dll")
file(GLOB rtmmanipulatordlls "${OPENRTM_BIN_PATH}/rtmManipulator*vc*.dll")
install(PROGRAMS ${rtcdlls} ${rtmcameradlls} ${rtmmanipulatordlls} DESTINATION ${CHOREONOID_BIN_SUBDIR} COMPONENT openrtmlib)
endif()
if(NOT IS_MASTER_PROJECT)
set(OPENRTM_DEFINITIONS ${OPENRTM_DEFINITIONS} PARENT_SCOPE)
set(OPENRTM_INCLUDE_DIRS ${OPENRTM_INCLUDE_DIRS} PARENT_SCOPE)
set(OPENRTM_LIBRARY_DIRS ${OPENRTM_LIBRARY_DIRS} PARENT_SCOPE)
set(OPENRTM_CFLAGS ${OPENRTM_CFLAGS} PARENT_SCOPE)
set(OPENRTM_CAMERA_LIBRARY ${OPENRTM_CAMERA_LIBRARY} PARENT_SCOPE)
set(IDL_INCLUDE_DIRS ${IDL_INCLUDE_DIRS} PARENT_SCOPE)
endif()
add_subdirectory(src)
add_subdirectory(sample)