CMakeLists.txt 21.4 KB
Newer Older
OTB Bot's avatar
OTB Bot committed
1 2 3 4 5 6 7 8 9
PROJECT(Examples C)

# Macro defs

# This macro states that the executable "EXECUTABLE" upon execution will generate
# output image "OUTPUT_IMG". The executable will depend on "SOURCE_FILE" (since
# it is assumed that it was generated by compiling SOURCE_FILE), the perl script
# used to generate this macro, and any figures that may have been generated by
# other examples that the executable may use as inputs to produce the OUTPUT_IMG.
10
#
OTB Bot's avatar
OTB Bot committed
11 12 13 14 15
# TODO: Create a smarter macro. For an example that generates 3 outputs, 3 macros
# are created. This results in the example running 3 times, instead of once.
MACRO(RUN_EXAMPLE EXECUTABLE OUTPUT_IMG SOURCE_FILE)
  ADD_CUSTOM_COMMAND(
      OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/Generated/${OUTPUT_IMG}"
16
      COMMAND     "${OTB_PREFIX}/bin/${EXECUTABLE}"
OTB Bot's avatar
OTB Bot committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
      ARGS        ${ARGN}
      DEPENDS     ${RUN_EXAMPLES_SCRIPT} ${SOURCE_FILE} ${GENERATED_FIGURE_DEPS}
  )
ENDMACRO(RUN_EXAMPLE)

