]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - CMakeLists.txt
Salome HOME
Merge from V7_3_BR branch 18/12/2013
[plugins/blsurfplugin.git] / CMakeLists.txt
1 # Copyright (C) 2012-2013  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.
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 7)
31 SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
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 ELSE(EXISTS ${KERNEL_ROOT_DIR})
45   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
46 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
47
48 IF(SALOME_LIGHT_ONLY)
49   MESSAGE(FATAL_ERROR "BLSURFPLUGIN module can't be built in Light mode (without CORBA)")
50 ENDIF()
51
52 # Platform setup
53 # ==============
54 INCLUDE(SalomeSetupPlatform)   # From KERNEL
55 # Always build libraries as shared objects:
56 SET(BUILD_SHARED_LIBS TRUE)
57 # Local macros:
58 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
59
60 # User options 
61 # ============
62 OPTION(SALOME_BUILD_DOC "Generate SALOME BLSURFPLUGIN documentation" ON)
63 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
64
65 IF(SALOME_BUILD_TESTS)
66   ENABLE_TESTING()
67 ENDIF()
68
69 # Advanced options:
70 OPTION(SALOME_BUILD_GUI "Enable BLSURFPLUGIN GUI" ON)
71 MARK_AS_ADVANCED(SALOME_BUILD_GUI)
72
73 ##
74 ## From KERNEL:
75 ##
76 # Python
77 FIND_PACKAGE(SalomePython REQUIRED)
78 # Boost
79 FIND_PACKAGE(SalomeBoost REQUIRED)
80 # CORBA
81 FIND_PACKAGE(SalomeOmniORB REQUIRED)
82 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
83
84 # Other KERNEL optionals:
85 IF(SALOME_BUILD_DOC)
86   FIND_PACKAGE(SalomeDoxygen)
87   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
88 ENDIF()
89
90 # Find GUI (optional)
91 # ===========
92 IF(SALOME_BUILD_GUI)
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)
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   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
103 ENDIF(SALOME_BUILD_GUI)
104
105 ##
106 ## From GUI:
107 ##
108 IF(SALOME_BUILD_GUI)
109   # Qt4
110   FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
111 ENDIF(SALOME_BUILD_GUI)
112
113 # OCCT
114 FIND_PACKAGE(SalomeCAS REQUIRED)
115 # VTK
116 FIND_PACKAGE(SalomeVTK 6.0 REQUIRED)
117
118 # Find GEOM
119 # ===========
120 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
121 IF(EXISTS ${GEOM_ROOT_DIR})
122   LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
123   FIND_PACKAGE(SalomeGEOM REQUIRED)
124 ELSE(EXISTS ${GEOM_ROOT_DIR})
125   MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
126 ENDIF(EXISTS ${GEOM_ROOT_DIR})
127
128 # Find SMESH
129 # ===========
130 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
131 IF(EXISTS ${SMESH_ROOT_DIR})
132   LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
133   FIND_PACKAGE(SalomeSMESH REQUIRED)
134   ADD_DEFINITIONS(${SMESH_DEFINITIONS})
135   INCLUDE_DIRECTORIES(${SMESH_INCLUDE_DIRS})
136   IF(SALOME_BUILD_GUI)
137     IF(NOT SALOME_SMESH_BUILD_GUI)
138       MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH with GUI, please set SALOME_BUILD_GUI=ON in SMESH module")
139     ENDIF(NOT SALOME_SMESH_BUILD_GUI)
140   ENDIF(SALOME_BUILD_GUI)
141   IF(SALOME_BUILD_DOC)
142     IF(NOT SALOME_SMESH_BUILD_DOC)
143       MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH documentation to build BLSURFPLUGIN documentation. "
144                           "So, you should either set SALOME_BUILD_DOC=OFF in BLSURFPLUGIN or set SALOME_BUILD_DOC=ON in SMESH module.")
145     ENDIF(NOT SALOME_SMESH_BUILD_DOC)
146   ENDIF(SALOME_BUILD_DOC)
147 ELSE(EXISTS ${SMESH_ROOT_DIR})
148   MESSAGE(FATAL_ERROR "We absolutely need a Salome SMESH, please define SMESH_ROOT_DIR")
149 ENDIF(EXISTS ${SMESH_ROOT_DIR})
150
151 ##
152 ## BLSURFPLUGIN specifics
153 ##
154 FIND_PACKAGE(SalomeMESHGEMS REQUIRED)
155
156 # Detection summary:
157 SALOME_PACKAGE_REPORT_AND_CHECK()
158
159 # Directories
160 # (default values taken from KERNEL)
161 # ===========
162 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
163 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
164 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
165 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
166 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
167    "Install path: SALOME scripts")
168 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
169    "Install path: SALOME script data")
170 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
171    "Install path: SALOME Python scripts")
172 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
173    "Install path: SALOME application skeleton - scripts")
174 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
175    "Install path: SALOME application skeleton - Python")
176 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
177 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
178    "Install path: SALOME Python shared modules")
179 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
180     "Install path: local SALOME CMake files") 
181 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
182   "Install path: local SALOME config files (obsolete, to be removed)")
183 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
184 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
185
186 # Specific to BLSURFPLUGIN:
187 SET(SALOME_BLSURFPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/blsurfplugin" CACHE PATH 
188     "Install path: SALOME BLSURFPLUGIN specific data")
189 SET(SALOME_BLSURFPLUGIN_INSTALL_TESTS ${SALOME_INSTALL_BINS})
190
191 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
192 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
193 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
194 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
195 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
196 MARK_AS_ADVANCED(SALOME_BLSURFPLUGIN_INSTALL_RES_DATA SALOME_BLSURFPLUGIN_INSTALL_TESTS)
197
198 # Accumulate environment variables for BLSURFPLUGIN module
199 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
200                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
201 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
202
203 # Sources 
204 # ========
205
206 ADD_SUBDIRECTORY(idl)
207 ADD_SUBDIRECTORY(adm_local)
208 ADD_SUBDIRECTORY(resources)
209 ADD_SUBDIRECTORY(src)
210 ADD_SUBDIRECTORY(bin)
211 IF(SALOME_BUILD_DOC)
212   ADD_SUBDIRECTORY(doc)
213 ENDIF(SALOME_BUILD_DOC)
214 IF(SALOME_BUILD_TESTS)
215   ADD_SUBDIRECTORY(tests)
216 ENDIF(SALOME_BUILD_TESTS)
217
218 # Header configuration
219 # ====================
220 SALOME_XVERSION(${PROJECT_NAME})
221 SALOME_CONFIGURE_FILE(BLSURFPLUGIN_version.h.in BLSURFPLUGIN_version.h INSTALL ${SALOME_INSTALL_HEADERS})
222
223 # Configuration export
224 # (here only the level 1 prerequisites are exposed)
225 # ====================
226 INCLUDE(CMakePackageConfigHelpers)
227
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   BLSURFEngine SalomeIDLBLSURFPLUGIN
232 )
233
234 IF(SALOME_BUILD_GUI)
235   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
236     BLSURFPluginGUI
237   )
238 ENDIF(SALOME_BUILD_GUI)
239
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)
243
244 # Create the configuration files:
245 #   - in the build tree:
246
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}")
250  
251 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
252
253 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
254 SALOME_CONFIGURE_PREPARE(MESHGEMS)
255
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)
261
262 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
263     VERSION ${${PROJECT_NAME_UC}_VERSION}
264     COMPATIBILITY AnyNewerVersion)
265   
266 # Install the CMake configuration files:
267 INSTALL(FILES
268   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
269   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
270   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
271
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)