1 # Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 INCLUDE(CMakeDependentOption)
22 PROJECT(SalomeGEOM C CXX)
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
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)
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")
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})
53 MESSAGE(FATAL_ERROR "GEOM module can't be built in Light mode (without CORBA)")
58 INCLUDE(SalomeSetupPlatform) # From KERNEL
59 # Always build libraries as shared objects:
60 SET(BUILD_SHARED_LIBS TRUE)
62 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
64 # User options defined in KERNEL
66 OPTION(SALOME_BUILD_DOC "Generate SALOME GEOM documentation" ON)
67 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
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)
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:
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)
95 # Other KERNEL optionals:
97 FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
99 IF(SALOME_BUILD_TESTS)
101 FIND_PACKAGE(SalomeCppUnit)
102 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
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)
113 # Find GUI (optional)
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)
128 ## Prerequisites From GUI:
134 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml)
136 # Optional prerequisites for GUI
137 IF(SALOME_USE_GLVIEWER)
138 FIND_PACKAGE(SalomeOpenGL)
139 SALOME_LOG_OPTIONAL_PACKAGE(OpenGL SALOME_USE_GLVIEWER)
141 ENDIF(SALOME_BUILD_GUI)
147 FIND_PACKAGE(SalomeCAS REQUIRED)
148 FIND_PACKAGE(SalomeVTK 6.0 REQUIRED)
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)
158 SALOME_PACKAGE_REPORT_AND_CHECK()
161 # (default values taken from KERNEL)
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)")
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")
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")
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)
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})
208 ADD_SUBDIRECTORY(idl)
210 ADD_SUBDIRECTORY(adm_local)
211 ADD_SUBDIRECTORY(resources)
212 ADD_SUBDIRECTORY(bin)
213 ADD_SUBDIRECTORY(src)
215 ADD_SUBDIRECTORY(doc)
218 # Header configuration
219 # ====================
220 SALOME_XVERSION(${PROJECT_NAME})
221 SALOME_CONFIGURE_FILE(GEOM_version.h.in GEOM_version.h INSTALL ${SALOME_INSTALL_HEADERS})
223 # Configuration export
224 # (here only the level 1 prerequisites are exposed)
225 # ====================
226 INCLUDE(CMakePackageConfigHelpers)
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
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
241 ENDIF(SALOME_BUILD_GUI)
243 IF(SALOME_GEOM_USE_OPENCV)
244 LIST(APPEND _${PROJECT_NAME}_exposed_targets
247 ENDIF(SALOME_GEOM_USE_OPENCV)
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)
253 # Create the configuration files:
254 # - in the build tree:
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}")
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)
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)
280 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
281 VERSION ${${PROJECT_NAME_UC}_VERSION}
282 COMPATIBILITY AnyNewerVersion)
284 # Install the CMake configuration files:
286 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
287 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
288 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
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)