# If we made the assumption that the input file needed for this example
# was generated by running some other example, let us explicitly
# state that dependency so that makefile rules fire in the right
# order.
MACRO(ADD_GENERATED_FIG_DEPS OUTPUT_IMG GENERATED_FIG)
  SET( GENERATED_FIGURE_DEPS ${GENERATED_FIGURE_DEPS} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${GENERATED_FIG}" )
ENDMACRO( ADD_GENERATED_FIG_DEPS )


# Some images need normalization for proper display in the book.
# Create a convenience macro that normalizes SOME_IMG and produces
# a rescaled EPS_IMG using ImageMagick tools.
MACRO(CONVERT_AND_NORMALIZE_IMG SOME_IMG EPS_IMG PATH)
  ADD_CUSTOM_COMMAND(
      SOURCE      "${PATH}/${SOME_IMG}"
37
      COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
38 39 40 41 42 43 44 45 46 47
      ARGS        "-normalize" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
      DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
      OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
  )
ENDMACRO(CONVERT_AND_NORMALIZE_IMG)

# Same as before.. also flip the image in the process.
MACRO(CONVERT_AND_FLIP_AND_NORMALIZE_IMG SOME_IMG EPS_IMG PATH)
  ADD_CUSTOM_COMMAND(
      SOURCE      "${PATH}/${SOME_IMG}"
48
      COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
49 50 51 52 53 54 55
      ARGS        "-flip" "-normalize" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
      DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
      OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
  )
ENDMACRO(CONVERT_AND_FLIP_AND_NORMALIZE_IMG)

# Convert an image from some file format to EPS for inclusion in Latex using
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
# ImageMagick or bmeps

IF(OTB_USE_BMEPS)
  MACRO(CONVERT_IMG SOME_IMG EPS_IMG PATH)
    ADD_CUSTOM_COMMAND(
        SOURCE      "${PATH}/${SOME_IMG}"
        COMMAND     ${BMEPS_EXECUTABLE}
        ARGS        "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
        DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
        OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
    )
  ENDMACRO(CONVERT_IMG)
ELSE(OTB_USE_BMEPS)
  MACRO(CONVERT_IMG SOME_IMG EPS_IMG PATH)
    ADD_CUSTOM_COMMAND(
        SOURCE      "${PATH}/${SOME_IMG}"
        COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
        ARGS        "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
        DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
        OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
    )
  ENDMACRO(CONVERT_IMG)
ENDIF(OTB_USE_BMEPS)
OTB Bot's avatar
OTB Bot committed
79 80 81 82 83 84

# Convert an image from some file format to EPS for inclusion in Latex using
# ImageMagick.. also flip in the process.
MACRO(CONVERT_AND_FLIP_IMG SOME_IMG EPS_IMG PATH)
  ADD_CUSTOM_COMMAND(
      SOURCE      "${PATH}/${SOME_IMG}"
85
      COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
86 87 88 89 90 91 92
      ARGS        "-flip" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
      DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
      OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
  )
ENDMACRO(CONVERT_AND_FLIP_IMG)

# Convert an image from some file format to EPS for inclusion in Latex using
93 94
# ImageMagick or bmeps.. This image is an input image. A separate macro is necessary
# cause input images do not have any dependencies
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
IF(OTB_USE_BMEPS)
  MACRO(CONVERT_INPUT_IMG SOME_IMG EPS_IMG PATH)
    ADD_CUSTOM_COMMAND(
        SOURCE      "${PATH}/${SOME_IMG}"
        COMMAND     ${BMEPS_EXECUTABLE}
        ARGS        "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
        DEPENDS     ${RUN_EXAMPLES_SCRIPT}
        OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
    )
  ENDMACRO(CONVERT_INPUT_IMG)
ELSE(OTB_USE_BMEPS)
  MACRO(CONVERT_INPUT_IMG SOME_IMG EPS_IMG PATH)
    ADD_CUSTOM_COMMAND(
        SOURCE      "${PATH}/${SOME_IMG}"
        COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
        ARGS        "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
        DEPENDS     ${RUN_EXAMPLES_SCRIPT}
        OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
    )
  ENDMACRO(CONVERT_INPUT_IMG)
ENDIF(OTB_USE_BMEPS)
116

117 118 119 120 121 122

#
#
#  Error checking for the components we need
#
#
123

124 125


126
# # Convert an image from some file format to EPS for inclusion in Latex using
127 128
# # jpg2ps.. This image is an input image. A separate macro is necessary
# # cause input images do not have any dependencies
129 130 131 132 133
# #in case of input image is in jpeg
# MACRO(CONVERT_INPUT_COMPRESSED_IMG BASIC_OPTION SOME_IMG EPS_IMG PATH)
#   ADD_CUSTOM_COMMAND(
#       SOURCE      "${PATH}/${SOME_IMG}"
#       COMMAND     ${JPG2PS_EXECUTABLE}
134
#       ARGS        "${BASIC_OPTION}" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
135 136 137 138
#       DEPENDS     ${RUN_EXAMPLES_SCRIPT}
#       OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
#   )
# ENDMACRO(CONVERT_INPUT_COMPRESSED_IMG)
139
#
140 141 142 143
# MACRO(CONVERT_COMPRESSED_IMG BASIC_OPTION SOME_IMG EPS_IMG PATH)
#   ADD_CUSTOM_COMMAND(
#       SOURCE      "${PATH}/${SOME_IMG}"
#       COMMAND     ${JPG2PS_EXECUTABLE}
144
#       ARGS        "${BASIC_OPTION}" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
145 146 147 148
#       DEPENDS     ${RUN_EXAMPLES_SCRIPT} "${SoftwareGuide_BINARY_DIR}/Art/Generated/${SOME_IMG}"
#       OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
#   )
# ENDMACRO(CONVERT_COMPRESSED_IMG)
149 150


OTB Bot's avatar
OTB Bot committed
151
# Convert an image from some file format to EPS for inclusion in Latex using
152 153
# ImageMagick.. This image is an input image. A separate macro is necessary
# cause input images do not have any dependencies. Also flip
OTB Bot's avatar
OTB Bot committed
154 155 156
MACRO(CONVERT_AND_FLIP_INPUT_IMG SOME_IMG EPS_IMG PATH)
  ADD_CUSTOM_COMMAND(
      SOURCE      "${PATH}/${SOME_IMG}"
157
      COMMAND     ${IMAGEMAGICK_CONVERT_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
      ARGS        "-flip" "${PATH}/${SOME_IMG}" "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
      DEPENDS     ${RUN_EXAMPLES_SCRIPT}
      OUTPUT      "${SoftwareGuide_BINARY_DIR}/Art/${EPS_IMG}"
  )
ENDMACRO(CONVERT_AND_FLIP_INPUT_IMG)


# Set/Get macros to set/get dependencies on file foo.tex
MACRO(SET_DEP_FOR_TEXFILE NAME VAL)
  SET(${NAME} ${${NAME}} "${VAL}")
  #MESSAGE("set: ${NAME}: ${${NAME}}")
ENDMACRO(SET_DEP_FOR_TEXFILE)
MACRO(GET_DEP_FOR_TEXFILE NAME VAR)
  SET(${VAR} ${${NAME}})
  #MESSAGE("get: ${NAME}: ${${NAME}}")
ENDMACRO(GET_DEP_FOR_TEXFILE)

# Macro to indicate that foo.tex depends on bar.eps
MACRO(ADD_DEP_TEX_ON_EPS_FIGS TEXFILE EPSIMG)
  GET_FILENAME_COMPONENT(name "${TEXFILE}" NAME_WE)
  SET_DEP_FOR_TEXFILE("${name}-DEPS" "${SoftwareGuide_BINARY_DIR}/Art/${EPSIMG}")
  #MESSAGE("Add dependency to ${TEXFILE} to ${EPSIMG}")
  GET_DEP_TEX_ON_EPS_FIGS("${TEXFILE}" deps)
  #MESSAGE("Stored as ${deps}")
ENDMACRO(ADD_DEP_TEX_ON_EPS_FIGS)

# Get macro to get the list of eps figures that are dependencies of foo.tex
MACRO(GET_DEP_TEX_ON_EPS_FIGS TEXFILE VAR)
  GET_FILENAME_COMPONENT(name "${TEXFILE}" NAME_WE)
  #MESSAGE("-- name: ${name} --")
  GET_DEP_FOR_TEXFILE("${name}-DEPS" ${VAR})
ENDMACRO(GET_DEP_TEX_ON_EPS_FIGS)

#
# Find Perl executable

INCLUDE (${CMAKE_ROOT}/Modules/FindPerl.cmake)
IF( NOT PERL_FOUND )
  MESSAGE("Perl executable was not found")
ENDIF( NOT PERL_FOUND )
FIND_PROGRAM(PERLCXXPARSER
  NAMES ${SoftwareGuide_SOURCE_DIR}/ParseCxxExamples.pl
)


ADD_CUSTOM_TARGET(SoftwareGuideExamples  ALL echo)


#
207
# At some point we should replace the manual OTB_EXAMPLES_SRCS with
OTB Bot's avatar
OTB Bot committed
208 209 210 211 212 213
# this FILE GLOB_RECURSE expression.
#
#FILE( GLOB_RECURSE OTB_EXAMPLES_SRCS  ${OTB_SOURCE_DIR}/Examples/*.cxx)


SET( OTB_EXAMPLES_SRCS
214
  ${OTB_SOURCE_DIR}/Examples/Application/ApplicationExample.cxx
OTB Bot's avatar
OTB Bot committed
215
  ${OTB_SOURCE_DIR}/Examples/Installation/HelloWorld.cxx
216 217 218 219 220 221 222
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/Image1.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/Image2.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/Image3.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/Image4.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/VectorImage.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/Image5.cxx
  ${OTB_SOURCE_DIR}/Examples/DataRepresentation/Image/ImageListExample.cxx
223 224 225 226 227
  ${OTB_SOURCE_DIR}/Examples/IO/ImageReadWrite.cxx
  ${OTB_SOURCE_DIR}/Examples/IO/ImageReadCastWrite.cxx
  ${OTB_SOURCE_DIR}/Examples/IO/ImageReadRegionOfInterestWrite.cxx
  ${OTB_SOURCE_DIR}/Examples/IO/ComplexImageReadWrite.cxx
  ${OTB_SOURCE_DIR}/Examples/IO/MultibandImageReadWrite.cxx
Jordi Inglada's avatar
Jordi Inglada committed
228
  ${OTB_SOURCE_DIR}/Examples/IO/ExtractROI.cxx
Jordi Inglada's avatar
Jordi Inglada committed
229
  ${OTB_SOURCE_DIR}/Examples/IO/ImageSeriesIOExample.cxx
230
  ${OTB_SOURCE_DIR}/Examples/IO/MetadataExample.cxx
231
  #${OTB_SOURCE_DIR}/Examples/IO/DXFReaderExample.cxx
232
  ${OTB_SOURCE_DIR}/Examples/IO/VectorDataIOExample.cxx
233
  ${OTB_SOURCE_DIR}/Examples/IO/DEMToImageGenerator.cxx
234
  ${OTB_SOURCE_DIR}/Examples/IO/DEMHandlerExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
235 236
  ${OTB_SOURCE_DIR}/Examples/Filtering/CompositeFilterExample.cxx
  ${OTB_SOURCE_DIR}/Examples/Filtering/SecondDerivativeRecursiveGaussianImageFilter.cxx
Jordi Inglada's avatar
Jordi Inglada committed
237
  ${OTB_SOURCE_DIR}/Examples/Filtering/DanielssonDistanceMapImageFilter.cxx
238
  #${OTB_SOURCE_DIR}/Examples/Filtering/RasterizationExample.cxx
239
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/LeeImageFilter.cxx
240
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/FrostImageFilter.cxx
241 242
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/ScalingFilterExample.cxx
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/PrintableImageFilterExample.cxx
243
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/IndexedToRGBExample.cxx
244
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/DEMToRainbowExample.cxx
245
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/MeanShiftSegmentationFilterExample.cxx
246
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/HillShadingExample.cxx
247
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/BandMathFilterExample.cxx
248
  ${OTB_SOURCE_DIR}/Examples/BasicFilters/BandMathXImageFilterExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
249
  ${OTB_SOURCE_DIR}/Examples/Projections/OrthoRectificationExample.cxx
250
  ${OTB_SOURCE_DIR}/Examples/Projections/VectorDataProjectionExample.cxx
251
  ${OTB_SOURCE_DIR}/Examples/Projections/GeometriesProjectionExample.cxx
252
  ${OTB_SOURCE_DIR}/Examples/Projections/VectorDataExtractROIExample.cxx
253
  ${OTB_SOURCE_DIR}/Examples/Projections/PlaceNameToLonLatExample.cxx
254
  ${OTB_SOURCE_DIR}/Examples/Projections/EstimateRPCSensorModelExample.cxx
255
  #${OTB_SOURCE_DIR}/Examples/DisparityMap/NCCRegistrationFilterExample.cxx
256
  ${OTB_SOURCE_DIR}/Examples/DisparityMap/FineRegistrationImageFilterExample.cxx
257
  ${OTB_SOURCE_DIR}/Examples/DisparityMap/StereoReconstructionExample.cxx
258
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/TextureExample.cxx
259
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/PanTexExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
260
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/SFSExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
261
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/RatioLineDetectorExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
262
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/CorrelationLineDetectorExample.cxx
263
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/AsymmetricFusionOfLineDetectorExample.cxx
264 265
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/LineSegmentDetectorExample.cxx
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/RightAngleDetectionExample.cxx
266
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ParallelLineDetectionExample.cxx
267
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/TouziEdgeDetectorExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
268
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/HarrisExample.cxx
269
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/SURFExample.cxx
270
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ComplexMomentsImageFunctionExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
271
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ComplexMomentPathExample.cxx
272 273
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/HuMomentsImageFunctionExample.cxx
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/FlusserMomentsImageFunctionExample.cxx
274 275
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ExtractRoadByStepsExample.cxx
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ExtractRoadExample.cxx
Emmanuel Christophe's avatar
Emmanuel Christophe committed
276 277
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/SeamCarvingExample.cxx
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/SeamCarvingOtherExample.cxx
278
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/ThresholdToPointSetExample.cxx
279
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/CloudDetectionExample.cxx
280
  ${OTB_SOURCE_DIR}/Examples/FeatureExtraction/EdgeDensityExample.cxx
281 282 283 284 285
  ${OTB_SOURCE_DIR}/Examples/DimensionReduction/MaximumAutocorrelationFactor.cxx
  ${OTB_SOURCE_DIR}/Examples/DimensionReduction/PCAExample.cxx
  ${OTB_SOURCE_DIR}/Examples/DimensionReduction/NAPCAExample.cxx
  ${OTB_SOURCE_DIR}/Examples/DimensionReduction/MNFExample.cxx
  ${OTB_SOURCE_DIR}/Examples/DimensionReduction/ICAExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
286
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/DiffChDet.cxx
Jordi Inglada's avatar
Jordi Inglada committed
287 288
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/RatioChDet.cxx
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/CorrelChDet.cxx
289 290
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/KullbackLeiblerDistanceChDet.cxx
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/KullbackLeiblerProfileChDet.cxx
291
  ${OTB_SOURCE_DIR}/Examples/ChangeDetection/MultivariateAlterationDetector.cxx
292 293
  ${OTB_SOURCE_DIR}/Examples/Markov/MarkovClassification1Example.cxx
  ${OTB_SOURCE_DIR}/Examples/Markov/MarkovClassification2Example.cxx
294
  ${OTB_SOURCE_DIR}/Examples/Markov/MarkovClassification3Example.cxx
295
  ${OTB_SOURCE_DIR}/Examples/Markov/MarkovRestorationExample.cxx
296
  ${OTB_SOURCE_DIR}/Examples/Markov/MarkovRegularizationExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
297
  ${OTB_SOURCE_DIR}/Examples/Learning/SVMImageEstimatorClassificationMultiExample.cxx
298
  ${OTB_SOURCE_DIR}/Examples/Classification/SupervisedImageClassificationExample.cxx
299
  ${OTB_SOURCE_DIR}/Examples/Classification/DempsterShaferFusionOfClassificationMapsExample.cxx
300
  ${OTB_SOURCE_DIR}/Examples/Classification/ClassificationMapRegularizationExample.cxx
301
  ${OTB_SOURCE_DIR}/Examples/Learning/SOMExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
302
  ${OTB_SOURCE_DIR}/Examples/Learning/SOMClassifierExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
303
  ${OTB_SOURCE_DIR}/Examples/Classification/SOMImageClassificationExample.cxx
Jordi Inglada's avatar
Jordi Inglada committed
304
  ${OTB_SOURCE_DIR}/Examples/Learning/SEMModelEstimatorExample.cxx
305
  ${OTB_SOURCE_DIR}/Examples/Learning/TrainMachineLearningModelFromSamplesExample.cxx
306
  ${OTB_SOURCE_DIR}/Examples/Learning/TrainMachineLearningModelFromImagesExample.cxx
307
  ${OTB_SOURCE_DIR}/Examples/OBIA/RadiometricAttributesLabelMapFilterExample.cxx
308
  ${OTB_SOURCE_DIR}/Examples/OBIA/HooverMetricsEstimation.cxx
Jordi Inglada's avatar
Jordi Inglada committed
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageLinearIteratorWithIndex.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators2.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators5.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageRandomConstIteratorWithIndex.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ShapedNeighborhoodIterators1.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ShapedNeighborhoodIterators2.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators3.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/IteratorsExamples.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageLinearIteratorWithIndex2.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageRegionIterator.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageSliceIteratorWithIndex.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators6.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators1.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/NeighborhoodIterators4.cxx
  ${OTB_SOURCE_DIR}/Examples/Iterators/ImageRegionIteratorWithIndex.cxx
324
  ${OTB_SOURCE_DIR}/Examples/Radiometry/ARVIMultiChannelRAndBAndNIRVegetationIndexImageFilter.cxx
325
  ${OTB_SOURCE_DIR}/Examples/Radiometry/AVIMultiChannelRAndGAndNIRVegetationIndexImageFilter.cxx
326
  ${OTB_SOURCE_DIR}/Examples/Radiometry/NDVIRAndNIRVegetationIndexImageFilter.cxx
327
  ${OTB_SOURCE_DIR}/Examples/Radiometry/AtmosphericCorrectionSequencement.cxx
328
  ${OTB_SOURCE_DIR}/Examples/Fusion/BayesianFusionImageFilter.cxx
329
  ${OTB_SOURCE_DIR}/Examples/Fusion/PanSharpeningExample.cxx
330 331 332
  ${OTB_SOURCE_DIR}/Examples/Tutorials/HelloWorldOTB.cxx
  ${OTB_SOURCE_DIR}/Examples/Tutorials/Pipeline.cxx
  ${OTB_SOURCE_DIR}/Examples/Tutorials/FilteringPipeline.cxx
333
  ${OTB_SOURCE_DIR}/Examples/Tutorials/ScalingPipeline.cxx
Jordi Inglada's avatar
Jordi Inglada committed
334
  ${OTB_SOURCE_DIR}/Examples/Tutorials/OrthoFusion.cxx
335
  ${OTB_SOURCE_DIR}/Examples/Tutorials/Multispectral.cxx
336 337 338
  ${OTB_SOURCE_DIR}/Examples/Simulation/ProsailModel.cxx
  ${OTB_SOURCE_DIR}/Examples/Simulation/LAIFromNDVIImageTransform.cxx
  ${OTB_SOURCE_DIR}/Examples/Simulation/LAIAndPROSAILToSensorResponse.cxx
339
  ${OTB_SOURCE_DIR}/Examples/Hyperspectral/HyperspectralUnmixingExample.cxx
OTB Bot's avatar
OTB Bot committed
340 341
)

342 343 344 345
IF(OTB_USE_PATENTED)
SET(OTB_EXAMPLES_SRCS ${OTB_EXAMPLES_SRCS}
  ${OTB_SOURCE_DIR}/Examples/Patented/SIFTDisparityMapEstimation.cxx
  ${OTB_SOURCE_DIR}/Examples/Patented/SIFTFastExample.cxx
346
  ${OTB_SOURCE_DIR}/Examples/Patented/SIFTDensityExample.cxx
347
   )
348
ENDIF(OTB_USE_PATENTED)
349

350
# It is recommended that the user build the figures from the OTB executables
351
# to generate the guide to ensure consistency.
OTB Bot's avatar
OTB Bot committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
IF( BUILD_FIGURES )
  #
  # Generate .cmake files containing those macros defined above.
  #
  # First make a directory to store generated images
  MAKE_DIRECTORY( "${SoftwareGuide_BINARY_DIR}/Art/Generated" )
  SET ( GeneratedFolder "${SoftwareGuide_BINARY_DIR}/Art/Generated" )

  # Earlier versions of the book had all the images flipped upside down, legacy
  # issue.. So if this flag is set to ON, they will be flipped prior to inclusion
  # in the SW guide.
  IF(OTB_FLIP_INPUTS_AND_THEIR_OUTPUTS)
    SET(FILENAME "${SoftwareGuide_BINARY_DIR}/Art/Generated/Flipped_files.txt")
    FILE(WRITE ${FILENAME} "")
    FOREACH(FLIPIMG ${OTB_FLIP_IMG})
      FILE(APPEND ${FILENAME} "${FLIPIMG} ")
    ENDFOREACH(FLIPIMG)
369 370
  ENDIF(OTB_FLIP_INPUTS_AND_THEIR_OUTPUTS)

OTB Bot's avatar
OTB Bot committed
371 372 373
  SET(FILENAME2 "${SoftwareGuide_BINARY_DIR}/Art/Generated/GeneratedFiles.txt")
  FILE(WRITE ${FILENAME2} "")

374

OTB Bot's avatar
OTB Bot committed
375 376 377 378 379 380 381 382 383 384 385 386
  FOREACH (example ${OTB_EXAMPLES_SRCS})
    #
    # Configure .. copy needed source files
    #
    GET_FILENAME_COMPONENT(EXAMPLE_FILE ${example} NAME)
    #CONFIGURE_FILE(${example} ${Examples_BINARY_DIR}/${EXAMPLE_FILE}
    #  COPYONLY IMMEDIATE)

    #Clear Figure dependencies for this examples
    #A figure may be generated by another example
    SET( GENERATED_FIGURE_DEPS "")

387
    # Run Perl script on each example to generate .cmake files
OTB Bot's avatar
OTB Bot committed
388 389
    GET_FILENAME_COMPONENT(EXAMPLE_FILE_BASE ${example} NAME_WE)

390 391
    MESSAGE(STATUS "Processing example ${example}")

OTB Bot's avatar
OTB Bot committed
392 393 394 395
    # Parse the source file, foo.cxx to generate a foo.cmake containing above macros.
    IF(PERL_FOUND AND RUN_EXAMPLES_SCRIPT)
      SET( ExampleCmakeFile "${Examples_BINARY_DIR}/${EXAMPLE_FILE_BASE}.cmake")
      GET_FILENAME_COMPONENT(TEX_FILE ${example} NAME_WE)
396
      SET(TEX_FILE ${SoftwareGuide_BINARY_DIR}/Examples/${TEX_FILE}.tex)
397 398

      EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE}
399
                      ${RUN_EXAMPLES_SCRIPT} ${example} ${OTB_PREFIX}/bin ${OTB_DATA_PATHS} ${ExampleCmakeFile} ${TEX_FILE} ${GeneratedFolder} )
400
      # MESSAGE( ARGS ${RUN_EXAMPLES_SCRIPT} ${example} ${OTB_EXECUTABLES_DIR} ${OTB_DATA_PATHS} ${ExampleCmakeFile} ${TEX_FILE} ${GeneratedFolder})
OTB Bot's avatar
OTB Bot committed
401 402 403 404 405 406 407 408
      # Include each of the generated .cmake files in dependencies list
      # only if the file is generated (if it has command line tags)
      INCLUDE(${ExampleCmakeFile} OPTIONAL)

    ENDIF(PERL_FOUND AND RUN_EXAMPLES_SCRIPT)
  ENDFOREACH(example)

  #
409
  # Parse Latex file for latex includes
OTB Bot's avatar
OTB Bot committed
410 411 412 413 414 415 416 417 418 419 420
  #
  IF( PERL_FOUND AND PERLCXXPARSER )
    FOREACH(example ${OTB_EXAMPLES_SRCS})
    GET_FILENAME_COMPONENT(TEX_FILE ${example} NAME_WE)
    SET(TEX_FILE ${SoftwareGuide_BINARY_DIR}/Examples/${TEX_FILE}.tex)
    GET_DEP_TEX_ON_EPS_FIGS("${TEX_FILE}" deps)
    #MESSAGE("Deps gotten from GET_DEP_TEX_ON_EPS_FIG are ${deps}")
    #GET_FILENAME_COMPONENT(depsNAME ${deps} NAME)
    #MESSAGE("File ${TEX_FILE} depends on: ${deps}")
    ADD_CUSTOM_COMMAND(
      SOURCE    ${example}
421
      COMMAND   ${PERL_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
422 423 424 425 426 427 428 429 430 431 432 433
      ARGS      ${PERLCXXPARSER} ${example} ${TEX_FILE}
      TARGET    SoftwareGuideExamples
      DEPENDS   ${PERLCXXPARSER} ${example} ${deps}
      OUTPUTS   ${TEX_FILE}
    )
    SET(TEX_DEPENDENCIES ${TEX_DEPENDENCIES} ${TEX_FILE})
    ENDFOREACH(example)

  ENDIF( PERL_FOUND AND PERLCXXPARSER )

ELSE( BUILD_FIGURES )
  #
434
  # Parse Latex file for latex includes
OTB Bot's avatar
OTB Bot committed
435 436 437 438 439 440 441
  #
  IF( PERL_FOUND AND PERLCXXPARSER )
    FOREACH(example ${OTB_EXAMPLES_SRCS})
    GET_FILENAME_COMPONENT(TEX_FILE ${example} NAME_WE)
    SET(TEX_FILE ${SoftwareGuide_BINARY_DIR}/Examples/${TEX_FILE}.tex)
    ADD_CUSTOM_COMMAND(
      SOURCE    ${example}
442
      COMMAND   ${PERL_EXECUTABLE}
OTB Bot's avatar
OTB Bot committed
443 444 445 446 447 448 449 450 451 452 453 454 455
      ARGS      ${PERLCXXPARSER} ${example} ${TEX_FILE}
      TARGET    SoftwareGuideExamples
      DEPENDS   ${PERLCXXPARSER} ${example}
      OUTPUTS   ${TEX_FILE}
    )
    SET(TEX_DEPENDENCIES ${TEX_DEPENDENCIES} ${TEX_FILE})
    ENDFOREACH(example)

  ENDIF( PERL_FOUND AND PERLCXXPARSER )

ENDIF( BUILD_FIGURES )

ADD_CUSTOM_TARGET(BuildTexFiles ALL DEPENDS ${TEX_DEPENDENCIES})
456
SET(EXAMPLES_TEX_FILES ${TEX_DEPENDENCIES} CACHE INTERNAL "Internal EXAMPLES_TEX_FILES file list.")