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:
94 FIND_PACKAGE(SalomePython REQUIRED)
97 IF(SALOME_BUILD_TESTS)
99 FIND_PACKAGE(SalomeCppUnit)
100 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
105 FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
106 SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
108 FIND_PACKAGE(SalomeDoxygen)
109 FIND_PACKAGE(SalomeSphinx)
110 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
111 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
114 # Find optional GUI libraries
117 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
118 ENDIF(SALOME_BUILD_GUI)
124 FIND_PACKAGE(SalomeCAS REQUIRED)
126 FIND_PACKAGE(SalomeVTK REQUIRED)
128 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
130 FIND_PACKAGE(SalomePyQt4 REQUIRED)
132 FIND_PACKAGE(SalomeOmniORB REQUIRED)
135 SALOME_PACKAGE_REPORT_AND_CHECK()
139 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
140 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
141 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
142 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
143 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
144 "Install path: SALOME scripts")
145 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
146 "Install path: SALOME script data")
147 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
148 "Install path: SALOME Python scripts")
149 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
150 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
151 "Install path: SALOME Python shared modules")
152 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
153 "Install path: local SALOME CMake files")
154 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
155 "Install path: local SALOME config files (obsolete, to be removed)")
157 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
158 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
161 SET(SALOME_HYDRO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydro" CACHE PATH
162 "Install path: SALOME HYDRO specific data")
163 SET(SALOME_HYDRO_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/hydro" CACHE PATH
164 "Install path: SALOME HYDRO scripts")
165 SET(SALOME_HYDRO_INSTALL_SAMPLES share/salome/hydrosamples CACHE PATH
166 "Install path: SALOME HYDRO samples")
168 SALOME_HYDRO_INSTALL_RES_DATA
169 SALOME_HYDRO_INSTALL_RES_SCRIPTS
170 SALOME_HYDRO_INSTALL_SAMPLES
175 ADD_SUBDIRECTORY (src/shapelib)
176 ADD_SUBDIRECTORY (src/HYDROData)
177 ADD_SUBDIRECTORY (src/HYDROGUI)
178 ADD_SUBDIRECTORY (src/HYDROPy)
179 ADD_SUBDIRECTORY (src/HYDROTools)
180 ADD_SUBDIRECTORY (src/HYDRO_tests)
182 ADD_SUBDIRECTORY(doc)
185 # Header configuration
186 # ====================
187 SALOME_XVERSION(${PROJECT_NAME})
188 SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
190 # Configuration export
191 # (here only the level 1 prerequisites are exposed)
192 # ====================
193 INCLUDE(CMakePackageConfigHelpers)
195 # List of targets in this project we want to make visible to the rest of the world.
196 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
197 SET(_${PROJECT_NAME}_exposed_targets
198 shapelib HYDROData HYDROPy
201 IF(SALOME_BUILD_TESTS)
202 #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
203 ENDIF(SALOME_BUILD_TESTS)
206 LIST(APPEND _${PROJECT_NAME}_exposed_targets
209 ENDIF(SALOME_BUILD_GUI)
211 # Add all targets to the build-tree export set
212 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
213 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
215 # Create the configuration files:
216 # - in the build tree:
218 # Ensure the variables are always defined for the configure:
219 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
220 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
221 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
222 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
223 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
224 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
226 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
227 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
228 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
229 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
230 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
231 KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR)
233 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
234 # Get the relative path of the include directory so
235 # we can register it in the generated configuration files:
236 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
237 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
238 # ${PROJECT_BINARY_DIR}/to_install/${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 EXPAT_ROOT_DIR QSCINTILLA_ROOT_DIR)
243 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
244 VERSION ${${PROJECT_NAME_UC}_VERSION}
245 COMPATIBILITY AnyNewerVersion)
247 # Install the CMake configuration files:
249 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
250 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
251 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
253 # Install the export set for use with the install-tree
254 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
255 FILE ${PROJECT_NAME}Targets.cmake)
259 SET(_bin_scripts bin/hydro_setenv.py)
260 SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})