1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
2 INCLUDE(CMakeDependentOption)
4 PROJECT(SalomeHYDRO C CXX)
6 # Ensure a proper linker behavior:
7 CMAKE_POLICY(SET CMP0003 NEW)
11 # Project name, upper case
12 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
14 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 1)
15 SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
16 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
17 SET(${PROJECT_NAME_UC}_VERSION
18 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
19 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
22 ADD_DEFINITIONS(-DWNT)
27 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
28 IF( EXISTS ${KERNEL_ROOT_DIR} )
29 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
31 FIND_PACKAGE(SalomeKERNEL REQUIRED)
32 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
33 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
34 ELSE( EXISTS ${KERNEL_ROOT_DIR} )
35 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_HYDRO_USE_KERNEL to OFF !")
36 ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
38 # Find SALOME GUI (optional)
40 OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
42 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
43 IF(EXISTS ${GUI_ROOT_DIR})
44 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
45 FIND_PACKAGE(SalomeGUI)
46 ELSE(EXISTS ${GUI_ROOT_DIR})
47 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
48 ENDIF(EXISTS ${GUI_ROOT_DIR})
49 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
50 ENDIF(SALOME_BUILD_GUI)
54 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
55 IF(EXISTS ${GEOM_ROOT_DIR})
56 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
57 FIND_PACKAGE(SalomeGEOM REQUIRED)
58 ADD_DEFINITIONS(${GEOM_DEFINITIONS})
59 INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
61 IF(NOT SALOME_GEOM_BUILD_GUI)
62 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
63 ENDIF(NOT SALOME_GEOM_BUILD_GUI)
64 ENDIF(SALOME_BUILD_GUI)
65 ELSE(EXISTS ${GEOM_ROOT_DIR})
66 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
67 ENDIF(EXISTS ${GEOM_ROOT_DIR})
71 INCLUDE(SalomeSetupPlatform) # From SalomeMacros
72 # Always build libraries as shared objects:
73 SET(BUILD_SHARED_LIBS TRUE)
75 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
79 # (some options may have already been defined in KERNEL)
80 OPTION(SALOME_BUILD_DOC "Generate HYDRO documentation" ON)
81 OPTION(SALOME_BUILD_TESTS "Build HYDRO tests" ON)
85 # Find "big" prerequisites first - they reference themselves many others
86 # -> this can helps to find the smaller prerequisites and detect conflicts.
87 # In our case KERNEL may have already loaded many prerequisites which are also used in HYDRO:
95 FIND_PACKAGE(SalomePython REQUIRED)
96 FIND_PACKAGE(SalomeCAS REQUIRED)
97 FIND_PACKAGE(SalomeVTK REQUIRED)
98 FIND_PACKAGE(SalomeOmniORB REQUIRED)
102 IF(SALOME_BUILD_TESTS)
104 FIND_PACKAGE(SalomeCppUnit)
105 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
110 FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
111 SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
113 FIND_PACKAGE(SalomeDoxygen)
114 FIND_PACKAGE(SalomeSphinx)
115 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
116 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
123 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
126 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
127 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL QtNetwork QtTest)
128 SET(QT_ROOT_DIR "${QT4_ROOT_DIR}")
129 SALOME_CONFIGURE_PREPARE(HYDROData HYDROGUI HYDROPy Qt4 PyQt4)
131 FIND_PACKAGE(SalomeQt5 REQUIRED)
132 SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
133 SALOME_CONFIGURE_PREPARE(HYDROData HYDROGUI HYDROPy Qt5 PyQt5)
137 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
138 FIND_PACKAGE(SalomePyQt4 REQUIRED)
139 SET(PYQT_ROOT_DIR "${PYQT4_ROOT_DIR}")
141 FIND_PACKAGE(SalomePyQt5 REQUIRED)
142 SET(PYQT_ROOT_DIR "${PYQT5_ROOT_DIR}")
146 SALOME_PACKAGE_REPORT_AND_CHECK()
150 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
151 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
152 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
153 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
154 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
155 "Install path: SALOME scripts")
156 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
157 "Install path: SALOME script data")
158 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
159 "Install path: SALOME Python scripts")
160 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
161 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
162 "Install path: SALOME Python shared modules")
163 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
164 "Install path: local SALOME CMake files")
165 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
166 "Install path: local SALOME config files (obsolete, to be removed)")
168 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
169 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
172 SET(SALOME_HYDRO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydro" CACHE PATH
173 "Install path: SALOME HYDRO specific data")
174 SET(SALOME_HYDRO_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/hydro" CACHE PATH
175 "Install path: SALOME HYDRO scripts")
176 SET(SALOME_HYDRO_INSTALL_SAMPLES share/salome/hydrosamples CACHE PATH
177 "Install path: SALOME HYDRO samples")
179 SALOME_HYDRO_INSTALL_RES_DATA
180 SALOME_HYDRO_INSTALL_RES_SCRIPTS
181 SALOME_HYDRO_INSTALL_SAMPLES
186 ADD_SUBDIRECTORY (src/shapelib)
187 ADD_SUBDIRECTORY (src/HYDRO_tests)
188 ADD_SUBDIRECTORY (src/HYDROData)
189 ADD_SUBDIRECTORY (src/HYDROGUI)
190 ADD_SUBDIRECTORY (src/HYDROPy)
192 ADD_SUBDIRECTORY(doc)
195 # Header configuration
196 # ====================
197 SALOME_XVERSION(${PROJECT_NAME})
198 SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
200 # Configuration export
201 # (here only the level 1 prerequisites are exposed)
202 # ====================
203 INCLUDE(CMakePackageConfigHelpers)
205 # List of targets in this project we want to make visible to the rest of the world.
206 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
207 SET(_${PROJECT_NAME}_exposed_targets
208 shapelib HYDROData HYDROPy
211 IF(SALOME_BUILD_TESTS)
212 #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
213 ENDIF(SALOME_BUILD_TESTS)
216 LIST(APPEND _${PROJECT_NAME}_exposed_targets
219 ENDIF(SALOME_BUILD_GUI)
221 # Add all targets to the build-tree export set
222 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
223 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
225 # Create the configuration files:
226 # - in the build tree:
228 # Ensure the variables are always defined for the configure:
229 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
230 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
231 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
232 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
233 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
234 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
236 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
237 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
238 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
239 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
240 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
241 KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR)
243 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
244 # Get the relative path of the include directory so
245 # we can register it in the generated configuration files:
246 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
247 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
248 # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
249 # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
250 # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
251 # KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR EXPAT_ROOT_DIR QSCINTILLA_ROOT_DIR)
253 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
254 VERSION ${${PROJECT_NAME_UC}_VERSION}
255 COMPATIBILITY AnyNewerVersion)
257 # Install the CMake configuration files:
259 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
260 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
261 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
263 # Install the export set for use with the install-tree
264 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
265 FILE ${PROJECT_NAME}Targets.cmake)
269 SET(_bin_scripts bin/hydro_setenv.py)
270 SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})