File: FindOpenRTM.cmake

package info (click to toggle)
roboptim-core 2.0-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,488 kB
  • ctags: 1,160
  • sloc: cpp: 5,388; sh: 395; ansic: 387; makefile: 25; python: 19
file content (171 lines) | stat: -rw-r--r-- 5,637 bytes parent folder | download
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
166
167
168
169
170
171

# @author Shin'ichiro Nakaoka

set(OPENRTM_FOUND FALSE)
set(OPENRTM_VERSION042 "0.4.2")
set(OPENRTM_VERSION100 "1.0.0")
set(OPENRTM_PKG_CONFIG_FOUND FALSE)
#Additional threshold OpenRTM versions switching processing 
set(OPENRTM_DEFAULT_VERSION ${OPENRTM_VERSION100})

if(UNIX)
  if(OPENRTM_DIR)
    string(REGEX REPLACE "/$" "" OPENRTM_DIR ${OPENRTM_DIR})
    set(OPENRTM_CONFIG_EXECUTABLE ${OPENRTM_DIR}/bin/rtm-config)
    if(NOT EXISTS ${OPENRTM_CONFIG_EXECUTABLE})
      set(OPENRTM_CONFIG_EXECUTABLE)
      message(FATAL_ERROR "rtm-config was not found in ${OPENRTM_DIR}/bin. Please set OPENRTM_DIR correctly.")
    endif()
  else()
    find_program(OPENRTM_CONFIG_EXECUTABLE rtm-config DOC "The location of the rtm-config script")
    mark_as_advanced(OPENRTM_CONFIG_EXECUTABLE)  
  endif()

  if(OPENRTM_CONFIG_EXECUTABLE)
    set(OPENRTM_FOUND TRUE)

    execute_process(
      COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --version
      OUTPUT_VARIABLE OPENRTM_VERSION
      RESULT_VARIABLE RESULT
      OUTPUT_STRIP_TRAILING_WHITESPACE)

    if(NOT RESULT EQUAL 0)
      set(OPENRTM_FOUND FALSE)
    endif()

    execute_process(
      COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --prefix
      OUTPUT_VARIABLE OPENRTM_DIR
      RESULT_VARIABLE RESULT
      OUTPUT_STRIP_TRAILING_WHITESPACE)

    if(RESULT EQUAL 0)
      if(OPENRTM_DIR)
        list(APPEND OPENRTM_INCLUDE_DIRS "${OPENRTM_DIR}/include")
        list(APPEND OPENRTM_INCLUDE_DIRS "${OPENRTM_DIR}/include/rtm/idl")
      endif()
    else()
      set(OPENRTM_FOUND FALSE)
    endif()

    execute_process(
      COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --cflags
      OUTPUT_VARIABLE OPENRTM_CXX_FLAGS
      RESULT_VARIABLE RESULT)

    if(RESULT EQUAL 0)
      string(REGEX MATCHALL "-D.*[^ ;]+" OPENRTM_DEFINITIONS ${OPENRTM_CXX_FLAGS})
    else()
      set(OPENRTM_FOUND FALSE)
    endif()

    execute_process(
      COMMAND ${OPENRTM_CONFIG_EXECUTABLE} --libs
      OUTPUT_VARIABLE OPENRTM_LIBRARIES
      RESULT_VARIABLE RESULT
      OUTPUT_STRIP_TRAILING_WHITESPACE)

    if(RESULT EQUAL 0)
      string(REGEX MATCHALL "-L[^ ;]+" OPENRTM_LIBRARY_DIRS ${OPENRTM_LIBRARIES})
      string(REGEX REPLACE "-L" ";" OPENRTM_LIBRARY_DIRS ${OPENRTM_LIBRARY_DIRS})
      string(REGEX REPLACE "-L[^ ;]+" "" OPENRTM_LIBRARIES ${OPENRTM_LIBRARIES})
      separate_arguments(OPENRTM_LIBRARIES)
    else()
      set(OPENRTM_FOUND FALSE)
    endif()

  endif(OPENRTM_CONFIG_EXECUTABLE)
  set(OPENRTM_PKG_CONFIG_FILE "/usr/lib/pkgconfig/openrtm-aist.pc")
  if(EXISTS ${OPENRTM_PKG_CONFIG_FILE})
    set(OPENRTM_PKG_CONFIG_FOUND TRUE)
  endif()
endif(UNIX)

