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