Salome HOME
New CMake procedure.
[modules/kernel.git] / salome_adm / cmake_files / FindOmniORB.cmake
1 # - Find OmniORB4 cmake module and Pyhon backends
2 #
3 # Sets the following variables:
4 # OMNIORB_FOUND        - TRUE if OmniORB4 installation has been found
5 # OMNIORB_INCLUDE_DIR  - OmniORB4 headers path
6 # OMNIORB_LIBRARIES    - OmniORB4 libraries 
7 # OMNIORB_VERSION      - OmniORB4 version
8 # OMNIORB_IDL_COMPILER - OmniORB4 idl compiler command (omniidl)
9 # OMNIORB_NAMESERVER   - OmniORB4 CORBA naming service (omniNames)
10 # OMNIORB_PYTHON_BACKEND
11 # and many other mainly used in UseOmniORB.cmake  
12 #
13 # Detection is made through calls to 
14 # find_library, find_program, find_path
15 # and can be guided by extending CMAKE_PREFIX_PATH. Given the CMake precedence
16 # rule this will take precedence over the standard system paths.
17 # See for example doc of find_library().  
18 #
19
20 ################################################################
21 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
22 #
23 # This library is free software; you can redistribute it and/or
24 # modify it under the terms of the GNU Lesser General Public
25 # License as published by the Free Software Foundation; either
26 # version 2.1 of the License.
27 #
28 # This library is distributed in the hope that it will be useful,
29 # but WITHOUT ANY WARRANTY; without even the implied warranty of
30 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
31 # Lesser General Public License for more details.
32 #
33 # You should have received a copy of the GNU Lesser General Public
34 # License along with this library; if not, write to the Free Software
35 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
36 #
37 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
38 #
39 ################################################################
40
41 # minimum OmniORB4 supported version
42 # 4.0.6 has known bug float/double marshalling using CORBA::Any
43 set(OMNIORB_MINIMUM_VERSION "4.1.2")
44
45 ##############################################################################
46 # find headers
47 ##############################################################################
48 FIND_PATH(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h)
49
50 ##############################################################################
51 # find libraries
52 ##############################################################################
53 IF (WIN32)
54   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 
55     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4${CMAKE_STATIC_LIBRARY_SUFFIX}
56     PATHS lib/x86_win32)
57   FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
58     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread${CMAKE_STATIC_LIBRARY_SUFFIX}
59     PATHS lib/x86_win32)
60   FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
61     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
62     PATHS lib/x86_win32)
63 ELSE (WIN32)
64   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 NAMES omniORB4)
65   FIND_LIBRARY(OMNIORB_LIBRARY_omnithread NAMES omnithread)
66   FIND_LIBRARY(OMNIORB_LIBRARY_omniDynamic4 NAMES omniDynamic4)
67 ENDIF (WIN32)   
68   
69 # Optional libraries
70
71 IF (WIN32)
72   FIND_LIBRARY( OMNIORB_LIBRARY_COS4
73     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COS4${CMAKE_STATIC_LIBRARY_SUFFIX}
74     PATHS lib/x86_win32 )
75   FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
76     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4${CMAKE_STATIC_LIBRARY_SUFFIX}
77     PATHS lib/x86_win32) 
78 ELSE (WIN32)
79   FIND_LIBRARY(OMNIORB_LIBRARY_COS4 NAMES COS4)
80   FIND_LIBRARY(OMNIORB_LIBRARY_COSDynamic4 NAMES COSDynamic4)
81 ENDIF (WIN32)
82
83 ##############################################################################
84 # find command line tools
85 ##############################################################################
86 IF (WIN32)
87   FIND_PROGRAM( OMNIORB_IDL_COMPILER
88     NAMES omniidl PATHS bin/x86_win32
89     DOC "What is the path where omniidl (the idl compiler) can be found")
90   FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
91     NAMES omniNames PATHS bin/x86_win32 
92   DOC "What is the path where omniNames (the ORB server) can be found")
93 ELSE(WIN32)
94   FIND_PROGRAM(OMNIORB_IDL_COMPILER NAMES omniidl)
95   FIND_PROGRAM(OMNIORB_NAMESERVER NAMES omniNames)
96 ENDIF (WIN32)
97
98 ##############################################################################
99 # find python back-end
100 ##############################################################################
101
102 SET(_py_version "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
103 SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CMAKE_PREFIX_PATH})
104 FIND_PATH(OMNIORB_PYTHON_BACKEND
105   NAMES python.py
106   PATHS "/lib/python${_py_version}/site-packages/omniidl_be" "/usr/lib/omniidl/omniidl_be" 
107   DOC "Path to python-backend directory (omniidl_be) including python.py file" )
108
109 ##############################################################################
110 # Cook our stuff
111 ##############################################################################
112
113 MARK_AS_ADVANCED(OMNIORB_DIR OMNIORB_INCLUDE_DIR)
114 MARK_AS_ADVANCED(OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread OMNIORB_LIBRARY_omniDynamic4)
115 MARK_AS_ADVANCED(OMNIORB_IDL_COMPILER OMNIORB_NAMESERVER OMNIORB_VERSION)
116 MARK_AS_ADVANCED(OMNIORB_LIBRARY_COS4 OMNIORB_LIBRARY_COSDynamic4 OMNIORB_PYTHON_BACKEND)
117
118 SET(OMNIORB_LIBRARIES
119     ${OMNIORB_LIBRARY_omniORB4}
120     ${OMNIORB_LIBRARY_omnithread}
121     ${OMNIORB_LIBRARY_omniDynamic4})
122
123 IF(OMNIORB_LIBRARY_COS4)
124     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COS4})
125 ENDIF()
126 IF(OMNIORB_LIBRARY_COSDynamic4)
127     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COSDynamic4})
128 ENDIF()
129
130 # Optionaly, extract the the version number from the acconfig.h file:
131 # The version check is done at the very bottom of this file.
132 IF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
133     FILE( READ ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h OMNIORB_ACCONFIG_H )
134     STRING( REGEX MATCH "#define[\t ]+PACKAGE_VERSION[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" OMNIORB_ACCONFIG_H "${OMNIORB_ACCONFIG_H}" )
135     STRING( REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" OMNIORB_VERSION "${OMNIORB_ACCONFIG_H}" )
136 ELSE()
137     SET( OMNIORB_VERSION "NOT-FOUND" )
138 ENDIF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
139   
140 SET(OMNIORB_IDLCXXFLAGS -Wba -nf)
141 SET(OMNIORB_IDLPYFLAGS -bpython)
142 IF (OMNIORB_PYTHON_BACKEND) 
143   SET(OMNIORB_IDLPYFLAGS "-p ${OMNIORB_PYTHON_BACKEND} ${OMNIORB_IDLPYFLAGS}")
144 ENDIF()
145 SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS})
146 SET(IDLPYFLAGS ${OMNIORB_IDLPYFLAGS})
147 SET(IDL_CLN_H .hh)
148 SET(IDL_SRV_H .hh)
149 SET(OMNIORB_DEFINITIONS "-D__x86__ -DCOMP_CORBA_DOUBLE -DCOMP_CORBA_LONG")
150 IF(WIN32)
151   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__")
152 ENDIF()
153 IF(APPLE)
154   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
155 ENDIF()
156
157 # Handle standard arguments:
158 INCLUDE(FindPackageHandleStandardArgs)
159 IF(OMNIORB_VERSION)
160   FIND_PACKAGE_HANDLE_STANDARD_ARGS(OmniORB  
161         REQUIRED_VARS OMNIORB_INCLUDE_DIR OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread 
162                       OMNIORB_LIBRARY_omniDynamic4 OMNIORB_IDL_COMPILER OMNIORB_PYTHON_BACKEND
163         VERSION_VAR OMNIORB_VERSION )
164 ELSE()
165   FIND_PACKAGE_HANDLE_STANDARD_ARGS(OmniORB  
166         REQUIRED_VARS OMNIORB_INCLUDE_DIR OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread 
167                       OMNIORB_LIBRARY_omniDynamic4 OMNIORB_IDL_COMPILER OMNIORB_PYTHON_BACKEND)
168 ENDIF()