if(WIN32)
  set(OPENRTM_DEFINITIONS -DUSE_stub_in_nt_dll )
  if( NOT OPENRTM_DIR )
    if(NOT $ENV{RTM_ROOT} STREQUAL "")
      set(OPENRTM_DIR $ENV{RTM_ROOT})
    endif()
  endif()
  if(OPENRTM_DIR )
    if( ${OPENRTM_DIR} MATCHES ".*\\\\0\\.4\\\\$" )
      set(OPENRTM_DEFAULT_VERSION ${OPENRTM_VERSION042})
    elseif(${OPENRTM_DIR} MATCHES ".*\\/0\\.4$")
      set(OPENRTM_DEFAULT_VERSION ${OPENRTM_VERSION042})
    else()
      set(OPENRTM_DEFAULT_VERSION ${OPENRTM_VERSION100})
    endif()
    set(OPENRTM_VERSION ${OPENRTM_DEFAULT_VERSION} CACHE STRING "Set version of OpenRTM-aist. Default version is ${OPENRTM_DEFAULT_VERSION}")
    set(OPENRTM_INCLUDE_DIRS ${OPENRTM_DIR} )
    set(OPENRTM_LIBRARY_DIRS ${OPENRTM_DIR}/bin )
    list(APPEND OPENRTM_INCLUDE_DIRS "${OPENRTM_DIR}/rtm/idl")
    if(OPENRTM_VERSION STREQUAL ${OPENRTM_VERSION042})
      set(OPENRTM_LIBRARIES_RELEASE RTC042 ACE )
    else()
      # 1.0.0-RC
      #set(OPENRTM_LIBRARIES_RELEASE RTC100 coil)

      # 1.0.0-Release
      set(OPENRTM_LIBRARIES_RELEASE RTC100 coil)
      set(OPENRTM_NODEBUG_LIBRARIES ws2_32 mswsock)
    endif()
    foreach(library ${OPENRTM_LIBRARIES_RELEASE})
      list(APPEND OPENRTM_LIBRARIES optimized ${library} debug ${library}d )
    endforeach()
    foreach(library ${OPENRTM_NODEBUG_LIBRARIES})
      list(APPEND OPENRTM_LIBRARIES optimized ${library} debug ${library} )
    endforeach()
  endif()

  if("${OPENRTM_VERSION}" STREQUAL ${OPENRTM_VERSION042})
    if(NOT ACE_ROOT)
      if(NOT $ENV{ACE_ROOT} STREQUAL "")
        set(ACE_ROOT $ENV{ACE_ROOT})
      endif()
      set(ACE_ROOT ${ACE_ROOT} CACHE PATH "The top directory of ACE")
    endif()
    if(ACE_ROOT)
      include_directories(${ACE_ROOT})
      link_directories(${ACE_ROOT}/lib)
    endif()
    if(OPENRTM_DIR AND ACE_ROOT)
      set(OPENRTM_FOUND TRUE)
    endif()
  else()
    if(OPENRTM_DIR)
       set(OPENRTM_FOUND TRUE)
    endif()
  endif()
endif(WIN32)

if(NOT OPENRTM_FOUND)
  set(OPENRTM_DIR NOT_FOUND)
endif()

set(OPENRTM_DIR ${OPENRTM_DIR} CACHE PATH "The top directory of OpenRTM-aist")

if(OPENRTM_FOUND)
  if( ${OPENRTM_VERSION} MATCHES "^0\\." )
      message(FATAL_ERROR "Not support OpenRTM-aist Ver.${OPENRTM_VERSION}, please install OpenRTM-aist Ver.1.0.0 or later and specify it's location.")
  endif()

  if(NOT OpenRTM_FIND_QUIETLY)
    message(STATUS "Found OpenRTM-aist ${OPENRTM_VERSION} in ${OPENRTM_DIR}")
  endif()
  if(OPENRTM_PKG_CONFIG_FOUND)
    message(STATUS "OpenRTM is supported pkg-config.")
  else()
    message(STATUS "OpenRTM is not supported pkg-config.")
    if(WIN32)
      list(APPEND OPENRTM_LIBRARIES ${OMNIORB_LIBRARIES})
    endif(WIN32)
  endif()
else()
  if(NOT OpenRTM_FIND_QUIETLY)
    if(OpenRTM_FIND_REQUIRED)
      message(FATAL_ERROR "OpenRTM-aist required, please specify it's location.")
    endif()
  endif()
endif()