]> Creatis software - bbtk.git/blob - kernel/cmake/BBTKConfigurePackage2.cmake
Feature #1774
[bbtk.git] / kernel / cmake / BBTKConfigurePackage2.cmake
1  # ---------------------------------------------------------------------
2  #
3  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4  #                        pour la SantÈ)
5  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8  #
9  #  This software is governed by the CeCILL-B license under French law and
10  #  abiding by the rules of distribution of free software. You can  use,
11  #  modify and/ or redistribute the software under the terms of the CeCILL-B
12  #  license as circulated by CEA, CNRS and INRIA at the following URL
13  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14  #  or in the file LICENSE.txt.
15  #
16  #  As a counterpart to the access to the source code and  rights to copy,
17  #  modify and redistribute granted by the license, users are provided only
18  #  with a limited warranty  and the software's author,  the holder of the
19  #  economic rights,  and the successive licensors  have only  limited
20  #  liability.
21  #
22  #  The fact that you are presently reading this means that you have had
23  #  knowledge of the CeCILL-B license and that you accept its terms.
24  # ------------------------------------------------------------------------ */
25
26
27 # ==================================
28 #           W A R N I N G !
29 # ==================================
30 #
31 # This file is a copy of BBTKConfigurePackage.cmake
32 #
33 # Only ONE commented out line differs
34 # :-(
35 # In case of modification, mind to modify BBTKConfigurePackage.cmake as well!
36 #
37
38 MESSAGE(STATUS "")
39 MESSAGE(STATUS "=======================================")
40 MESSAGE(STATUS "CONFIGURING BBTK PACKAGE ${BBTK_PACKAGE_NAME}")
41
42 #---------------------------------------------------------------------------
43 SET(${BBTK_PACKAGE_NAME}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
44 #---------------------------------------------------------------------------
45
46 #---------------------------------------------------------------------------
47 IF(NOT BBTK_CORE_PACKAGE)
48   #---------------------------------------------------------------------------
49   SET(BBTK_PACKAGE_LIBS 
50     ${BBTK_PACKAGE_LIBS}
51     ${BBTK_LIBRARIES})
52   MARK_AS_ADVANCED(BBTK_DIR)
53   #-------------------------------------------------------------------------
54   # If not a core package must include necessary cmake scripts
55   INCLUDE(${BBTK_CMAKE_DIR}/BBTKConfigurePackagePaths.cmake)
56   INCLUDE(${BBTK_CMAKE_DIR}/BBTKBuildAllOption.cmake)
57   #  INCLUDE(${BBTK_CMAKE_DIR}/BBTKMacros.cmake)
58   
59 # ==================================
60 #           W A R N I N G !
61 # ==================================
62 #
63 # Hereafter is commented out line :
64   
65   #INCLUDE(${BBTK_CMAKE_DIR}/BBTKFindLibraries.cmake) # JPR
66   
67   #-------------------------------------------------------------------------
68   # Configure bbtk_config_build.xml.in for bbi to find the bbs
69   INCLUDE(${BBTK_CMAKE_DIR}/BBTKConfigureBbtkConfigXmlForBuildTree.cmake)
70   #------------------------------------------------------------------------- 
71   # WARNING : 
72   # FOR THE MOMENT ONLY ONE BBTK PACKAGE PER PROJECT ALLOWED!!!
73   # 
74   SET(${BBTK_PACKAGE_NAME}_BINARY_DIR  ${PROJECT_BINARY_DIR})
75   # ${CMAKE_CURRENT_BINARY_DIR})
76   #------------------------------------------------------------------------- 
77   #---------------------------------------------------------------------------
78   # CREATES THE bbtkPackage TEXT FILE
79   CONFIGURE_FILE(
80     ${BBTK_CMAKE_DIR}/bbtkPackage.in
81     ${${BBTK_PACKAGE_NAME}_BINARY_DIR}/bbtkPackage
82     @ONLY
83     )
84   IF (WIN32)
85     INSTALL ( FILES ${${BBTK_PACKAGE_NAME}_BINARY_DIR}/bbtkPackage
86       DESTINATION "." )
87   ENDIF (WIN32)
88   #---------------------------------------------------------------------------
89 ELSE(NOT BBTK_CORE_PACKAGE)
90   SET(${BBTK_PACKAGE_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR})
91 ENDIF(NOT BBTK_CORE_PACKAGE)
92 #---------------------------------------------------------------------------
93
94
95
96
97
98 #----------------------------------------------------------------------------
99 # USER DEFINED ADDITIONAL INCLUDE DIRS
100 INCLUDE_DIRECTORIES(${${BBTK_PACKAGE_NAME}_INCLUDE_DIRS})
101 #----------------------------------------------------------------------------
102
103
104 #---------------------------------------------------------------------------
105 # Package dependencies
106 SET(${BBTK_PACKAGE_NAME}_DEPS bb${BBTK_PACKAGE_NAME})
107 STRING(REGEX MATCH "${${BBTK_PACKAGE_NAME}_DEPS}" 
108   ${BBTK_PACKAGE_NAME}_IN_DEPS
109   "${BBTK_PACKAGES_DEPS}")
110 #---------------------------------------------------------------------------
111 #SET(BBTK_PACKAGES_DEPS "" CACHE INTERNAL "bbtk packages dependencies" FORCE)
112
113
114
115 #----------------------------------------------------------------------------
116 # VARS CONFIGURED IN bbPackage.h AND IN doc/bbdoc/header.html.in
117 SET(BBTK_PACKAGE_AUTHOR        "${${BBTK_PACKAGE_NAME}_AUTHOR}")
118 SET(BBTK_PACKAGE_DESCRIPTION   "${${BBTK_PACKAGE_NAME}_DESCRIPTION}")
119 SET(BBTK_PACKAGE_MAJOR_VERSION ${${BBTK_PACKAGE_NAME}_MAJOR_VERSION})
120 SET(BBTK_PACKAGE_MINOR_VERSION ${${BBTK_PACKAGE_NAME}_MINOR_VERSION})
121 SET(BBTK_PACKAGE_BUILD_VERSION ${${BBTK_PACKAGE_NAME}_BUILD_VERSION})
122 SET(BBTK_PACKAGE_VERSION 
123   "\"${${BBTK_PACKAGE_NAME}_MAJOR_VERSION}.${${BBTK_PACKAGE_NAME}_MINOR_VERSION}.${${BBTK_PACKAGE_NAME}_BUILD_VERSION}\"")
124 #----------------------------------------------------------------------------
125
126
127 #---------------------------------------------------------------------------
128 # If package deps not in global deps : add them
129 IF(NOT ${BBTK_PACKAGE_NAME}_IN_DEPS)
130   SET(BBTK_PACKAGES_DEPS "${${BBTK_PACKAGE_NAME}_DEPS};${BBTK_PACKAGES_DEPS}"
131     CACHE INTERNAL "bbtk packages dependencies" FORCE)
132   #   MESSAGE(STATUS "Packages=${BBTK_PACKAGES_DEPS}")
133 ENDIF(NOT ${BBTK_PACKAGE_NAME}_IN_DEPS)
134 #---------------------------------------------------------------------------
135
136 #---------------------------------------------------------------------------
137 # Package dependencies
138 IF(${BBTK_PACKAGE_NAME}_USE_VTK)
139   SET(USE_VTK ON CACHE BOOL "Use VTK" FORCE)
140   SET(${BBTK_PACKAGE_NAME}_LIBS
141     ${${BBTK_PACKAGE_NAME}_LIBS}
142     ${VTK_LIBRARIES}
143     )
144 ENDIF(${BBTK_PACKAGE_NAME}_USE_VTK)
145
146 IF(${BBTK_PACKAGE_NAME}_USE_ITK)
147   SET(USE_ITK ON CACHE BOOL "Use ITK" FORCE)
148   SET(${BBTK_PACKAGE_NAME}_LIBS
149     ${${BBTK_PACKAGE_NAME}_LIBS}
150     ${ITK_LIBRARIES}
151     )
152 ENDIF(${BBTK_PACKAGE_NAME}_USE_ITK)
153
154 IF(${BBTK_PACKAGE_NAME}_USE_QT)
155   SET(USE_QT4 ON CACHE BOOL "Use QT" FORCE)
156   SET(${BBTK_PACKAGE_NAME}_LIBS
157     ${${BBTK_PACKAGE_NAME}_LIBS}
158     ${QT_LIBRARIES}
159     )
160 ENDIF(${BBTK_PACKAGE_NAME}_USE_QT)
161
162 #----------
163
164 IF(${BBTK_PACKAGE_NAME}_USE_GDCM)
165   SET(USE_GDCM ON CACHE BOOL "Use GDCM" )
166   SET(USE_GDCM2 OFF CACHE BOOL "Use GDCM2" )
167   SET(USE_GDCM_VTK ON CACHE BOOL "Use GDCM_VTK" FORCE)
168   SET(${BBTK_PACKAGE_NAME}_LIBS
169     ${${BBTK_PACKAGE_NAME}_LIBS}
170     ${GDCM_LIBRARIES}
171     )
172         IF(USE_GDCM)
173                 IF(USE_GDCM2)
174                 message(FATAL_ERROR "You cannot select both GDCM and GDCM2 (DICOM library readers)")
175                 ENDIF(USE_GDCM2)
176         ENDIF(USE_GDCM)
177 ENDIF(${BBTK_PACKAGE_NAME}_USE_GDCM)
178
179 #----------
180
181 IF(${BBTK_PACKAGE_NAME}_USE_GDCM2)
182   SET(USE_GDCM2 ON CACHE BOOL "Use GDCM2" FORCE)
183   SET(USE_GDCM2_VTK ON CACHE BOOL "Use GDCM2_VTK" FORCE)
184   SET(${BBTK_PACKAGE_NAME}_LIBS
185     ${${BBTK_PACKAGE_NAME}_LIBS}
186     ${GDCM2_LIBRARIES}
187     )
188         IF(USE_GDCM2)
189                 IF(USE_GDCM)
190                 message(FATAL_ERROR "You cannot select both GDCM and GDCM2 (DICOM library readers)")
191                 ENDIF(USE_GDCM)
192         ENDIF(USE_GDCM2)
193 ENDIF(${BBTK_PACKAGE_NAME}_USE_GDCM2)
194
195 #----------
196
197 IF(${BBTK_PACKAGE_NAME}_USE_GSMIS)
198   SET(USE_GSMIS ON CACHE BOOL "Use GSMIS" FORCE)
199   SET(${BBTK_PACKAGE_NAME}_LIBS
200     ${${BBTK_PACKAGE_NAME}_LIBS}
201     ${GSMIS_LIBRARIES}
202     )
203 ENDIF(${BBTK_PACKAGE_NAME}_USE_GSMIS)
204
205 IF(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS)
206   IF(BBTK_CORE_PACKAGE)
207     SET(BBTK_USE_WXWIDGETS ON CACHE BOOL "Use wxWidgets" FORCE)
208     MESSAGE(STATUS "BBTK_USE_WXWIDGETS forced to ON by the compilation of the package ${BBTK_PACKAGE_NAME}")
209     # bbtk already links against wx ...
210     IF(WIN32)
211       SET(${BBTK_PACKAGE_NAME}_LIBS
212         ${${BBTK_PACKAGE_NAME}_LIBS}
213         ${WXWIDGETS_LIBRARIES}
214         )
215     ENDIF(WIN32)
216   ELSE(BBTK_CORE_PACKAGE)
217     # If linking against a non-wx bbtk : problem
218     IF(NOT BBTK_BUILT_WITH_WX)
219       MESSAGE(FATAL_ERROR "The bbtk package ${BBTK_PACKAGE_NAME} needs wxWidgets however the bbtk library which was found on your system was not compiled with wxWidgets : recompile it and rebuild the package.")
220     ELSE(NOT BBTK_BUILT_WITH_WX)
221       SET(USE_WXWIDGETS ON CACHE BOOL "Use wxWidgets" FORCE)
222       # bbtk already links against wx ...
223       IF(WIN32)
224         SET(${BBTK_PACKAGE_NAME}_LIBS
225           ${${BBTK_PACKAGE_NAME}_LIBS}
226           ${WXWIDGETS_LIBRARIES}
227           )
228       ENDIF(WIN32)
229     ENDIF(NOT BBTK_BUILT_WITH_WX)
230   ENDIF(BBTK_CORE_PACKAGE)
231 ENDIF(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS)
232
233
234 #---------------------------------------------------------------------------
235
236 MESSAGE(STATUS "")
237 MESSAGE(STATUS "=======================================")
238 MESSAGE(STATUS "${BBTK_PACKAGE_NAME} link libraries:")
239 MESSAGE(STATUS "${${BBTK_PACKAGE_NAME}_LIBS}")
240 MESSAGE(STATUS "=======================================")
241 MESSAGE(STATUS "")
242
243 #---------------------------------------------------------------------------
244 # Recurse into ADD_SUBDIRECTORY
245 ADD_SUBDIRECTORY(src)
246 ADD_SUBDIRECTORY(doc)
247 ADD_SUBDIRECTORY(bbs)
248 ADD_SUBDIRECTORY(data)
249 #---------------------------------------------------------------------------
250
251 MESSAGE(STATUS "=======================================")
252 MESSAGE(STATUS "")
253
254 #-----------------------------------------------------------------------------
255 # EOF
256 #-----------------------------------------------------------------------------
257
258
259
260