diff --git a/CMakeLists.txt b/CMakeLists.txt index d0492ae424d727251072798f9e784aec81520e2c..5d792670e6200df489912b84cd63d1d1d840b126 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1126,3 +1126,16 @@ 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 a7f6ca89846849d5e8a5d004feef5b3aa6438581..56010dbaa84bd003ec71b0e81b022c0e04bdccbf 100644 --- a/Code/Common/CMakeLists.txt +++ b/Code/Common/CMakeLists.txt @@ -12,7 +12,7 @@ ENDIF( NOT OTB_USE_PQXX ) ADD_LIBRARY(OTBCommon ${OTBCommon_SRCS}) -TARGET_LINK_LIBRARIES (OTBCommon ITKAlgorithms ITKStatistics ITKCommon otbConfigFile) +TARGET_LINK_LIBRARIES (OTBCommon ITKAlgorithms ITKStatistics ITKCommon otbconfigfile) IF (OTB_USE_MAPNIK) TARGET_LINK_LIBRARIES(OTBCommon ${MAPNIK_LIBRARY}) ENDIF(OTB_USE_MAPNIK) diff --git a/Utilities/otbconfigfile/CMakeLists.txt b/Utilities/otbconfigfile/CMakeLists.txt index 6bd476639ebd0e8d8e3af1cd415037994fad8d9f..cef7f255484015d514a511b1137b7eb95a3d2c03 100644 --- a/Utilities/otbconfigfile/CMakeLists.txt +++ b/Utilities/otbconfigfile/CMakeLists.txt @@ -1,35 +1,45 @@ -PROJECT(otbConfigFilelib) +PROJECT(otbconfigfile) -FILE(GLOB otbConfigFilelib_SRCS "*.cpp") -FILE(GLOB otbConfigFilelib_HDRS "*.h") -SET(otbConfigFile_DEFAULT otb_config.inp) -ADD_LIBRARY(otbConfigFile ${otbConfigFilelib_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/${otbConfigFile_DEFAULT}) -TARGET_LINK_LIBRARIES(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} ) + +TARGET_LINK_LIBRARIES(otbconfigfile ) IF(OTB_LIBRARY_PROPERTIES) - SET_TARGET_PROPERTIES(otbConfigFile PROPERTIES ${OTB_LIBRARY_PROPERTIES}) + SET_TARGET_PROPERTIES(otbconfigfile PROPERTIES ${OTB_LIBRARY_PROPERTIES}) ENDIF(OTB_LIBRARY_PROPERTIES) -# INCLUDE_DIRECTORIES("${OTB_SOURCE_DIR}/Utilities/otbconfigfile") + IF(NOT OTB_INSTALL_NO_LIBRARIES) - INSTALL(TARGETS otbConfigFile + INSTALL(TARGETS otbconfigfile RUNTIME DESTINATION ${OTB_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries LIBRARY DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR_CM24} COMPONENT Development) ENDIF(NOT OTB_INSTALL_NO_LIBRARIES) IF(NOT OTB_INSTALL_NO_DEVELOPMENT) - INSTALL(FILES ${otbConfigFilelib_HDRS} + INSTALL(FILES ${otbconfigfilelib_HDRS} DESTINATION ${OTB_INSTALL_INCLUDE_DIR_CM24}/Utilities/otbconfigfile COMPONENT Development) ENDIF(NOT OTB_INSTALL_NO_DEVELOPMENT) -#copy the configuration file in the binary directory -ADD_CUSTOM_COMMAND( - OUTPUT ${OTB_BINARY_DIR}/${otbConfigFile_DEFAULT} - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${otbConfigFile_DEFAULT} ${OTB_BINARY_DIR}/${otbConfigFile_DEFAULT} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${otbConfigFile_DEFAULT} - COMMENT "Copy configuration file to OTB_BINARY_DIR" - ) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${otbConfigFile_DEFAULT} DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/Utilities/otbconfigfile/ConfigFile.cpp b/Utilities/otbconfigfile/ConfigFile.cpp index f041064e51720d31643c833bca149d9bd58f9d39..acb4dbc6d225822b64671fcf4af012b3198e8687 100644 --- a/Utilities/otbconfigfile/ConfigFile.cpp +++ b/Utilities/otbconfigfile/ConfigFile.cpp @@ -16,7 +16,7 @@ ConfigFile::ConfigFile( string filename, string delimiter, in >> (*this); } - + ConfigFile::ConfigFile() : myDelimiter( string(1,'=') ), myComment( string(1,'#') ) diff --git a/Utilities/otbconfigfile/generate-config-properties.cpp b/Utilities/otbconfigfile/generate-config-properties.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f22e15dc549cc0d8a06c2c7367ef9b4c0ca367e8 --- /dev/null +++ b/Utilities/otbconfigfile/generate-config-properties.cpp @@ -0,0 +1,121 @@ +/*========================================================================= + +Program: ORFEO Toolbox +Language: C++ +Date: $Date$ +Version: $Revision$ + + +Copyright (c) Centre National d'Etudes Spatiales. All rights reserved. +See OTBCopyright.txt for details. + +Copyright (c) CS Systemes d'information. All rights reserved. +See CSCopyright.txt for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include <cstdlib> +#include <ctime> +#include <fstream> +#include <string> +#include <iostream> + +/** + * @brief main application for generating the otb_config.inp file. + * + * @param argv[1] Path to OTB_BINARY_DIR/otb_config.inp + * + * @param argv[2] language parameter + */ +int main(int argc, char* argv[]) +{ + if (argc != 3) + { + exit(1); + } + + std::ofstream os(argv[1]); + if (!os) + { + exit(1); + } + /* + // Get the version. This is now passed in from the make file. + std::string versionString = "Version "; + versionString += argv[2]; + std::string versionNumber = argv[2]; + std::string majorVersion; + std::string minorVersion = "0"; + std::string releaseVersion = "0"; + std::string::size_type pos1 = std::string::npos; + std::string::size_type pos2 = std::string::npos; + + pos1 = versionNumber.find(".", 0); + if(pos1 != std::string::npos) + { + majorVersion = std::string(versionNumber.begin(), + versionNumber.begin()+pos1); + pos2 = versionNumber.find(".", pos1+1); + if(pos2 != std::string::npos) + { + minorVersion = std::string(versionNumber.begin()+pos1+1, + versionNumber.begin()+pos2); + releaseVersion = std::string(versionNumber.begin()+pos2+1, + versionNumber.end()); + } + } + else + { + majorVersion = versionNumber; + } + // Get the build date in the format of (yyyymmdd). + char s[11]; + s[10] = '\0'; + time_t t; + time(&t); + tm* lt = localtime(&t); + strftime(s, 11, "(%Y%m%d)", lt); + std::string date = s; + + // Write the header file. + os << "// Auto generated by version-config - DO NOT EDIT\n" + << "#ifndef ossimVersion_HEADER\n" + << "#define ossimVersion_HEADER\n" + << "\n" + << "#include <ossim/ossimConfig.h>\n" + << "\n" + << "#ifndef OSSIM_VERSION\n" + << "# define OSSIM_VERSION " << "\"" << versionString << "\"\n" + << "# define OSSIM_VERSION_NUMBER " << "\"" << versionNumber << "\"\n" + << "# define OSSIM_MAJOR_VERSION_NUMBER " << majorVersion << "\n" + << "# define OSSIM_MINOR_VERSION_NUMBER " << minorVersion << "\n" + << "# define OSSIM_RELEASE_NUMBER " << releaseVersion << "\n" + << "#endif\n" + << "\n" + << "// date format = (yyyymmdd)\n" + << "#ifndef OSSIM_BUILD_DATE\n" + << "# define OSSIM_BUILD_DATE " << "\"" << date << "\"\n" + << "#endif\n" + << "\n" + << "#endif /* End of #ifndef ossimVersion_HEADER " + << std::endl; + */ + std::string language(argv[2]); + + + os << "#Auto generated by config-properties \n" + << "#Language \n" + << "OTB_LANG=" + << language + << "\n" + << "# end of config file properties generation" + << std::endl; + os.close(); + + std::cout << "wrote file: " << argv[1] << std::endl; + + exit(0); +} diff --git a/Utilities/otbconfigfile/otb_config.inp b/Utilities/otbconfigfile/otb_config.inp deleted file mode 100644 index 91c74c5c257e129f2c0d396ab26bb0aa58e83ea6..0000000000000000000000000000000000000000 --- a/Utilities/otbconfigfile/otb_config.inp +++ /dev/null @@ -1,5 +0,0 @@ -#example properties for OTB and ... -LANG=fr -GEOIDE=/home/manuel/toto -WORLD=/home/manuel/tata -SRTM=/home/manuel/titi \ No newline at end of file diff --git a/Utilities/otbossim/src/ossim/version-config.cpp b/Utilities/otbossim/src/ossim/version-config.cpp index 7355c8ab8924a8bdedad72957a1fe34551c5ef02..a0c89e65450d6e95aeb5f7f52ee4e727a7bba6c5 100644 --- a/Utilities/otbossim/src/ossim/version-config.cpp +++ b/Utilities/otbossim/src/ossim/version-config.cpp @@ -15,7 +15,7 @@ //---------------------------------------------------------------------------- #include <cstdlib> #include <ctime> -#include <fstream> +#include <fstream> #include <string> #include <iostream>