From 3abbcf371a90f69c324bb9f422239b76bd1e71ad Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Wed, 18 Feb 2015 11:54:05 +0100
Subject: [PATCH] BUG: fix ApplicationExample compilation and tests

---
 CMake/OTBApplicationMacros.cmake    | 11 +++++++----
 Examples/Application/CMakeLists.txt |  7 ++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/CMake/OTBApplicationMacros.cmake b/CMake/OTBApplicationMacros.cmake
index 40bd282c97..8004325c1e 100644
--- a/CMake/OTBApplicationMacros.cmake
+++ b/CMake/OTBApplicationMacros.cmake
@@ -116,7 +116,10 @@ macro(otb_test_application)
                   $<TARGET_FILE_DIR:otbapp_${TESTAPPLICATION_APP}>
                   ${TESTAPPLICATION_OPTIONS}
                   -testenv ${TESTAPPLICATION_TESTENVOPTIONS})
-  # Be sure that the ${otb-module}-all target triggers the build of commandline launcher and testdriver
-  add_dependencies(${otb-module}-all otbApplicationLauncherCommandLine)
-  add_dependencies(${otb-module}-all otbTestDriver)
-endmacro()
\ No newline at end of file
+                  
+  if(otb-module)
+    # Be sure that the ${otb-module}-all target triggers the build of commandline launcher and testdriver
+    add_dependencies(${otb-module}-all otbApplicationLauncherCommandLine)
+    add_dependencies(${otb-module}-all otbTestDriver)
+  endif()
+endmacro()
diff --git a/Examples/Application/CMakeLists.txt b/Examples/Application/CMakeLists.txt
index 02c4cabe30..e87366a71e 100644
--- a/Examples/Application/CMakeLists.txt
+++ b/Examples/Application/CMakeLists.txt
@@ -1,8 +1,9 @@
 project(ApplicationExamples)
 
-add_executable(ApplicationExample ApplicationExample.cxx)
-target_link_libraries(ApplicationExample ${OTB_LIBRARIES})
-
+otb_create_application(
+  NAME           ApplicationExample
+  SOURCES        ApplicationExample.cxx
+  LINK_LIBRARIES ${OTB_LIBRARIES})
 
 if(BUILD_TESTING)
   add_subdirectory(test)
-- 
GitLab