]> SALOME platform Git repositories - modules/kernel.git/blob - salome_adm/cmake_files/FindOmniORB.cmake
Salome HOME
CMake: Edition accumulation of LD_LIBRARY_PATH and PATH
[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_PYTHONPATH   - path to the OmniORB Python modules 
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 IF(WIN32)
46   # Guide the FIND_LIBRARY command towards the correct directory <...>/lib/x86_win32:
47   SET(CMAKE_LIBRARY_ARCHITECTURE x86_win32)
48 ENDIF()
49
50 ##############################################################################
51 # find headers
52 ##############################################################################
53 FIND_PATH(OMNIORB_INCLUDE_DIR omniORB4/CORBA.h)
54
55 ##############################################################################
56 # find libraries
57 ##############################################################################
58
59 # Win release / debug specific stuff:
60 IF (WIN32)
61   IF(CMAKE_BUILD_TYPE STREQUAL Debug)
62     SET(OMNIORB_RD_SUFFIX d)
63   ELSE()
64     SET(OMNIORB_RD_SUFFIX)
65   ENDIF()
66 ENDIF()
67
68 IF (WIN32)
69   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 
70     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
71   FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
72     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
73   FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
74     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
75 ELSE (WIN32)
76   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 NAMES omniORB4)
77   FIND_LIBRARY(OMNIORB_LIBRARY_omnithread NAMES omnithread)
78   FIND_LIBRARY(OMNIORB_LIBRARY_omniDynamic4 NAMES omniDynamic4)
79 ENDIF (WIN32)   
80   
81 # Optional libraries
82
83 IF (WIN32)
84   FIND_LIBRARY( OMNIORB_LIBRARY_COS4
85     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COS4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
86   FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
87     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) 
88 ELSE (WIN32)
89   FIND_LIBRARY(OMNIORB_LIBRARY_COS4 NAMES COS4)
90   FIND_LIBRARY(OMNIORB_LIBRARY_COSDynamic4 NAMES COSDynamic4)
91 ENDIF (WIN32)
92
93 ##############################################################################
94 # find command line tools
95 ##############################################################################
96 IF (WIN32)
97   FIND_PROGRAM( OMNIORB_IDL_COMPILER
98     NAMES omniidl 
99     PATH_SUFFIXES x86_win32
100     DOC "What is the path where omniidl (the idl compiler) can be found")
101   FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
102     NAMES omniNames 
103     PATH_SUFFIXES x86_win32
104   DOC "What is the path where omniNames (the ORB server) can be found")
105 ELSE(WIN32)
106   FIND_PROGRAM(OMNIORB_IDL_COMPILER NAMES omniidl)
107   FIND_PROGRAM(OMNIORB_NAMESERVER NAMES omniNames)
108 ENDIF (WIN32)
109
110 ##############################################################################
111 # Cook our stuff
112 ##############################################################################
113
114 MARK_AS_ADVANCED(OMNIORB_DIR OMNIORB_INCLUDE_DIR)
115 MARK_AS_ADVANCED(OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread OMNIORB_LIBRARY_omniDynamic4)
116 MARK_AS_ADVANCED(OMNIORB_IDL_COMPILER OMNIORB_NAMESERVER OMNIORB_VERSION)
117 MARK_AS_ADVANCED(OMNIORB_LIBRARY_COS4 OMNIORB_LIBRARY_COSDynamic4)
118
119 SET(OMNIORB_LIBRARIES
120     ${OMNIORB_LIBRARY_omniORB4}
121     ${OMNIORB_LIBRARY_omnithread}
122     ${OMNIORB_LIBRARY_omniDynamic4})
123
124 IF(OMNIORB_LIBRARY_COS4)
125     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COS4})
126 ENDIF()
127 IF(OMNIORB_LIBRARY_COSDynamic4)
128     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COSDynamic4})
129 ENDIF()
130
131 # Set path to the OmniORB Python modules
132 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${OMNIORB_LIBRARIES}" PATH) 
133 SET(OMNIORB_PYTHONPATH "${_tmp_ROOT_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
134
135 # Optionaly, extract the the version number from the acconfig.h file:
136 # The version check is done at the very bottom of this file.
137 IF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
138     FILE( READ ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h OMNIORB_ACCONFIG_H )
139     STRING( REGEX MATCH "#define[\t ]+PACKAGE_VERSION[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" OMNIORB_ACCONFIG_H "${OMNIORB_ACCONFIG_H}" )
140     STRING( REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" OMNIORB_VERSION "${OMNIORB_ACCONFIG_H}" )
141 ELSE()
142     SET( OMNIORB_VERSION "NOT-FOUND" )
143 ENDIF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
144   
145 SET(OMNIORB_IDLCXXFLAGS -bcxx -Wba -nf)
146 SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS})
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   ## OmniORB isn`t defines SIZEOF_LONG and SIZEOF_INT on WIN32 platform
152   ## Note SIZE_OF_LONG calculates in the SalomeSetupPlatform.cmake 
153   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__ -DSIZEOF_INT=4 -DSIZEOF_LONG=${SIZE_OF_LONG}")
154 ENDIF()
155 IF(APPLE)
156   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
157 ENDIF()
158
159 # Handle standard arguments:
160 INCLUDE(FindPackageHandleStandardArgs)
161 IF(OMNIORB_VERSION)
162   FIND_PACKAGE_HANDLE_STANDARD_ARGS(OmniORB  
163         REQUIRED_VARS OMNIORB_INCLUDE_DIR OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread 
164                       OMNIORB_LIBRARY_omniDynamic4 OMNIORB_IDL_COMPILER 
165         VERSION_VAR OMNIORB_VERSION )
166 ELSE()
167   FIND_PACKAGE_HANDLE_STANDARD_ARGS(OmniORB  
168         REQUIRED_VARS OMNIORB_INCLUDE_DIR OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread 
169                       OMNIORB_LIBRARY_omniDynamic4 OMNIORB_IDL_COMPILER)
170 ENDIF()