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