Commit 0f71f217 authored by Manuel Grizonnet's avatar Manuel Grizonnet

ENH:generation of configure file with exeduring build process

parent 20f44c0b
......@@ -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
......@@ -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)
......
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})
......@@ -16,7 +16,7 @@ ConfigFile::ConfigFile( string filename, string delimiter,
in >> (*this);
}
ConfigFile::ConfigFile()
: myDelimiter( string(1,'=') ), myComment( string(1,'#') )
......
/*=========================================================================
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);
}
#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
......@@ -15,7 +15,7 @@
//----------------------------------------------------------------------------
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <fstream>
#include <string>
#include <iostream>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment