]> SALOME platform Git repositories - plugins/ghs3dplugin.git/blob - CMakeLists.txt
Salome HOME
Remove CMake warnings: set-up cmake policies globally in SalomeMacros.cmake
[plugins/ghs3dplugin.git] / CMakeLists.txt
1 # Copyright (C) 2012-2020  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 PROJECT(SalomeGHS3DPLUGIN C CXX)
21
22 # Versioning
23 # ===========
24 # Project name, upper case
25 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
26
27 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
28 SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
29 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
30 SET(${PROJECT_NAME_UC}_VERSION
31   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
32 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
33
34 # Common CMake macros
35 # ===================
36 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
37 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
38   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
39   INCLUDE(SalomeMacros)
40 ELSE()
41   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
42 ENDIF()
43
44 # Find KERNEL
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   KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
52 ELSE(EXISTS ${KERNEL_ROOT_DIR})
53   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
54 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
55
56 # Platform setup
57 # ==============
58 INCLUDE(SalomeSetupPlatform)   # From KERNEL
59 # Always build libraries as shared objects:
60 SET(BUILD_SHARED_LIBS TRUE)
61
62 # User options 
63 # ============
64 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
65 OPTION(SALOME_BUILD_DOC "Generate SALOME GHS3DPLUGIN documentation" ON)
66 OPTION(SALOME_USE_MG_LIBS "Use MeshGems libraries" OFF)
67
68 IF(SALOME_BUILD_TESTS)
69   ENABLE_TESTING()
70 ENDIF()
71
72 # Advanced options:
73 OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
74
75 MARK_AS_ADVANCED(SALOME_USE_MG_LIBS)
76
77 ##
78 ## From KERNEL:
79 ##
80
81 # Various
82 # Python
83 FIND_PACKAGE(SalomePythonInterp REQUIRED)
84 FIND_PACKAGE(SalomePythonLibs REQUIRED)
85 # Boost
86 FIND_PACKAGE(SalomeBoost REQUIRED)
87 # CORBA
88 FIND_PACKAGE(SalomeOmniORB REQUIRED)
89 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
90
91 # Other KERNEL optionals:  
92 IF(SALOME_BUILD_DOC)
93   FIND_PACKAGE(SalomeDoxygen)
94   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
95 ENDIF()
96
97 # Find GUI (optional)
98 # ===========
99 IF(SALOME_BUILD_GUI)
100   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
101   IF(EXISTS ${GUI_ROOT_DIR})
102     LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
103     FIND_PACKAGE(SalomeGUI)
104     SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
105     ADD_DEFINITIONS(${GUI_DEFINITIONS})
106     INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
107   ELSE(EXISTS ${GUI_ROOT_DIR})
108     MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
109   ENDIF(EXISTS ${GUI_ROOT_DIR})
110   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
111 ENDIF(SALOME_BUILD_GUI)
112
113 ##
114 ## From GUI:
115 ##
116
117 IF(SALOME_BUILD_GUI)
118   # Qt
119   FIND_PACKAGE(SalomeQt5 REQUIRED)
120 ENDIF(SALOME_BUILD_GUI)
121 # OCCT
122 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED)
123 # VTK
124 FIND_PACKAGE(SalomeVTK REQUIRED)
125
126 # Find GEOM
127 # ===========
128
129 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
130 IF(EXISTS ${GEOM_ROOT_DIR})
131   LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
132   FIND_PACKAGE(SalomeGEOM REQUIRED)
133 ELSE(EXISTS ${GEOM_ROOT_DIR})
134   MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
135 ENDIF(EXISTS ${GEOM_ROOT_DIR})
136
137 # Find SMESH
138 # ===========
139
140 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
141 IF(EXISTS ${SMESH_ROOT_DIR})
142   LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
143   FIND_PACKAGE(SalomeSMESH REQUIRED)
144   ADD_DEFINITIONS(${SMESH_DEFINITIONS})
145   INCLUDE_DIRECTORIES(${SMESH_INCLUDE_DIRS})
146   IF(SALOME_BUILD_GUI)
147     IF(NOT SALOME_SMESH_BUILD_GUI)
148       MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH with GUI, please set SALOME_BUILD_GUI=ON in SMESH module")
149     ENDIF(NOT SALOME_SMESH_BUILD_GUI)
150   ENDIF(SALOME_BUILD_GUI)
151   IF(SALOME_BUILD_DOC)
152     IF(NOT SALOME_SMESH_BUILD_DOC)
153       MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH documentation to build GHS3DPLUGIN documentation. "
154                           "So, you should either set SALOME_BUILD_DOC=OFF in GHS3DPLUGIN or set SALOME_BUILD_DOC=ON in SMESH module.")
155     ENDIF(NOT SALOME_SMESH_BUILD_DOC)
156   ENDIF(SALOME_BUILD_DOC)
157 ELSE(EXISTS ${SMESH_ROOT_DIR})
158   MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH, please define SMESH_ROOT_DIR")
159 ENDIF(EXISTS ${SMESH_ROOT_DIR})
160
161 ##
162 ## Find MESHGEMS
163 ## =============
164 IF(SALOME_USE_MG_LIBS)
165   FIND_PACKAGE(SalomeMESHGEMS)
166   SALOME_LOG_OPTIONAL_PACKAGE(MESHGEMS SALOME_USE_MG_LIBS)
167   ADD_DEFINITIONS(-DUSE_MG_LIBS)
168 ENDIF(SALOME_USE_MG_LIBS)
169
170 # Detection summary:
171 SALOME_PACKAGE_REPORT_AND_CHECK()
172
173 # Directories
174 # (default values taken from KERNEL)
175 # ===========
176 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
177 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
178 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
179 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
180 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
181    "Install path: SALOME scripts")
182 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
183    "Install path: SALOME script data")
184 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
185    "Install path: SALOME Python scripts")
186 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
187    "Install path: SALOME application skeleton - scripts")
188 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
189    "Install path: SALOME application skeleton - Python")
190 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
191 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
192    "Install path: SALOME Python shared modules")
193 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
194     "Install path: local SALOME CMake files") 
195 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
196   "Install path: local SALOME config files (obsolete, to be removed)")
197 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
198 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
199
200 # Specific to GHS3DPLUGIN:
201 SET(SALOME_GHS3DPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/ghs3dplugin" CACHE PATH 
202     "Install path: SALOME GHS3DPLUGIN specific data")
203
204 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
205 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
206 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
207 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
208 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
209 MARK_AS_ADVANCED(SALOME_GHS3DPLUGIN_INSTALL_RES_DATA)
210
211 # Accumulate environment variables for GHS3DPLUGIN module
212 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
213                                          ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
214 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
215 # Sources 
216 # ========
217
218 ADD_SUBDIRECTORY(idl)
219 ADD_SUBDIRECTORY(adm_local)
220 ADD_SUBDIRECTORY(resources)
221 ADD_SUBDIRECTORY(src)
222 ADD_SUBDIRECTORY(bin)
223 IF(SALOME_BUILD_DOC)
224   ADD_SUBDIRECTORY(doc)
225 ENDIF(SALOME_BUILD_DOC)
226
227 # Header configuration
228 # ====================
229 SALOME_XVERSION(${PROJECT_NAME})
230 SALOME_CONFIGURE_FILE(GHS3DPLUGIN_version.h.in GHS3DPLUGIN_version.h INSTALL ${SALOME_INSTALL_HEADERS})
231
232 # Configuration export
233 # (here only the level 1 prerequisites are exposed)
234 # ====================
235 INCLUDE(CMakePackageConfigHelpers)
236
237 # List of targets in this project we want to make visible to the rest of the world.
238 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
239 SET(_${PROJECT_NAME}_exposed_targets 
240   GHS3DEngine SalomeIDLGHS3DPLUGIN
241 )
242
243 IF(SALOME_BUILD_GUI)
244   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
245     GHS3DPluginGUI
246   )
247 ENDIF(SALOME_BUILD_GUI)
248
249 # Add all targets to the build-tree export set
250 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
251   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
252
253 # Create the configuration files:
254 #   - in the build tree:
255
256 # Ensure the variables are always defined for the configure:
257 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
258 SET(MESHGEMS_ROOT_DIR "${MESHGEMS_ROOT_DIR}")
259  
260 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
261
262 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
263 SALOME_CONFIGURE_PREPARE(MESHGEMS)
264
265 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
266     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
267     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
268     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
269     SMESH_ROOT_DIR MESHGEMS_ROOT_DIR)
270
271 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
272     VERSION ${${PROJECT_NAME_UC}_VERSION}
273     COMPATIBILITY AnyNewerVersion)
274   
275 # Install the CMake configuration files:
276 INSTALL(FILES
277   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
278   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
279   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
280
281 # Install the export set for use with the install-tree
282 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
283   FILE ${PROJECT_NAME}Targets.cmake)