]> SALOME platform Git repositories - modules/hydrosolver.git/blob - CMakeLists.txt
Salome HOME
Merge branch 'pre/V8_3_BR_izf' into pre/V8_3_BR
[modules/hydrosolver.git] / CMakeLists.txt
1 #  Copyright (C) 2012-2013 EDF
2 #
3 #  This file is part of SALOME HYDRO module.
4 #
5 #  SALOME HYDRO module is free software: you can redistribute it and/or modify
6 #  it under the terms of the GNU General Public License as published by
7 #  the Free Software Foundation, either version 3 of the License, or
8 #  (at your option) any later version.
9 #
10 #  SALOME HYDRO module is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU General Public License for more details.
14 #
15 #  You should have received a copy of the GNU General Public License
16 #  along with SALOME HYDRO module.  If not, see <http://www.gnu.org/licenses/>.
17
18 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
19 PROJECT(SalomeHYDROSOLVER CXX)
20
21 # Ensure a proper linker behavior:
22 CMAKE_POLICY(SET CMP0003 NEW)
23
24 # Versioning
25 # ===========
26 # Project name, upper case
27 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
28
29 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 2)
30 SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
31 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
32 SET(${PROJECT_NAME_UC}_VERSION
33   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
34 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
35
36 # Find KERNEL
37 # ===========
38 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
39 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
40   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
41   INCLUDE(SalomeMacros)
42 ELSE()
43   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
44 ENDIF()
45
46 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
47 IF(EXISTS ${KERNEL_ROOT_DIR})
48   LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
49   #INCLUDE(SalomeMacros)
50   FIND_PACKAGE(SalomeKERNEL REQUIRED)
51 ELSE(EXISTS ${KERNEL_ROOT_DIR})
52   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
53 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
54
55 # Platform setup
56 # ==============
57 INCLUDE(SalomeSetupPlatform)   # From KERNEL
58 # Always build libraries as shared objects:
59 SET(BUILD_SHARED_LIBS TRUE)
60 # Local macros:
61 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
62
63 # User options
64 # ============
65 OPTION(SALOME_BUILD_DOC "Generate SALOME HYDROSOLVER documentation" ON)
66 #OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) #for use in the future
67
68 #IF(SALOME_BUILD_TESTS)
69 #  ENABLE_TESTING()
70 #ENDIF()
71
72 ##
73 ## From KERNEL:
74 ##
75 FIND_PACKAGE(SalomePythonInterp REQUIRED)
76 FIND_PACKAGE(SalomePythonLibs REQUIRED)
77 #FIND_PACKAGE(SalomePython REQUIRED)
78 FIND_PACKAGE(SalomeOmniORB REQUIRED)
79 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
80 FIND_PACKAGE(SalomeSWIG REQUIRED)
81
82 # Med and Hdf5 are second order dependencies (deps for Telemac) but since Telemac libraries
83 # are not linked against them, we need to include them here for the Telemac wrapper
84 FIND_PACKAGE(SalomeMEDFile REQUIRED)
85 FIND_PACKAGE(SalomeHDF5 REQUIRED)
86
87 IF(SALOME_BUILD_DOC)
88   FIND_PACKAGE(SalomeSphinx REQUIRED)
89 ENDIF()
90
91 # Find GUI
92 # ===========
93 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
94 IF(EXISTS ${GUI_ROOT_DIR})
95   LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
96   FIND_PACKAGE(SalomeGUI REQUIRED)
97   ADD_DEFINITIONS(${GUI_DEFINITIONS})
98   INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
99 ELSE(EXISTS ${GUI_ROOT_DIR})
100   MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
101 ENDIF(EXISTS ${GUI_ROOT_DIR})
102
103 ##
104 ## From GUI:
105 ##
106 FIND_PACKAGE(SalomePyQt5 REQUIRED)
107
108 ##
109 ## HYDROSOLVER specifics
110 ##
111
112 FIND_PACKAGE(SalomeMascaret REQUIRED)
113 FIND_PACKAGE(SalomeTelemac REQUIRED)
114
115 # Directories
116 # (default values taken from KERNEL)
117 # ===========
118 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
119 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
120 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
121 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
122 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
123    "Install path: SALOME scripts")
124 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
125    "Install path: SALOME script data")
126 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
127    "Install path: SALOME Python scripts")
128 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
129    "Install path: SALOME application skeleton - scripts")
130 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
131    "Install path: SALOME application skeleton - Python")
132 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
133 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
134    "Install path: SALOME Python shared modules")
135 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
136     "Install path: local SALOME CMake files")
137 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
138   "Install path: local SALOME config files (obsolete, to be removed)")
139 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
140 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
141
142 # HYDROSOLVER specific:
143 SET(SALOME_HYDROSOLVER_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydrosolver" CACHE PATH "Install path: SALOME HYDROSOLVER specific data")
144 SET(SALOME_HYDROSOLVER_INSTALL_DOC "${SALOME_INSTALL_DOC}/gui/HYDROSOLVER" CACHE PATH "Install path: SALOME HYDROSOLVER doc")
145
146 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
147 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
148 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
149 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
150 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
151 MARK_AS_ADVANCED(SALOME_HYDROSOLVER_INSTALL_RES_DATA SALOME_HYDROSOLVER_INSTALL_DOC)
152
153 # Accumulate environment variables for HYDROSOLVER module
154 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS})
155 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
156
157 # Sources
158 # ========
159
160 ADD_SUBDIRECTORY(adm_local)
161 ADD_SUBDIRECTORY(resources)
162 ADD_SUBDIRECTORY(src)
163 ADD_SUBDIRECTORY(idl)
164 ADD_SUBDIRECTORY(tests)
165 IF(SALOME_BUILD_DOC)
166   ADD_SUBDIRECTORY(doc)
167 ENDIF()
168
169 # Configuration export
170 # (here only the level 1 prerequisites are exposed)
171 # ====================
172 INCLUDE(CMakePackageConfigHelpers)
173
174 # List of targets in this project we want to make visible to the rest of the world.
175 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
176 SET(_${PROJECT_NAME}_exposed_targets
177   SalomeIDLHYDROSOLVER
178 )
179
180 # Add all targets to the build-tree export set
181 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
182   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
183
184 # Create the configuration files:
185 #   - in the build tree:
186
187 # Ensure the variables are always defined for the configure:
188 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
189
190 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
191
192 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
193 # SALOME_CONFIGURE_PREPARE() #For use in the future
194
195 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
196     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
197     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
198     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
199     GUI_ROOT_DIR)
200
201 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
202     VERSION ${${PROJECT_NAME_UC}_VERSION}
203     COMPATIBILITY AnyNewerVersion)
204
205 # Install the CMake configuration files:
206 INSTALL(FILES
207   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
208   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
209   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
210
211 # Install the export set for use with the install-tree
212 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
213   FILE ${PROJECT_NAME}Targets.cmake)