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