Salome HOME
Refactoring of the preprocessor definitions:
[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
58 # Win release / debug specific stuff:
59 IF (WIN32)
60   IF(CMAKE_BUILD_TYPE STREQUAL Debug)
61     SET(OMNIORB_RD_SUFFIX d)
62   ELSE()
63     SET(OMNIORB_RD_SUFFIX)
64   ENDIF()
65 ENDIF()
66
67 IF (WIN32)
68   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 
69     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniORB4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
70   FIND_LIBRARY( OMNIORB_LIBRARY_omnithread
71     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omnithread_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
72   FIND_LIBRARY( OMNIORB_LIBRARY_omniDynamic4
73     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}omniDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
74 ELSE (WIN32)
75   FIND_LIBRARY(OMNIORB_LIBRARY_omniORB4 NAMES omniORB4)
76   FIND_LIBRARY(OMNIORB_LIBRARY_omnithread NAMES omnithread)
77   FIND_LIBRARY(OMNIORB_LIBRARY_omniDynamic4 NAMES omniDynamic4)
78 ENDIF (WIN32)   
79   
80 # Optional libraries
81
82 IF (WIN32)
83   FIND_LIBRARY( OMNIORB_LIBRARY_COS4
84     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COS4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
85   FIND_LIBRARY( OMNIORB_LIBRARY_COSDynamic4
86     NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}COSDynamic4_rt${OMNIORB_RD_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}) 
87 ELSE (WIN32)
88   FIND_LIBRARY(OMNIORB_LIBRARY_COS4 NAMES COS4)
89   FIND_LIBRARY(OMNIORB_LIBRARY_COSDynamic4 NAMES COSDynamic4)
90 ENDIF (WIN32)
91
92 ##############################################################################
93 # find command line tools
94 ##############################################################################
95 IF (WIN32)
96   FIND_PROGRAM( OMNIORB_IDL_COMPILER
97     NAMES omniidl PATHS bin/x86_win32
98     DOC "What is the path where omniidl (the idl compiler) can be found")
99   FIND_PROGRAM( OMNIORB_OMNINAMES_COMMAND
100     NAMES omniNames PATHS bin/x86_win32 
101   DOC "What is the path where omniNames (the ORB server) can be found")
102 ELSE(WIN32)
103   FIND_PROGRAM(OMNIORB_IDL_COMPILER NAMES omniidl)
104   FIND_PROGRAM(OMNIORB_NAMESERVER NAMES omniNames)
105 ENDIF (WIN32)
106
107 ##############################################################################
108 # Cook our stuff
109 ##############################################################################
110
111 MARK_AS_ADVANCED(OMNIORB_DIR OMNIORB_INCLUDE_DIR)
112 MARK_AS_ADVANCED(OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread OMNIORB_LIBRARY_omniDynamic4)
113 MARK_AS_ADVANCED(OMNIORB_IDL_COMPILER OMNIORB_NAMESERVER OMNIORB_VERSION)
114 MARK_AS_ADVANCED(OMNIORB_LIBRARY_COS4 OMNIORB_LIBRARY_COSDynamic4)
115
116 SET(OMNIORB_LIBRARIES
117     ${OMNIORB_LIBRARY_omniORB4}
118     ${OMNIORB_LIBRARY_omnithread}
119     ${OMNIORB_LIBRARY_omniDynamic4})
120
121 IF(OMNIORB_LIBRARY_COS4)
122     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COS4})
123 ENDIF()
124 IF(OMNIORB_LIBRARY_COSDynamic4)
125     LIST(APPEND OMNIORB_LIBRARIES ${OMNIORB_LIBRARY_COSDynamic4})
126 ENDIF()
127
128 # Optionaly, extract the the version number from the acconfig.h file:
129 # The version check is done at the very bottom of this file.
130 IF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
131     FILE( READ ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h OMNIORB_ACCONFIG_H )
132     STRING( REGEX MATCH "#define[\t ]+PACKAGE_VERSION[\t ]+\"([0-9]+.[0-9]+.[0-9]+)\"" OMNIORB_ACCONFIG_H "${OMNIORB_ACCONFIG_H}" )
133     STRING( REGEX REPLACE ".*\"([0-9]+.[0-9]+.[0-9]+)\".*" "\\1" OMNIORB_VERSION "${OMNIORB_ACCONFIG_H}" )
134 ELSE()
135     SET( OMNIORB_VERSION "NOT-FOUND" )
136 ENDIF( EXISTS ${OMNIORB_INCLUDE_DIR}/omniORB4/acconfig.h )
137   
138 SET(OMNIORB_IDLCXXFLAGS -bcxx -Wba -nf)
139 SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS})
140 SET(IDL_CLN_H .hh)
141 SET(IDL_SRV_H .hh)
142 SET(OMNIORB_DEFINITIONS "-D__x86__ -DCOMP_CORBA_DOUBLE -DCOMP_CORBA_LONG")
143 IF(WIN32)
144   ## OmniORB isn`t defines SIZEOF_LONG and SIZEOF_INT on WIN32 platform
145   ## Note SIZE_OF_LONG calculates in the SalomeSetupPlatform.cmake 
146   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__WIN32__ -DSIZEOF_INT=4 -DSIZEOF_LONG=${SIZE_OF_LONG}")
147 ENDIF()
148 IF(APPLE)
149   SET(OMNIORB_DEFINITIONS "${OMNIORB_DEFINITIONS} -D__macos__")#for omnithread.h to be checked...
150 ENDIF()
151
152 # Handle standard arguments:
153 INCLUDE(FindPackageHandleStandardArgs)
154 IF(OMNIORB_VERSION)
155   FIND_PACKAGE_HANDLE_STANDARD_ARGS(OmniORB  
156         REQUIRED_VARS OMNIORB_INCLUDE_DIR OMNIORB_LIBRARY_omniORB4 OMNIORB_LIBRARY_omnithread 
157                       OMNIORB_LIBRARY_omniDynamic4 OMNIORB_IDL_COMPILER 
158         VERSION_VAR OMNIORB_VERSION )
159 ELSE()
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)
163 ENDIF()