]> SALOME platform Git repositories - modules/hydro.git/blob - CMakeLists.txt
Salome HOME
Merge branch 'BR_v14_rc' of ssh://git.salome-platform.org/modules/hydro into HEAD
[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 # Ensure a proper linker behavior:
7 CMAKE_POLICY(SET CMP0003 NEW)
8
9 # Versioning
10 # ===========
11 # Project name, upper case
12 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
13
14 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 0)
15 SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
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)
20
21 IF(WIN32)
22   ADD_DEFINITIONS(-DWNT)
23 ENDIF(WIN32)
24
25 # Find KERNEL
26 # ==============
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")
30   INCLUDE(SalomeMacros)
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} )
37
38 # Find SALOME GUI (optional)
39 # ==============
40 OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
41 IF(SALOME_BUILD_GUI)
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)
51
52 # Find GEOM
53 # ===========
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})
60   IF(SALOME_BUILD_GUI)
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})
68
69 # Platform setup
70 # ==============
71 INCLUDE(SalomeSetupPlatform)   # From SalomeMacros
72 # Always build libraries as shared objects:
73 SET(BUILD_SHARED_LIBS TRUE)
74 # Local macros:
75 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
76
77 # User options
78 # ============
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)
82
83 # Prerequisites
84 # =============
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:
88
89 ##
90 ## From KERNEL:
91 ##
92
93 # Mandatory products
94 FIND_PACKAGE(SalomePython    REQUIRED)
95
96 # Optional products:
97 IF(SALOME_BUILD_TESTS)
98   ENABLE_TESTING()
99   FIND_PACKAGE(SalomeCppUnit)
100   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
101 ENDIF()
102
103 IF(SALOME_BUILD_DOC)
104   IF(SALOME_USE_MPI)
105     FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
106     SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
107   ENDIF()  
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)
112 ENDIF()
113
114 # Find optional GUI libraries
115 IF(SALOME_BUILD_GUI)
116   # Qt4
117   FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
118 ENDIF(SALOME_BUILD_GUI)
119
120 ##
121 ## HYDRO specifics
122 ##
123
124 FIND_PACKAGE(SalomeCAS REQUIRED)
125
126 FIND_PACKAGE(SalomeVTK REQUIRED)
127
128 FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt4
129
130 FIND_PACKAGE(SalomePyQt4 REQUIRED)
131
132 FIND_PACKAGE(SalomeOmniORB REQUIRED)
133
134 # Detection summary:
135 SALOME_PACKAGE_REPORT_AND_CHECK()
136
137 # Directories
138 # ===========
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)")
156
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")
159
160 # Specific to HYDRO:
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")
167 MARK_AS_ADVANCED(
168   SALOME_HYDRO_INSTALL_RES_DATA
169   SALOME_HYDRO_INSTALL_RES_SCRIPTS
170   SALOME_HYDRO_INSTALL_SAMPLES
171   )
172
173 # Sources 
174 # ========
175 ADD_SUBDIRECTORY (src/shapelib)
176 ADD_SUBDIRECTORY (src/HYDROData)
177 ADD_SUBDIRECTORY (src/HYDROGUI)
178 ADD_SUBDIRECTORY (src/HYDROPy)
179 IF(SALOME_BUILD_DOC)
180   ADD_SUBDIRECTORY(doc)
181 ENDIF()
182
183 # Header configuration
184 # ====================
185 SALOME_XVERSION(${PROJECT_NAME})
186 SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
187
188 # Configuration export
189 # (here only the level 1 prerequisites are exposed)
190 # ====================
191 INCLUDE(CMakePackageConfigHelpers)
192
193 # List of targets in this project we want to make visible to the rest of the world.
194 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
195 SET(_${PROJECT_NAME}_exposed_targets 
196   shapelib HYDROData HYDROPy
197 )
198
199 IF(SALOME_BUILD_TESTS)
200   #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
201 ENDIF(SALOME_BUILD_TESTS)
202
203 IF(SALOME_BUILD_GUI)
204   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
205     HYDROGUI 
206   )
207 ENDIF(SALOME_BUILD_GUI)
208
209 # Add all targets to the build-tree export set
210 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
211   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
212
213 # Create the configuration files:
214 #   - in the build tree:
215
216 #      Ensure the variables are always defined for the configure:
217 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
218 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
219 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
220 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
221 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
222 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
223  
224 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
225 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
226     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
227     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
228     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
229     KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR)
230
231 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
232 #       Get the relative path of the include directory so 
233 #       we can register it in the generated configuration files:
234 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
235 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
236 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
237 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
238 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX 
239 #    KERNEL_ROOT_DIR GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR EXPAT_ROOT_DIR QSCINTILLA_ROOT_DIR)
240
241 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
242     VERSION ${${PROJECT_NAME_UC}_VERSION}
243     COMPATIBILITY AnyNewerVersion)
244   
245 # Install the CMake configuration files:
246 INSTALL(FILES
247   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
248   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
249   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
250
251 # Install the export set for use with the install-tree
252 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
253         FILE ${PROJECT_NAME}Targets.cmake)