From 565753e2fd8e29bdf9a519f81e964c1d9f459e3f Mon Sep 17 00:00:00 2001
From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org>
Date: Tue, 13 Oct 2009 10:23:29 +0800
Subject: [PATCH] ENH: generation of the config file

---
 .../generate-config-properties.cpp              |  0
 CMakeLists.txt                                  | 14 --------------
 Code/Common/CMakeLists.txt                      | 12 ++++++++++++
 Utilities/otbconfigfile/CMakeLists.txt          | 17 -----------------
 4 files changed, 12 insertions(+), 31 deletions(-)
 rename {Utilities/otbconfigfile => CMake}/generate-config-properties.cpp (100%)

diff --git a/Utilities/otbconfigfile/generate-config-properties.cpp b/CMake/generate-config-properties.cpp
similarity index 100%
rename from Utilities/otbconfigfile/generate-config-properties.cpp
rename to CMake/generate-config-properties.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d792670e6..8842ddafd3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1125,17 +1125,3 @@ ENDIF(WIN32 AND NOT UNIX AND NOT CYGWIN)
 INCLUDE(CPack)
 
 ENDIF(OTB_USE_CPACK)
-
-
-#-----------------------------------------------------------------------------
-# Manage OTB Configuration file otb_config.inputs
-# SET(otbConfigFile_DEFAULT otb_config.inp)
-# #copy the configuration file in the binary directory
-# ADD_CUSTOM_COMMAND(
-#   OUTPUT ${OTB_BINARY_DIR}/${otbConfigFile_DEFAULT}
-#   COMMAND ${CMAKE_COMMAND} -E copy ${OTB_SOURCE_DIR}/Utilities/otbconfigfile/${otbConfigFile_DEFAULT} ${OTB_BINARY_DIR}/${otbConfigFile_DEFAULT}
-#   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${otbConfigFile_DEFAULT}
-#   COMMENT "Copy configuration file to OTB_BINARY_DIR"
-#   )
-# 
-# INSTALL(FILES ${OTB_SOURCE_DIR}/Utilities/otbconfigfile/${otbConfigFile_DEFAULT} DESTINATION ${CMAKE_INSTALL_PREFIX})
\ No newline at end of file
diff --git a/Code/Common/CMakeLists.txt b/Code/Common/CMakeLists.txt
index 56010dbaa8..d3a7a13c0b 100644
--- a/Code/Common/CMakeLists.txt
+++ b/Code/Common/CMakeLists.txt
@@ -26,6 +26,18 @@ IF(OTB_LIBRARY_PROPERTIES)
   SET_TARGET_PROPERTIES(OTBCommon PROPERTIES ${OTB_LIBRARY_PROPERTIES})
 ENDIF(OTB_LIBRARY_PROPERTIES)
 
+FILE(GLOB otbconfigfileCreation_SRCS "${OTB_SOURCE_DIR}/CMake/generate-config-properties.cpp")
+SET(otbconfigfile_DEFAULT "${OTB_BINARY_DIR}/otb_config.inp")
+
+ADD_EXECUTABLE(generate-config-properties ${otbconfigfileCreation_SRCS})
+
+ADD_CUSTOM_COMMAND(
+          TARGET OTBCommon
+          POST_BUILD
+          COMMAND generate-config-properties
+          ARGS "${otbconfigfile_DEFAULT}" "${OTB_LANG}"
+          COMMENT "Generating otb_config.inp" )
+
 IF(NOT OTB_INSTALL_NO_LIBRARIES)
   INSTALL(TARGETS OTBCommon
     RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries
diff --git a/Utilities/otbconfigfile/CMakeLists.txt b/Utilities/otbconfigfile/CMakeLists.txt
index cef7f25548..dd622f9749 100644
--- a/Utilities/otbconfigfile/CMakeLists.txt
+++ b/Utilities/otbconfigfile/CMakeLists.txt
@@ -2,23 +2,6 @@ PROJECT(otbconfigfile)
 
 FILE(GLOB otbconfigfilelib_SRCS "ConfigFile.cpp")
 FILE(GLOB otbconfigfilelib_HDRS "ConfigFile.h")
-FILE(GLOB otbconfigfileCreation_SRCS "generate-config-properties.cpp")
-FILE(GLOB otbconfigfile_DEFAULT "otb_config.inp")
-
-ADD_EXECUTABLE(generate-config-properties ${otbconfigfileCreation_SRCS})
-ADD_CUSTOM_COMMAND(
-          OUTPUT ${OTB_BINARY_DIR}/${otbconfigfile_DEFAULT}
-          COMMAND ${OTB_BINARY_DIR}/bin/generate-config-properties
-          ARGS "${OTB_BINARY_DIR}/${otbconfigfile_DEFAULT}" "${OTB_LANG}"
-          DEPENDS generate-config-properties
-          COMMENT "Generating otb_config.inp" )
-          
-          
-SET_SOURCE_FILES_PROPERTIES(
-     ${otbconfigfilelib_SRCS} PROPERTIES
-     OBJECT_DEPENDS "${OTB_BINARY_DIR}/${otbconfigfile_DEFAULT}"
-     )
-
 
 ADD_LIBRARY(otbconfigfile ${otbconfigfilelib_SRCS} )
 
-- 
GitLab