]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - CMakeLists.txt
Salome HOME
Set development flag ON
[plugins/blsurfplugin.git] / CMakeLists.txt
1 # Copyright (C) 2013-2015  CEA/DEN, EDF R&D, OPEN CASCADE
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(SalomeBLSURFPLUGIN C CXX)
21
22 # Ensure a proper linker behavior:
23 CMAKE_POLICY(SET CMP0003 NEW)
24
25 # Versioning
26 # ===========
27 # Project name, upper case
28 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
29
30 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
31 SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
32 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
33 SET(${PROJECT_NAME_UC}_VERSION
34   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
35 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
36
37 # Find KERNEL
38 # ===========
39 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
40 IF(EXISTS ${KERNEL_ROOT_DIR})
41   LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
42   INCLUDE(SalomeMacros)
43   FIND_PACKAGE(SalomeKERNEL REQUIRED)
44   KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
45 ELSE(EXISTS ${KERNEL_ROOT_DIR})
46   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
47 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
48
49 # Platform setup
50 # ==============
51 INCLUDE(SalomeSetupPlatform)   # From KERNEL
52 # Always build libraries as shared objects:
53 SET(BUILD_SHARED_LIBS TRUE)
54 # Local macros:
55 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
56
57 # User options 
58 # ============
59 OPTION(SALOME_BUILD_DOC "Generate SALOME BLSURFPLUGIN documentation" ON)
60 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
61
62 IF(SALOME_BUILD_TESTS)
63   ENABLE_TESTING()
64 ENDIF()
65
66 # Advanced options:
67 OPTION(SALOME_BUILD_GUI "Enable BLSURFPLUGIN GUI" ON)
68 MARK_AS_ADVANCED(SALOME_BUILD_GUI)
69
70 ##
71 ## From KERNEL:
72 ##
73 # Python
74 FIND_PACKAGE(SalomePython REQUIRED)
75 # Boost
76 FIND_PACKAGE(SalomeBoost REQUIRED)
77 # CORBA
78 FIND_PACKAGE(SalomeOmniORB REQUIRED)
79 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
80
81 # Other KERNEL optionals:
82 IF(SALOME_BUILD_DOC)
83   FIND_PACKAGE(SalomeDoxygen)
84   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
85 ENDIF()
86
87 # Find GUI (optional)
88 # ===========
89 IF(SALOME_BUILD_GUI)
90   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
91   IF(EXISTS ${GUI_ROOT_DIR})
92     LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
93     FIND_PACKAGE(SalomeGUI)
94     SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
95     SALOME_GUI_MODE(SALOME_USE_SALOMEOBJECT)
96     ADD_DEFINITIONS(${GUI_DEFINITIONS})
97     INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
98   ELSE(EXISTS ${GUI_ROOT_DIR})
99     MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
100   ENDIF(EXISTS ${GUI_ROOT_DIR})
101   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
102 ENDIF(SALOME_BUILD_GUI)
103
104 ##
105 ## From GUI:
106 ##
107 IF(SALOME_BUILD_GUI)
108   # Qt
109   IF(NOT SALOME_GUI_BUILD_WITH_QT5)
110     FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
111   ELSE()
112     FIND_PACKAGE(SalomeQt5 REQUIRED)
113   ENDIF()
114 ENDIF(SALOME_BUILD_GUI)
115
116 # OCCT
117 FIND_PACKAGE(SalomeCAS REQUIRED)
118 # VTK
119 FIND_PACKAGE(SalomeVTK REQUIRED)
120
121 # Find GEOM
122 # ===========
123 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
124 IF(EXISTS ${GEOM_ROOT_DIR})
125   LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
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})
130
131 # Find SMESH
132 # ===========
133 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
134 IF(EXISTS ${SMESH_ROOT_DIR})
135   LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
136   FIND_PACKAGE(SalomeSMESH REQUIRED)
137   ADD_DEFINITIONS(${SMESH_DEFINITIONS})
138   INCLUDE_DIRECTORIES(${SMESH_INCLUDE_DIRS})
139   IF(SALOME_BUILD_GUI)
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)
144   IF(SALOME_BUILD_DOC)
145     IF(NOT SALOME_SMESH_BUILD_DOC)
146       MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH documentation to build BLSURFPLUGIN documentation. "
147                           "So, you should either set SALOME_BUILD_DOC=OFF in BLSURFPLUGIN 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})
153
154 ##
155 ## BLSURFPLUGIN specifics
156 ##
157 FIND_PACKAGE(SalomeMESHGEMS REQUIRED)
158
159 # Detection summary:
160 SALOME_PACKAGE_REPORT_AND_CHECK()
161
162 # Directories
163 # (default values taken from KERNEL)
164 # ===========
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")
188
189 # Specific to BLSURFPLUGIN:
190 SET(SALOME_BLSURFPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/blsurfplugin" CACHE PATH 
191     "Install path: SALOME BLSURFPLUGIN specific data")
192 SET(SALOME_BLSURFPLUGIN_INSTALL_TESTS ${SALOME_INSTALL_BINS})
193
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_BLSURFPLUGIN_INSTALL_RES_DATA SALOME_BLSURFPLUGIN_INSTALL_TESTS)
200
201 # Accumulate environment variables for BLSURFPLUGIN 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}) 
205
206 # Sources 
207 # ========
208
209 ADD_SUBDIRECTORY(idl)
210 ADD_SUBDIRECTORY(adm_local)
211 ADD_SUBDIRECTORY(resources)
212 ADD_SUBDIRECTORY(src)
213 ADD_SUBDIRECTORY(bin)
214 IF(SALOME_BUILD_DOC)
215   ADD_SUBDIRECTORY(doc)
216 ENDIF(SALOME_BUILD_DOC)
217 IF(SALOME_BUILD_TESTS)
218   ADD_SUBDIRECTORY(tests)
219 ENDIF(SALOME_BUILD_TESTS)
220
221 # Header configuration
222 # ====================
223 SALOME_XVERSION(${PROJECT_NAME})
224 SALOME_CONFIGURE_FILE(BLSURFPLUGIN_version.h.in BLSURFPLUGIN_version.h INSTALL ${SALOME_INSTALL_HEADERS})
225
226 # Configuration export
227 # (here only the level 1 prerequisites are exposed)
228 # ====================
229 INCLUDE(CMakePackageConfigHelpers)
230
231 # List of targets in this project we want to make visible to the rest of the world.
232 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
233 SET(_${PROJECT_NAME}_exposed_targets 
234   BLSURFEngine SalomeIDLBLSURFPLUGIN
235 )
236
237 IF(SALOME_BUILD_GUI)
238   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
239     BLSURFPluginGUI
240   )
241 ENDIF(SALOME_BUILD_GUI)
242
243 # Add all targets to the build-tree export set
244 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
245   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
246
247 # Create the configuration files:
248 #   - in the build tree:
249
250 # Ensure the variables are always defined for the configure:
251 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
252 SET(MESHGEMS_ROOT_DIR  "${MESHGEMS_ROOT_DIR}")
253  
254 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
255
256 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
257 SALOME_CONFIGURE_PREPARE(MESHGEMS)
258
259 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
260     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
261     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
262     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
263     SMESH_ROOT_DIR MESHGEMS_ROOT_DIR)
264
265 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
266     VERSION ${${PROJECT_NAME_UC}_VERSION}
267     COMPATIBILITY AnyNewerVersion)
268   
269 # Install the CMake configuration files:
270 INSTALL(FILES
271   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
272   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
273   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
274
275 # Install the export set for use with the install-tree
276 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
277   FILE ${PROJECT_NAME}Targets.cmake)