Salome HOME
Increment version to 7.2.0
[modules/kernel.git] / salome_adm / cmake_files / FindOMNIORB.cmake
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # Find OmniORB4 cmake module and Pyhon backends
21 #
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)
29 #
30 # optional variables:
31 # OMNIORB_DIR          - OmniORB4 local installation path
32 # OMNIORBPY_DIR        - OmniORBpy local installation path
33 #
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
39 #
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
45 #
46 # NOTE: this goes against cmake default behavior for Find* macros, 
47 # more on this issue: 
48 # http://www.mail-archive.com/kde-buildsystem@kde.org/msg00589.html
49 #
50
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")
55
56 ##############################################################################
57 # find headers
58 ##############################################################################
59 find_path(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h
60   PATHS "${OMNIORB_DIR}/include" "$ENV{OMNIORB_DIR}/include"
61   NO_DEFAULT_PATH)
62
63 find_path(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h)
64
65
66 ##############################################################################
67 # find libraries
68 ##############################################################################
69 if (WIN32)
70   find_library(OMNIORB_LIBRARY_omniORB4
71         NAMES
72         ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4${CMAKE_STATIC_LIBRARY_SUFFIX}
73         PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
74         NO_DEFAULT_PATH
75   )
76   find_library(OMNIORB_LIBRARY_omniORB4 NAMES
77     ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4${CMAKE_STATIC_LIBRARY_SUFFIX}
78   )
79 else (WIN32)
80   find_library(OMNIORB_LIBRARY_omniORB4
81     NAMES omniORB4
82     PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
83     NO_DEFAULT_PATH)
84
85   find_library(OMNIORB_LIBRARY_omniORB4
86     NAMES omniORB4)
87 endif (WIN32)   
88   
89 if (WIN32)
90   FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
91         NAMES
92         ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread${CMAKE_STATIC_LIBRARY_SUFFIX}
93         PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
94         NO_DEFAULT_PATH
95   )
96
97   FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
98         NAMES
99         ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread${CMAKE_STATIC_LIBRARY_SUFFIX}
100   )
101 else (WIN32)
102   find_library(OMNIORB_LIBRARY_omnithread
103     NAMES omnithread
104     PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
105     NO_DEFAULT_PATH)
106
107   find_library(OMNIORB_LIBRARY_omnithread
108     NAMES omnithread)
109 endif (WIN32)
110
111
112 if (WIN32)
113   FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
114     NAMES
115       ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
116     PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
117     NO_DEFAULT_PATH
118   )
119
120   FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
121     NAMES
122       ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
123   )
124 else (WIN32)
125   find_library(OMNIORB_LIBRARY_omniDynamic4
126     NAMES omniDynamic4
127     PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
128     NO_DEFAULT_PATH)
129
130   find_library(OMNIORB_LIBRARY_omniDynamic4
131     NAMES omniDynamic4)
132 endif (WIN32)    
133
134 # optional libraries
135
136 if (WIN32)
137   FIND_LIBRARY( OMNIORB_LIBRARY_COS4
138     NAMES
139       ${CMAKE_STATIC_LIBRARY_PREFIX}COS4${CMAKE_STATIC_LIBRARY_SUFFIX}
140     PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
141     NO_DEFAULT_PATH 
142   )
143
144   FIND_LIBRARY( OMNIORB_LIBRARY_COS4
145     NAMES
146       ${CMAKE_STATIC_LIBRARY_PREFIX}COS4${CMAKE_STATIC_LIBRARY_SUFFIX}
147   )
148 else (WIN32)
149   find_library(OMNIORB_LIBRARY_COS4
150     NAMES COS4
151     PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
152     NO_DEFAULT_PATH)
153
154   find_library(OMNIORB_LIBRARY_COS4
155     NAMES COS4)
156 endif (WIN32)
157
158 if (WIN32)
159   FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
160     NAMES
161       ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
162     PATHS ${OMNIORB_DIR}/lib/x86_win32 $ENV{OMNIORB_DIR}/lib/x86_win32
163     NO_DEFAULT_PATH
164   )
165
166   FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
167     NAMES
168       ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
169   )
170
171 else (WIN32)
172   find_library(OMNIORB_LIBRARY_COSDynamic4
173     NAMES COSDynamic4
174     PATHS "${OMNIORB_DIR}/lib${LIB_SUFFIX}" "$ENV{OMNIORB_DIR}/lib${LIB_SUFFIX}"
175     NO_DEFAULT_PATH)
176
177   find_library(OMNIORB_LIBRARY_COSDynamic4
178     NAMES COSDynamic4)
179 endif (WIN32)
180 ##############################################################################
181 # find command line tools
182 ##############################################################################
183 IF (WIN32)
184 FIND_PROGRAM( OMNIORB_IDL_COMPILER
185   NAMES omniidl
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"
188   NO_DEFAULT_PATH
189 )
190 FIND_PROGRAM( OMNIORB_IDL_COMPILER
191   NAMES omniidl
192   DOC "What is the path where omniidl (the idl compiler) can be found"
193 )
194
195 FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
196   NAMES omniNames
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"
199   NO_DEFAULT_PATH
200 )
201 FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
202   NAMES omniNames
203   DOC "What is the path where omniNames (the ORB server) can be found"
204 )
205 ELSE(WIN32)
206   find_program(OMNIORB_IDL_COMPILER
207     NAMES omniidl
208     PATHS "${OMNIORB_DIR}/bin" "$ENV{OMNIORB_DIR}/bin"
209     NO_DEFAULT_PATH)
210     
211   find_program(OMNIORB_IDL_COMPILER
212     NAMES omniidl)
213
214   find_program(OMNIORB_NAMESERVER
215     NAMES omniNames
216     PATHS "${OMNIORB_DIR}/bin" "$ENV{OMNIORB_DIR}/bin"
217     NO_DEFAULT_PATH)
218     
219   find_program(OMNIORB_NAMESERVER
220     NAMES omniNames)
221 ENDIF (WIN32)
222
223 ##############################################################################
224 # find python back-end
225 ##############################################################################
226 FIND_PATH( OMNIORB_PYTHON_BACKEND
227   NAMES python.py
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"
231   NO_DEFAULT_PATH )
232
233 FIND_PATH( OMNIORB_PYTHON_BACKEND
234   NAMES python.py
235   PATHS /usr/lib/omniidl/omniidl_be
236   DOC "Path to python-backend directory (omniidl_be) including python.py file" )
237 ##############################################################################
238 # cook our stuff
239 ##############################################################################
240 set(OMNIORB_FOUND "FALSE")
241
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)
259
260   set(OMNIORB_LIBRARIES
261     ${OMNIORB_LIBRARY_omniORB4}
262     ${OMNIORB_LIBRARY_omnithread}
263     ${OMNIORB_LIBRARY_omniDynamic4})
264
265   if(OMNIORB_LIBRARY_COS4)
266     set(OMNIORB_LIBRARIES ${OMNIORB_LIBRARIES} ${OMNIORB_LIBRARY_COS4})
267   endif()
268   if(OMNIORB_LIBRARY_COSDynamic4)
269     set(OMNIORB_LIBRARIES ${OMNIORB_LIBRARIES} ${OMNIORB_LIBRARY_COSDynamic4})
270   endif()
271
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}" )
277
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." )
280     endif()
281
282
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." )
288   
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})
296   SET(IDL_CLN_H .hh)
297   SET(IDL_SRV_H .hh)
298   SET(OMNIORB_DEFINITIONS "-D__x86__ -DCOMP_CORBA_DOUBLE -DCOMP_CORBA_LONG")
299   IF(WINDOWS)
300     SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__")
301   ENDIF(WINDOWS)
302   IF(APPLE)
303     SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
304   ENDIF(APPLE)
305
306
307 else()
308   message(FATAL_ERROR "OmniORB is required, please define OMNIORB_DIR as environment or cmake variable")
309 endif()