1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
2 INCLUDE(CMakeDependentOption)
4 PROJECT(SalomeHYDRO C CXX)
6 ADD_SUBDIRECTORY (src/HYDRO_tests)
8 # Ensure a proper linker behavior:
9 CMAKE_POLICY(SET CMP0003 NEW)
13 # Project name, upper case
14 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
16 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 0)
17 SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
18 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
19 SET(${PROJECT_NAME_UC}_VERSION
20 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
21 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
24 ADD_DEFINITIONS(-DWNT)
29 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
30 IF( EXISTS ${KERNEL_ROOT_DIR} )
31 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
33 FIND_PACKAGE(SalomeKERNEL REQUIRED)
34 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
35 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
36 ELSE( EXISTS ${KERNEL_ROOT_DIR} )
37 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_HYDRO_USE_KERNEL to OFF !")
38 ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
40 # Find SALOME GUI (optional)
42 OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
44 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
45 IF(EXISTS ${GUI_ROOT_DIR})
46 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
47 FIND_PACKAGE(SalomeGUI)
48 ELSE(EXISTS ${GUI_ROOT_DIR})
49 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
50 ENDIF(EXISTS ${GUI_ROOT_DIR})
51 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
52 ENDIF(SALOME_BUILD_GUI)
56 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
57 IF(EXISTS ${GEOM_ROOT_DIR})
58 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
59 FIND_PACKAGE(SalomeGEOM REQUIRED)
60 ADD_DEFINITIONS(${GEOM_DEFINITIONS})
61 INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
63 IF(NOT SALOME_GEOM_BUILD_GUI)
64 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
65 ENDIF(NOT SALOME_GEOM_BUILD_GUI)
66 ENDIF(SALOME_BUILD_GUI)
67 ELSE(EXISTS ${GEOM_ROOT_DIR})
68 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
69 ENDIF(EXISTS ${GEOM_ROOT_DIR})
73 INCLUDE(SalomeSetupPlatform) # From SalomeMacros
74 # Always build libraries as shared objects:
75 SET(BUILD_SHARED_LIBS TRUE)
77 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
81 # (some options may have already been defined in KERNEL)
82 OPTION(SALOME_BUILD_DOC "Generate HYDRO documentation" ON)
83 OPTION(SALOME_BUILD_TESTS "Build HYDRO tests" ON)
87 # Find "big" prerequisites first - they reference themselves many others
88 # -> this can helps to find the smaller prerequisites and detect conflicts.
89 # In our case KERNEL may have already loaded many prerequisites which are also used in HYDRO:
96 FIND_PACKAGE(SalomePython REQUIRED)
99 IF(SALOME_BUILD_TESTS)
101 FIND_PACKAGE(SalomeCppUnit)
102 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
107 FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
108 SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
110 FIND_PACKAGE(SalomeDoxygen)
111 FIND_PACKAGE(SalomeSphinx)
112 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
113 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
116 # Find optional GUI libraries
119 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
120 ENDIF(SALOME_BUILD_GUI)
126 FIND_PACKAGE(SalomeCAS REQUIRED)
128 FIND_PACKAGE(SalomeVTK REQUIRED)
130 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
132 FIND_PACKAGE(SalomePyQt4 REQUIRED)
134 FIND_PACKAGE(SalomeOmniORB REQUIRED)
137 SALOME_PACKAGE_REPORT_AND_CHECK()
141 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
142 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
143 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
144 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
145 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
146 "Install path: SALOME scripts")
147 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
148 "Install path: SALOME script data")
149 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
150 "Install path: SALOME Python scripts")
151 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
152 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
153 "Install path: SALOME Python shared modules")
154 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
155 "Install path: local SALOME CMake files")
156 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
157 "Install path: local SALOME config files (obsolete, to be removed)")
159 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
160 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
163 SET(SALOME_HYDRO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydro" CACHE PATH
164 "Install path: SALOME HYDRO specific data")
165 SET(SALOME_HYDRO_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/hydro" CACHE PATH
166 "Install path: SALOME HYDRO scripts")
167 SET(SALOME_HYDRO_INSTALL_SAMPLES share/salome/hydrosamples CACHE PATH
168 "Install path: SALOME HYDRO samples")
170 SALOME_HYDRO_INSTALL_RES_DATA
171 SALOME_HYDRO_INSTALL_RES_SCRIPTS
172 SALOME_HYDRO_INSTALL_SAMPLES
177 ADD_SUBDIRECTORY (src/shapelib)
178 ADD_SUBDIRECTORY (src/HYDROData)
179 ADD_SUBDIRECTORY (src/HYDROGUI)
180 ADD_SUBDIRECTORY (src/HYDROPy)
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})