1 # Copyright (C) 2012-2015 ALNEOS
2 # Copyright (C) 2016-2023 EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.alneos.com/ or email : contact@alneos.fr
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
26 PROJECT(SalomeGMSHPLUGIN C CXX)
28 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
32 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
33 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
34 LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
35 INCLUDE(SalomeMacros NO_POLICY_SCOPE)
37 MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
42 SALOME_SETUP_VERSION(9.12.0)
43 MESSAGE(STATUS "Building ${PROJECT_NAME_UC} ${${PROJECT_NAME_UC}_VERSION} from \"${${PROJECT_NAME_UC}_GIT_SHA1}\"")
47 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
48 IF(EXISTS ${KERNEL_ROOT_DIR})
49 FIND_PACKAGE(SalomeKERNEL REQUIRED)
50 KERNEL_WITH_CORBA() # check whether KERNEL built with CORBA
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})
57 INCLUDE(SalomeSetupPlatform) # From KERNEL
58 # Always build libraries as shared objects:
59 SET(BUILD_SHARED_LIBS TRUE)
63 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
64 OPTION(SALOME_BUILD_DOC "Generate SALOME GMSHPLUGIN documentation" ON)
66 IF(SALOME_BUILD_TESTS)
71 OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
79 FIND_PACKAGE(SalomePythonInterp REQUIRED)
80 FIND_PACKAGE(SalomePythonLibs REQUIRED)
82 FIND_PACKAGE(SalomeBoost REQUIRED)
84 FIND_PACKAGE(SalomeOmniORB REQUIRED)
85 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
87 # Other KERNEL optionals:
89 FIND_PACKAGE(SalomeDoxygen)
90 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
96 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
97 IF(EXISTS ${GUI_ROOT_DIR})
98 FIND_PACKAGE(SalomeGUI)
99 SALOME_GUI_WITH_CORBA() # check whether GUI built with CORBA
100 ADD_DEFINITIONS(${GUI_DEFINITIONS})
101 INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
102 ELSE(EXISTS ${GUI_ROOT_DIR})
103 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
104 ENDIF(EXISTS ${GUI_ROOT_DIR})
105 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
106 ENDIF(SALOME_BUILD_GUI)
114 FIND_PACKAGE(SalomeQt5 REQUIRED)
115 ENDIF(SALOME_BUILD_GUI)
117 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED)
119 FIND_PACKAGE(SalomeVTK REQUIRED)
124 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
125 IF(EXISTS ${GEOM_ROOT_DIR})
126 FIND_PACKAGE(SalomeGEOM REQUIRED)
127 ELSE(EXISTS ${GEOM_ROOT_DIR})
128 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
129 ENDIF(EXISTS ${GEOM_ROOT_DIR})
134 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
135 IF(EXISTS ${SMESH_ROOT_DIR})
136 FIND_PACKAGE(SalomeSMESH REQUIRED)
137 ADD_DEFINITIONS(${SMESH_DEFINITIONS})
138 INCLUDE_DIRECTORIES(${SMESH_INCLUDE_DIRS})
140 IF(NOT SALOME_SMESH_BUILD_GUI)
141 MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH with GUI, please set SALOME_BUILD_GUI=ON in SMESH module")
142 ENDIF(NOT SALOME_SMESH_BUILD_GUI)
143 ENDIF(SALOME_BUILD_GUI)
145 IF(NOT SALOME_SMESH_BUILD_DOC)
146 MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH documentation to build GMSHPLUGIN documentation. "
147 "So, you should either set SALOME_BUILD_DOC=OFF in GMSHPLUGIN or set SALOME_BUILD_DOC=ON in SMESH module.")
148 ENDIF(NOT SALOME_SMESH_BUILD_DOC)
149 ENDIF(SALOME_BUILD_DOC)
150 ELSE(EXISTS ${SMESH_ROOT_DIR})
151 MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH, please define SMESH_ROOT_DIR")
152 ENDIF(EXISTS ${SMESH_ROOT_DIR})
155 ## GMSHPLUGIN specifics
157 FIND_PACKAGE(SalomeGMSH REQUIRED)
160 SALOME_PACKAGE_REPORT_AND_CHECK()
163 # (default values taken from KERNEL)
165 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
166 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
167 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
168 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
169 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
170 "Install path: SALOME scripts")
171 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
172 "Install path: SALOME script data")
173 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
174 "Install path: SALOME Python scripts")
175 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
176 "Install path: SALOME application skeleton - scripts")
177 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
178 "Install path: SALOME application skeleton - Python")
179 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
180 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
181 "Install path: SALOME Python shared modules")
182 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
183 "Install path: local SALOME CMake files")
184 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
185 "Install path: local SALOME config files (obsolete, to be removed)")
186 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
187 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
189 # Specific to GMSHPLUGIN:
190 SET(SALOME_GMSHPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/gmshplugin" CACHE PATH
191 "Install path: SALOME GMSHPLUGIN specific data")
192 SET(SALOME_GMSHPLUGIN_INSTALL_TESTS "${SALOME_INSTALL_BINS}/test")
194 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
195 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
196 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
197 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
198 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
199 MARK_AS_ADVANCED(SALOME_GMSHPLUGIN_INSTALL_RES_DATA SALOME_GMSHPLUGIN_INSTALL_TESTS)
201 # Accumulate environment variables for GMSHPLUGIN module
202 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
203 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
204 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
208 ADD_SUBDIRECTORY(idl)
209 ADD_SUBDIRECTORY(resources)
210 ADD_SUBDIRECTORY(src)
211 ADD_SUBDIRECTORY(bin)
212 IF(SALOME_BUILD_TESTS)
213 ADD_SUBDIRECTORY(tests)
214 ENDIF(SALOME_BUILD_TESTS)
216 ADD_SUBDIRECTORY(doc)
217 ENDIF(SALOME_BUILD_DOC)
219 # Header configuration
220 # ====================
221 SALOME_CONFIGURE_FILE(GMSHPLUGIN_version.h.in GMSHPLUGIN_version.h INSTALL ${SALOME_INSTALL_HEADERS})
223 # Configuration export
224 # (here only the level 1 prerequisites are exposed)
225 # ====================
226 INCLUDE(CMakePackageConfigHelpers)
228 # List of targets in this project we want to make visible to the rest of the world.
229 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
230 SET(_${PROJECT_NAME}_exposed_targets
231 GMSHEngine SalomeIDLGMSHPLUGIN
235 LIST(APPEND _${PROJECT_NAME}_exposed_targets
238 ENDIF(SALOME_BUILD_GUI)
240 # Add all targets to the build-tree export set
241 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
242 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
244 # Create the configuration files:
245 # - in the build tree:
247 # Ensure the variables are always defined for the configure:
248 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
249 SET(MESHGEMS_ROOT_DIR "${MESHGEMS_ROOT_DIR}")
251 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
253 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
254 SALOME_CONFIGURE_PREPARE(MESHGEMS)
256 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
257 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
258 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
259 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
260 SMESH_ROOT_DIR MESHGEMS_ROOT_DIR)
262 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
263 VERSION ${${PROJECT_NAME_UC}_VERSION}
264 COMPATIBILITY AnyNewerVersion)
266 # Install the CMake configuration files:
268 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
269 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
270 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
272 # Install the export set for use with the install-tree
273 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
274 FILE ${PROJECT_NAME}Targets.cmake)