1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Find OmniORB4 cmake module and Pyhon backends
22 # sets the following variables:
23 # OMNIORB_FOUND - TRUE if OmniORB4 installation has been found
24 # OMNIORB_INCLUDE_DIR - OmniORB4 headers path
25 # OMNIORB_LIBRARIES - OmniORB4 libraries
26 # OMNIORB_VERSION - OmniORB4 version
27 # OMNIORB_IDL_COMPILER - OmniORB4 idl compiler command (omniidl)
28 # OMNIORB_NAMESERVER - OmniORB4 CORBA naming service (omniNames)
31 # OMNIORB_DIR - OmniORB4 local installation path
32 # OMNIORBPY_DIR - OmniORBpy local installation path
34 # This module could use OMNIORB_DIR environment variable if set
35 # WARNING: The precedence order is the following:
36 # 1. OMNIORB_DIR cmake variable
37 # 2. OMNIORB_DIR environment variable
38 # 3. default cmake search paths
40 # This module could use OMNIORBPY_DIR environment variable if set
41 # WARNING: The precedence order is the following:
42 # 1. OMNIORBPY_DIR cmake variable
43 # 2. OMNIORBPY_DIR environment variable
44 # 3. default cmake search paths
46 # NOTE: this goes against cmake default behavior for Find* macros,
48 # http://www.mail-archive.com/kde-buildsystem@kde.org/msg00589.html
51 # minimum OmniORB4 supported version
52 # 4.0.6 has known bug float/double marshalling using CORBA::Any
53 set(OMNIORB_MINIMUM_VERSION "4.1.2")
54 set(OMNIORB_DIR $ENV{OMNIORB_DIR} CACHE PATH "Path to OmniORB directory")
56 ##############################################################################
58 ##############################################################################
59 find_path(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h
60 PATHS "${OMNIORB_DIR}/include" "$ENV{OMNIORB_DIR}/include"
63 find_path(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h)
66 ##############################################################################
68 ##############################################################################
70 find_library(OMNIORB_LIBRARY_omniORB4
72 ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4${CMAKE_STATIC_LIBRARY_SUFFIX}
73 PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
76 find_library(OMNIORB_LIBRARY_omniORB4 NAMES
77 ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4${CMAKE_STATIC_LIBRARY_SUFFIX}
80 find_library(OMNIORB_LIBRARY_omniORB4
82 PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
85 find_library(OMNIORB_LIBRARY_omniORB4
90 FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
92 ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread${CMAKE_STATIC_LIBRARY_SUFFIX}
93 PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
97 FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
99 ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread${CMAKE_STATIC_LIBRARY_SUFFIX}
102 find_library(OMNIORB_LIBRARY_omnithread
104 PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
107 find_library(OMNIORB_LIBRARY_omnithread
113 FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
115 ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
116 PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
120 FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
122 ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
125 find_library(OMNIORB_LIBRARY_omniDynamic4
127 PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
130 find_library(OMNIORB_LIBRARY_omniDynamic4
137 FIND_LIBRARY( OMNIORB_LIBRARY_COS4
139 ${CMAKE_STATIC_LIBRARY_PREFIX}COS4${CMAKE_STATIC_LIBRARY_SUFFIX}
140 PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
144 FIND_LIBRARY( OMNIORB_LIBRARY_COS4
146 ${CMAKE_STATIC_LIBRARY_PREFIX}COS4${CMAKE_STATIC_LIBRARY_SUFFIX}
149 find_library(OMNIORB_LIBRARY_COS4
151 PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
154 find_library(OMNIORB_LIBRARY_COS4
159 FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
161 ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
162 PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
166 FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
168 ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
172 find_library(OMNIORB_LIBRARY_COSDynamic4
174 PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
177 find_library(OMNIORB_LIBRARY_COSDynamic4
180 ##############################################################################
181 # find command line tools
182 ##############################################################################
184 FIND_PROGRAM( OMNIORB_IDL_COMPILER
186 PATHS ${OMNIORB_DIR}/bin/x86_win32 $ENV{OMNIORB_DIR}/bin/x86_win32
187 DOC "What is the path where omniidl (the idl compiler) can be found"
190 FIND_PROGRAM( OMNIORB_IDL_COMPILER
192 DOC "What is the path where omniidl (the idl compiler) can be found"
195 FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
197 PATHS ${OMNIORB_DIR}/bin/x86_win32 $ENV{OMNIORB_DIR}/bin/x86_win32
198 DOC "What is the path where omniNames (the ORB server) can be found"
201 FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
203 DOC "What is the path where omniNames (the ORB server) can be found"
206 find_program(OMNIORB_IDL_COMPILER
208 PATHS "${OMNIORB_DIR}/bin" "$ENV{OMNIORB_DIR}/bin"
211 find_program(OMNIORB_IDL_COMPILER
214 find_program(OMNIORB_NAMESERVER
216 PATHS "${OMNIORB_DIR}/bin" "$ENV{OMNIORB_DIR}/bin"
219 find_program(OMNIORB_NAMESERVER
223 ##############################################################################
224 # find python back-end
225 ##############################################################################
226 FIND_PATH( OMNIORB_PYTHON_BACKEND
228 PATHS $ENV{OMNIORB_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/omniidl_be $ENV{OMNIORBPY_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/omniidl_be
229 ${OMNIORB_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/omniidl_be ${OMNIORBPY_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/omniidl_be
230 DOC "Path to python-backend directory (omniidl_be) including python.py file"
233 FIND_PATH( OMNIORB_PYTHON_BACKEND
235 PATHS /usr/lib/omniidl/omniidl_be
236 DOC "Path to python-backend directory (omniidl_be) including python.py file" )
237 ##############################################################################
239 ##############################################################################
240 set(OMNIORB_FOUND "FALSE")
242 if(OMNIORB_INCLUDE_DIR AND
243 OMNIORB_LIBRARY_omniORB4 AND
244 OMNIORB_LIBRARY_omnithread AND
245 OMNIORB_LIBRARY_omniDynamic4 AND
246 OMNIORB_IDL_COMPILER)
247 set(OMNIORB_FOUND "TRUE")
248 mark_as_advanced(OMNIORB_DIR)
249 mark_as_advanced(OMNIORB_INCLUDE_DIR)
250 mark_as_advanced(OMNIORB_LIBRARY_omniORB4)
251 mark_as_advanced(OMNIORB_LIBRARY_omnithread)
252 mark_as_advanced(OMNIORB_LIBRARY_omniDynamic4)
253 mark_as_advanced(OMNIORB_IDL_COMPILER)
254 mark_as_advanced(OMNIORB_NAMESERVER)
255 mark_as_advanced(OMNIORB_VERSION)
256 mark_as_advanced(OMNIORB_LIBRARY_COS4)
257 mark_as_advanced(OMNIORB_LIBRARY_COSDynamic4)
258 mark_as_advanced(OMNIORB_PYTHON_BACKEND)
260 set(OMNIORB_LIBRARIES
261 ${OMNIORB_LIBRARY_omniORB4}
262 ${OMNIORB_LIBRARY_omnithread}
263 ${OMNIORB_LIBRARY_omniDynamic4})
265 if(OMNIORB_LIBRARY_COS4)
266 set(OMNIORB_LIBRARIES ${OMNIORB_LIBRARIES} ${OMNIORB_LIBRARY_COS4})
268 if(OMNIORB_LIBRARY_COSDynamic4)
269 set(OMNIORB_LIBRARIES ${OMNIORB_LIBRARIES} ${OMNIORB_LIBRARY_COSDynamic4})
272 # Optionaly, extract the the version number from the acconfig.h file:
273 if( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
274 file( READ ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h OMNIORB_ACCONFIG_H )
275 string( REGEX MATCH "#define[\t ]+PACKAGE_VERSION[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" OMNIORB_ACCONFIG_H "${OMNIORB_ACCONFIG_H}" )
276 string( REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" OMNIORB_VERSION "${OMNIORB_ACCONFIG_H}" )
278 if( ${OMNIORB_VERSION} VERSION_LESS ${OMNIORB_MINIMUM_VERSION} )
279 message( "WARNING: your version of omniORB is older than the minimum required one (${OMNIORB_MINIMUM_VERSION}), using DIET with this version may result in undetermined behaviors." )
283 else( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
284 set( OMNIORB_VERSION "NOT-FOUND" )
285 endif( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
286 set( OMNIORB_VERSION ${OMNIORB_VERSION}
287 CACHE STRING "OmniORB version number." )
289 SET(OMNIORB_IDLCXXFLAGS -Wba -nf)
290 SET(OMNIORB_IDLPYFLAGS -bpython)
291 IF (OMNIORB_PYTHON_BACKEND)
292 SET(OMNIORB_IDLPYFLAGS "-p ${OMNIORB_PYTHON_BACKEND} ${OMNIORB_IDLPYFLAGS}")
293 ENDIF(OMNIORB_PYTHON_BACKEND)
294 SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS})
295 SET(IDLPYFLAGS ${OMNIORB_IDLPYFLAGS})
298 SET(OMNIORB_DEFINITIONS "-D__x86__ -DCOMP_CORBA_DOUBLE -DCOMP_CORBA_LONG")
300 SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__")
303 SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
308 message(FATAL_ERROR "OmniORB is required, please define OMNIORB_DIR as environment or cmake variable")