]> SALOME platform Git repositories - modules/hydro.git/blob - CMakeLists.txt
Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / CMakeLists.txt
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
2 INCLUDE(CMakeDependentOption)
3
4 PROJECT(SalomeHYDRO C CXX)
5
6 ADD_SUBDIRECTORY (src/HYDRO_tests)
7
8 # Ensure a proper linker behavior:
9 CMAKE_POLICY(SET CMP0003 NEW)
10
11 # Versioning
12 # ===========
13 # Project name, upper case
14 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
15
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)
22
23 IF(WIN32)
24   ADD_DEFINITIONS(-DWNT)
25 ENDIF(WIN32)
26
27 # Find KERNEL
28 # ==============
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")
32   INCLUDE(SalomeMacros)
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} )
39
40 # Find SALOME GUI (optional)
41 # ==============
42 OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
43 IF(SALOME_BUILD_GUI)
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)
53
54 # Find GEOM
55 # ===========
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})
62   IF(SALOME_BUILD_GUI)
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})
70
71 # Platform setup
72 # ==============
73 INCLUDE(SalomeSetupPlatform)   # From SalomeMacros
74 # Always build libraries as shared objects:
75 SET(BUILD_SHARED_LIBS TRUE)
76 # Local macros:
77 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
78
79 # User options
80 # ============
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)
84
85 # Prerequisites
86 # =============
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:
90
91 ##
92 ## From KERNEL:
93 ##
94
95 # Mandatory products
96 FIND_PACKAGE(SalomePython    REQUIRED)
97
98 # Optional products:
99 IF(SALOME_BUILD_TESTS)
100   ENABLE_TESTING()
101   FIND_PACKAGE(SalomeCppUnit)
102   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
103 ENDIF()
104
105 IF(SALOME_BUILD_DOC)
106   IF(SALOME_USE_MPI)
107     FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
108     SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
109   ENDIF()  
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)
114 ENDIF()
115
116 # Find optional GUI libraries
117 IF(SALOME_BUILD_GUI)
118   # Qt4
119   FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
120 ENDIF(SALOME_BUILD_GUI)
121
122 ##
123 ## HYDRO specifics
124 ##
125
126 FIND_PACKAGE(SalomeCAS REQUIRED)
127
128 FIND_PACKAGE(SalomeVTK REQUIRED)
129
130 FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt4
131
132 FIND_PACKAGE(SalomePyQt4 REQUIRED)
133
134 FIND_PACKAGE(SalomeOmniORB REQUIRED)
135
136 # Detection summary:
137 SALOME_PACKAGE_REPORT_AND_CHECK()
138
139 # Directories
140 # ===========
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)")
158
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")
161
162 # Specific to HYDRO:
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")
169 MARK_AS_ADVANCED(
170   SALOME_HYDRO_INSTALL_RES_DATA
171   SALOME_HYDRO_INSTALL_RES_SCRIPTS
172   SALOME_HYDRO_INSTALL_SAMPLES
173   )
174
175 # Sources 
176 # ========
177 ADD_SUBDIRECTORY (src/shapelib)
178 ADD_SUBDIRECTORY (src/HYDROData)
179 ADD_SUBDIRECTORY (src/HYDROGUI)
180 ADD_SUBDIRECTORY (src/HYDROPy)
181 IF(SALOME_BUILD_DOC)
182   ADD_SUBDIRECTORY(doc)
183 ENDIF()
184
185 # Header configuration
186 # ====================
187 SALOME_XVERSION(${PROJECT_NAME})
188 SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
189
190 # Configuration export
191 # (here only the level 1 prerequisites are exposed)
192 # ====================
193 INCLUDE(CMakePackageConfigHelpers)
194
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
199 )
200
201 IF(SALOME_BUILD_TESTS)
202   #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
203 ENDIF(SALOME_BUILD_TESTS)
204
205 IF(SALOME_BUILD_GUI)
206   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
207     HYDROGUI 
208   )
209 ENDIF(SALOME_BUILD_GUI)
210
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)
214
215 # Create the configuration files:
216 #   - in the build tree:
217
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}")
225  
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)
232
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)
242
243 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
244     VERSION ${${PROJECT_NAME_UC}_VERSION}
245     COMPATIBILITY AnyNewerVersion)
246   
247 # Install the CMake configuration files:
248 INSTALL(FILES
249   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
250   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
251   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
252
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)
256
257
258
259 SET(_bin_scripts bin/hydro_setenv.py)
260 SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS})
261