]> SALOME platform Git repositories - modules/geom.git/blob - CMakeLists.txt
Salome HOME
Fix compilation errors
[modules/geom.git] / CMakeLists.txt
1 # Copyright (C) 2013-2014  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, or (at your option) any later version.
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 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 INCLUDE(CMakeDependentOption)
21
22 PROJECT(SalomeGEOM C CXX)
23
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
26
27 # Versioning
28 # ===========
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
31
32 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
33 SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
34 SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
35 SET(${PROJECT_NAME_UC}_VERSION
36   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
37 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
38
39 # Find KERNEL
40 # ===========
41 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
42 IF(EXISTS ${KERNEL_ROOT_DIR})
43   LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
44   INCLUDE(SalomeMacros)
45   FIND_PACKAGE(SalomeKERNEL REQUIRED)
46   KERNEL_WITH_CORBA() #check whether KERNEL builded with CORBA
47   ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
48   INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
49 ELSE(EXISTS ${KERNEL_ROOT_DIR})
50   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
51 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
52
53 # Platform setup
54 # ==============
55 INCLUDE(SalomeSetupPlatform)   # From KERNEL
56 # Always build libraries as shared objects:
57 SET(BUILD_SHARED_LIBS TRUE)
58 # Local macros:
59 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
60
61 # User options 
62 # ============
63 OPTION(SALOME_BUILD_DOC "Generate SALOME GEOM documentation" ON)
64 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
65
66 # Advanced options:
67 OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
68 CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_OPENCV "Enable shape recognition from picture" OFF
69                        "SALOME_BUILD_GUI" OFF)
70 CMAKE_DEPENDENT_OPTION(SALOME_GEOM_BUILD_CC "Enable curve creator (experimental)" OFF
71                        "SALOME_BUILD_GUI" OFF)
72 MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV SALOME_GEOM_BUILD_CC)
73
74 # Debug options (!!! FOR DEVELOPERS ONLY !!! TO BE REMOVED LATER !!!)
75 IF(CMAKE_BUILD_TYPE MATCHES "^Debug$")
76   CMAKE_DEPENDENT_OPTION(SALOME_GEOM_DEBUG_CC "Debug curve creator" OFF
77                         "SALOME_GEOM_BUILD_CC" OFF)
78   MARK_AS_ADVANCED(SALOME_GEOM_DEBUG_CC)
79
80   IF(SALOME_GEOM_DEBUG_CC)
81     ADD_DEFINITIONS(-DDEBUG_CURVE_CREATOR)
82   ENDIF(SALOME_GEOM_DEBUG_CC)
83 ENDIF()
84
85 # Prerequisites
86 # =============
87 # Find "big" prerequisites first - they reference themselves many others
88 #   -> this can help finding the smaller prerequisites and detect conficts.
89 # In our case KERNEL has already loaded many prereq:
90
91 ##
92 ## From KERNEL:
93 ##
94
95 # Various
96 FIND_PACKAGE(SalomePython REQUIRED)
97 FIND_PACKAGE(SalomePThread REQUIRED)
98 FIND_PACKAGE(SalomeSWIG REQUIRED)
99 FIND_PACKAGE(SalomeBoost REQUIRED)
100 FIND_PACKAGE(SalomeOmniORB REQUIRED)
101 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
102 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
103 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
104
105 # Other KERNEL optionals: 
106 IF(SALOME_BUILD_TESTS)
107   ENABLE_TESTING()
108   FIND_PACKAGE(SalomeCppUnit)
109   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
110 ENDIF()
111 IF(SALOME_BUILD_DOC)
112   FIND_PACKAGE(SalomeDoxygen)
113   FIND_PACKAGE(SalomeGraphviz)
114   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
115   SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
116 ENDIF()
117
118 # Find GUI (optional)
119 IF(SALOME_BUILD_GUI)
120   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
121   IF(EXISTS ${GUI_ROOT_DIR})
122     LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
123     FIND_PACKAGE(SalomeGUI)
124     FULL_GUI(TRUE) #check whether GUI builded in full mode and with CORBA
125     ADD_DEFINITIONS(${GUI_DEFINITIONS})
126     INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
127   ELSE(EXISTS ${GUI_ROOT_DIR})
128     MESSAGE(STATUS "GUI_ROOT_DIR is not well defined, GEOM will be built without GUI!!!")
129   ENDIF(EXISTS ${GUI_ROOT_DIR})
130   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
131 ENDIF(SALOME_BUILD_GUI)
132
133 ##
134 ## Prerequisites From GUI:
135 ##
136
137 IF(SALOME_BUILD_GUI)
138
139   # Qt4
140   FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml)
141
142   # Optional prerequisites for GUI
143   IF(SALOME_USE_GLVIEWER)
144     FIND_PACKAGE(SalomeOpenGL)
145     SALOME_LOG_OPTIONAL_PACKAGE(OpenGL SALOME_USE_GLVIEWER) 
146   ENDIF() 
147 ENDIF(SALOME_BUILD_GUI)
148
149 ##
150 ## GEOM specifics
151 ##
152
153 FIND_PACKAGE(SalomeCAS REQUIRED)
154 FIND_PACKAGE(SalomeVTK 6.1 REQUIRED)
155
156 # OpenCV
157 IF(SALOME_GEOM_USE_OPENCV)
158   FIND_PACKAGE(SalomeOpenCV)
159   SALOME_LOG_OPTIONAL_PACKAGE(OpenCV SALOME_GEOM_USE_OPENCV)
160   ADD_DEFINITIONS(-DWITH_OPENCV)
161 ENDIF(SALOME_GEOM_USE_OPENCV)
162
163 # Detection summary:
164 SALOME_PACKAGE_REPORT_AND_CHECK()
165
166 # Directories
167 # (default values taken from KERNEL)
168 # ===========
169 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
170 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
171 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
172 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
173 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
174    "Install path: SALOME scripts")
175 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
176    "Install path: SALOME script data")
177 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
178    "Install path: SALOME Python scripts")
179 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
180 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
181    "Install path: SALOME Python shared modules")
182 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
183 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
184     "Install path: local SALOME CMake files") 
185 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
186   "Install path: local SALOME config files (obsolete, to be removed)")
187
188 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
189 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
190
191 # Specific to GEOM:
192 SET(SALOME_GEOM_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/geom" CACHE PATH 
193     "Install path: SALOME GEOM specific data")
194 SET(SALOME_GEOM_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/geom" CACHE PATH 
195     "Install path: SALOME GEOM scripts")
196 SET(SALOME_GEOM_INSTALL_PLUGINS share/salome/plugins/geom CACHE PATH 
197     "Install path: SALOME GEOM plugins")
198
199 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
200 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
201 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
202 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
203 MARK_AS_ADVANCED(SALOME_GEOM_INSTALL_RES_DATA SALOME_GEOM_INSTALL_RES_SCRIPTS SALOME_GEOM_INSTALL_PLUGINS)
204 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
205
206 # Accumulate environment variables for GEOM module
207 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
208                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
209                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
210 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
211
212 # Sources 
213 # ========
214 ADD_SUBDIRECTORY(idl)
215
216 ADD_SUBDIRECTORY(adm_local)
217 ADD_SUBDIRECTORY(resources)
218 ADD_SUBDIRECTORY(bin)
219 ADD_SUBDIRECTORY(src)
220 IF(SALOME_BUILD_DOC)
221   ADD_SUBDIRECTORY(doc)
222 ENDIF()
223
224 # Header configuration
225 # ====================
226 SALOME_XVERSION(${PROJECT_NAME})
227 SALOME_CONFIGURE_FILE(GEOM_version.h.in GEOM_version.h INSTALL ${SALOME_INSTALL_HEADERS})
228
229 # Configuration export
230 # (here only the level 1 prerequisites are exposed)
231 # ====================
232 INCLUDE(CMakePackageConfigHelpers)
233
234 # List of targets in this project we want to make visible to the rest of the world.
235 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
236 SET(_${PROJECT_NAME}_exposed_targets 
237   GEOMArchimede BlockFix GEOMbasic GEOMAlgo GEOMClient GEOMImpl
238   GEOMUtils GEOMEngine GEOM_SupervEngine GEOMSketcher
239   SalomeIDLGEOM SalomeIDLGEOMSuperv SalomeIDLAdvancedGEOM ShHealOper XAO AdvancedEngine OCC2VTK
240   SalomeIDLSTLPlugin SalomeIDLBREPPlugin SalomeIDLSTEPPlugin SalomeIDLIGESPlugin SalomeIDLXAOPlugin SalomeIDLVTKPlugin
241   STLPluginEngine BREPPluginEngine STEPPluginEngine IGESPluginEngine XAOPluginEngine VTKPluginEngine
242 )
243 IF(SALOME_BUILD_GUI)
244   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
245     AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef EntityGUI GEOMBase
246     GEOMFiltersSelection GEOM GEOMToolsGUI GenerationGUI GroupGUI Material MeasureGUI GEOMObject
247     OperationGUI PrimitiveGUI RepairGUI TransformationGUI DependencyTree
248     STLPluginGUI BREPPluginGUI STEPPluginGUI IGESPluginGUI XAOPluginGUI VTKPluginGUI
249     )
250 ENDIF(SALOME_BUILD_GUI)
251
252 IF(SALOME_GEOM_USE_OPENCV)
253   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
254     GEOMShapeRec
255     )
256 ENDIF(SALOME_GEOM_USE_OPENCV)
257
258 IF(SALOME_GEOM_BUILD_CC)
259   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
260     CurveCreator
261     )
262 ENDIF(SALOME_GEOM_BUILD_CC)
263
264 # Add all targets to the build-tree export set
265 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
266   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
267
268 # Create the configuration files:
269 #   - in the build tree:
270
271 #      Ensure the variables are always defined for the configure:
272 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
273 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
274 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
275 SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}")
276 SET(OPENCV_ROOT_DIR "${OPENCV_ROOT_DIR}")
277
278 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
279
280 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
281 SALOME_CONFIGURE_PREPARE(OpenCV CAS VTK)
282                          
283 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
284     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
285     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
286     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
287     KERNEL_ROOT_DIR GUI_ROOT_DIR CAS_ROOT_DIR VTK_ROOT_DIR OPENCV_ROOT_DIR)
288
289 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
290 #       Get the relative path of the include directory so 
291 #       we can register it in the generated configuration files:
292 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
293 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
294 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
295 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
296 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
297 #    KERNEL_ROOT_DIR GUI_ROOT_DIR CAS_ROOT_DIR VTK_ROOT_DIR OPENCV_ROOT_DIR)
298
299 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
300     VERSION ${${PROJECT_NAME_UC}_VERSION}
301     COMPATIBILITY AnyNewerVersion)
302   
303 # Install the CMake configuration files:
304 INSTALL(FILES
305   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
306   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
307   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
308
309 # Install the export set for use with the install-tree
310 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
311         FILE ${PROJECT_NAME}Targets.cmake)