From a6c351fa40c1aec8bd534dd2dd6f0fb040baeb71 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Thu, 21 Jan 2010 14:01:46 +0000 Subject: [PATCH] Bug 1448: Merged development branch (r14778:HEAD) with the trunk --- .gitattributes | 1 - CEP/pyparmdb/src/CMakeLists.txt | 9 +- CMake/LofarMacros.cmake | 14 +- CMake/LofarPackage.cmake | 9 +- CMake/LofarPackageVersion.cmake | 106 +++--- CMake/MACAddProtocol.cmake | 4 + CMake/MakePackageVersion.cmake | 267 +++++++++++++++ CMake/MakePackageVersion.cmake.in | 222 +++++++++++++ CMake/UpdatePackageVersion.cmake.in | 222 +++++++++++++ CMake/makeversion | 312 ------------------ LCS/Common/src/CMakeLists.txt | 3 + LCS/pyparameterset/src/CMakeLists.txt | 12 +- LCS/pyparameterset/src/pyparameterset.cc | 2 +- .../src/CTStartDaemon/CTStartDaemon.cc | 2 +- MAC/APL/CUDaemons/src/LogClient/LogClient.cc | 2 +- .../src/ServiceBroker/ServiceBroker.cc | 2 +- MAC/APL/PAC/Beam_Server/src/BeamServer.cc | 2 +- MAC/APL/PAC/Cal_Server/src/CalServer.cc | 2 +- MAC/APL/PIC/RSP_Driver/src/RSPDriver.cc | 2 +- RTCP/CNProc/src/CN_Processing_main.cc | 2 - RTCP/IONProc/src/ION_main.cc | 4 +- RTCP/Storage/src/Storage_main.cc | 3 - 22 files changed, 802 insertions(+), 402 deletions(-) create mode 100644 CMake/MakePackageVersion.cmake create mode 100644 CMake/MakePackageVersion.cmake.in create mode 100644 CMake/UpdatePackageVersion.cmake.in delete mode 100755 CMake/makeversion diff --git a/.gitattributes b/.gitattributes index b80dcc34041..349ca24e53b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -172,7 +172,6 @@ CMake/FindCPPLapack.cmake -text CMake/FindWCSLIB.cmake -text CMake/TODO -text CMake/makeCMakeCache -text -CMake/makeversion -text CMake/variants/variants.bgfen0 -text CMake/variants/variants.kis001 -text CMake/variants/variants.lfe001 -text diff --git a/CEP/pyparmdb/src/CMakeLists.txt b/CEP/pyparmdb/src/CMakeLists.txt index 5508430cf7e..7ed23a52b44 100644 --- a/CEP/pyparmdb/src/CMakeLists.txt +++ b/CEP/pyparmdb/src/CMakeLists.txt @@ -2,10 +2,9 @@ include(LofarPackageVersion) -# Create symbolic link to include directory. -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME}) +# Add current build directory to the include path. This is needed, because +# pyparmdb.cc #include's Package__Version.cc (yucky!). +include_directories(${CMAKE_CURRENT_BINARY_DIR}) lofar_add_library(_parmdb MODULE pyparmdb.cc) set_target_properties(_parmdb PROPERTIES @@ -18,6 +17,8 @@ set_target_properties(_parmdb PROPERTIES install(TARGETS _parmdb DESTINATION ${PYTHON_INSTALL_DIR}/lofar/parmdb) +# Dummy library, needed because lofar_add_executable() takes its dependencies +# from libraries added with lofar_add_library() (see bug #1430) lofar_add_library(lofar_pyparmdb Package__Version.cc) lofar_add_bin_program(versionpyparmdb versionpyparmdb.cc) diff --git a/CMake/LofarMacros.cmake b/CMake/LofarMacros.cmake index 54ce9d0f8fe..c2cbb528c7f 100644 --- a/CMake/LofarMacros.cmake +++ b/CMake/LofarMacros.cmake @@ -113,6 +113,8 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED) # Furthermore: # - Set the link dependencies of this executable on other LOFAR libraries # using the information in ${PACKAGE_NAME}_LIBRARIES. + # - Add a dependency of the executable on the PackageVersion target of the + # current package; it has no effect if LofarPackageVersion is not included. # - Add a dependency of the current package on this executable. # # Note: since the libraries of the current package already have all their @@ -123,6 +125,7 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED) add_executable(${_name} ${ARGN}) get_property(_libs GLOBAL PROPERTY ${PACKAGE_NAME}_LIBRARIES) target_link_libraries(${_name} ${_libs}) + add_dependencies(${_name} ${PACKAGE_NAME}_PackageVersion) add_dependencies(${PACKAGE_NAME} ${_name}) endmacro(lofar_add_executable _name) @@ -132,12 +135,14 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED) # # Add a library like add_library() does. # Furthermore: - # - add the library to the list of libraries for the current package + # - Add the library to the list of libraries for the current package # (global property ${PACKAGE_NAME}_LIBRARIES). - # - set the link dependencies of this library on other LOFAR libraries + # - Set the link dependencies of this library on other LOFAR libraries # using the information in ${PACKAGE_NAME}_DEPENDENCIES. - # - mark the library for install into LOFAR_LIBDIR. - # - add a dependency of the current package on the library. + # - Mark the library for install into LOFAR_LIBDIR. + # - Add a dependency of the library on the PackageVersion target of the + # current package; it has no effect if LofarPackageVersion is not included. + # - Add a dependency of the current package on the library. # # Note: link dependencies are determined by examining the link dependencies # of the libraries in the LOFAR packages that the current package depends @@ -159,6 +164,7 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED) # VERSION ${${PACKAGE_NAME}_VERSION} # OUTPUT_NAME lofar_${_name}) install(TARGETS ${_name} DESTINATION ${LOFAR_LIBDIR}) + add_dependencies(${_name} ${PACKAGE_NAME}_PackageVersion) add_dependencies(${PACKAGE_NAME} ${_name}) endmacro(lofar_add_library _name) diff --git a/CMake/LofarPackage.cmake b/CMake/LofarPackage.cmake index 7f8fcb68912..a6a39cd4f92 100644 --- a/CMake/LofarPackage.cmake +++ b/CMake/LofarPackage.cmake @@ -118,8 +118,10 @@ if(NOT LOFAR_PACKAGE_INCLUDED) # Define a LOFAR package. # # This macro sets the following variables: - # ${pkg}_VERSION Version number of package <pkg> - # ${pkg}_DEPENDENCIES List of packages that package <pkg> depends on. + # ${pkg}_VERSION Version number of package <pkg> + # PACKAGE_VERSION (idem) + # ${pkg}_DEPENDENCIES List of packages that package <pkg> depends on. + # PACKAGE_DEPENDENCIES (idem) # # Each dependent package is added to the build. If any of these packages is # excluded from the build (e.g., because BUILD_<dep> is OFF), then package @@ -157,6 +159,9 @@ if(NOT LOFAR_PACKAGE_INCLUDED) endif(${_pkg}_DEPENDENCIES MATCHES "^$") endif(_depends MATCHES "^.+$") + set(PACKAGE_VERSION ${${_pkg}_VERSION}) + set(PACKAGE_DEPENDENCIES ${${_pkg}_DEPENDENCIES}) + if(LOFAR_VERBOSE_CONFIGURE) message(STATUS " ${_pkg} version: ${${_pkg}_VERSION}") message(STATUS " ${_pkg} dependencies: ${${_pkg}_DEPENDENCIES}") diff --git a/CMake/LofarPackageVersion.cmake b/CMake/LofarPackageVersion.cmake index f030c41b65d..9f5c1fcb02d 100644 --- a/CMake/LofarPackageVersion.cmake +++ b/CMake/LofarPackageVersion.cmake @@ -1,63 +1,53 @@ -# Include useful macros -include(LofarMacros) +# - Generate CMake script to create/update LOFAR package version information. +# +# This script generates a CMake script file UpdatePackageVersion.cmake that is +# used in the custom target <pkg>_PackageVersion to create or update the +# source files Package__Version.h, Package__Version.cc and version<pkg>.cc, +# which provide version information about the current LOFAR package. The +# custom target is considered to be always out-of-date, so that it will be +# rebuilt with each invocation of 'make'. It collects version information from +# the Subversion repository, using 'svn info' and 'svn status'. This is +# information is then used to create or update the files Package__Version.h +# Package__Version.cc and version<pkg>.cc, if necessary. +# +# NOTE: you still have to add these sources manually as argument to +# add_library() or add_executable(). +# +# See also UpdatePackageVersion.cmake.in -# First check to see whether we need to update our CMakeLists.txt files. +# $Id$ +# +# Copyright (C) 2010 +# ASTRON (Netherlands Foundation for Research in Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# Generate version program source file -execute_process(COMMAND ${CMAKE_MODULE_PATH}/makeversion - WORKING_DIRECTORY ${PACKAGE_SOURCE_DIR} - RESULT_VARIABLE result) -if(result) - message(SEND_ERROR "makeversion failed!") -endif(result) +configure_file( + ${LOFAR_ROOT}/CMake/UpdatePackageVersion.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/UpdatePackageVersion.cmake @ONLY) -# Create/update FillPackage__VersionInc.h. Avoid unnecessary recompilations: -# first create a temporary file; only copy it if files are different. -set(_file "${CMAKE_CURRENT_BINARY_DIR}/FillPackage__VersionInc.h") -file(WRITE "${_file}.tmp" - "/* Generated by CMake for project ${PACKAGE_NAME} */\n\n") -foreach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) - # This hack is for MAC packages, which follow different naming conventions. - if(DEFINED ${dep}_INCLUDE_PATH_SUFFIX) - set(include_path ${${dep}_INCLUDE_PATH_SUFFIX}) - else() - set(include_path ${dep}) - endif(DEFINED ${dep}_INCLUDE_PATH_SUFFIX) - file(APPEND "${_file}.tmp" - "#include <${include_path}/Package__Version.h>\n") -endforeach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) -execute_process(COMMAND ${CMAKE_COMMAND} -E - copy_if_different "${_file}.tmp" "${_file}") +add_custom_target(${PACKAGE_NAME}_PackageVersion # ALL + COMMAND ${CMAKE_COMMAND} + ARGS -P ${CMAKE_CURRENT_BINARY_DIR}/UpdatePackageVersion.cmake) -# Create/update FillPackage__VersionFunc.h. Avoid unnecessary recompilations: -# first create a temporary file; only copy it if files are different. -lofar_get_hostname(hostname) -set(_file "${CMAKE_CURRENT_BINARY_DIR}/FillPackage__VersionFunc.h") -file(WRITE "${_file}.tmp" - "/* Generated by CMake for project ${PACKAGE_NAME} */\n\n" - "namespace LOFAR {\n" - " std::string ${PACKAGE_NAME}Version::getBuildTime()\n" - " { return std::string(__DATE__) + \" \" + std::string(__TIME__); }\n" - " std::string ${PACKAGE_NAME}Version::getBuildUser()\n" - " { return \"$ENV{USER}\"; }\n" - " std::string ${PACKAGE_NAME}Version::getBuildMachine()\n" - " { return \"${hostname}\"; }\n" - " void ${PACKAGE_NAME}Version::fillInfo\n" - " (int level, std::vector<Version::PkgInfo>& vec)\n" - " {\n" - " // Add info of this package if needed.\n" - " vec.push_back (Version::PkgInfo(level, &getInfo));\n" - " // Add info of packages being used.\n") -foreach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) - file(APPEND "${_file}.tmp" - " ${dep}Version::fillInfo (level+1, vec);\n") -endforeach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) -file(APPEND "${_file}.tmp" - " }\n" - "}\n") -execute_process(COMMAND ${CMAKE_COMMAND} -E - copy_if_different "${_file}.tmp" "${_file}") +# Mark files Package__Version.cc and version<pkg>.cc as generated; +# otherwise CMake will complain it cannot find the source files. +string(TOLOWER ${PACKAGE_NAME} _lpkg) +set_source_files_properties(Package__Version.cc version${_lpkg}.cc + PROPERTIES GENERATED ON) -# Add current binary directory to compiler's include path, so that the -# generated header files can be found during compilation. -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# Add the path to the generated file Package__Version.h to the include path. +include_directories(${CMAKE_BINARY_DIR}/include/Package__Version) diff --git a/CMake/MACAddProtocol.cmake b/CMake/MACAddProtocol.cmake index 64d7eb5ec64..07235978500 100644 --- a/CMake/MACAddProtocol.cmake +++ b/CMake/MACAddProtocol.cmake @@ -66,4 +66,8 @@ macro(mac_add_protocol _protocol _templ_dir) ARGS -E copy "${_cxx_hdr}" "${_dest_dir}/${_cxx_hdr}" DEPENDS "${_proto_file}") + # Due to inconsistent use of include path prefixes in #include's, we must + # also add the current build directory to the -I path. + include_directories(${CMAKE_CURRENT_BINARY_DIR}) + endmacro(mac_add_protocol _protocol _templ_dir) diff --git a/CMake/MakePackageVersion.cmake b/CMake/MakePackageVersion.cmake new file mode 100644 index 00000000000..b1be50d4f10 --- /dev/null +++ b/CMake/MakePackageVersion.cmake @@ -0,0 +1,267 @@ +# - Create/update the LOFAR package version information source files. +# +# Create or update the files Package__Version.h, Package__Version.cc and +# version<package>.cc files, which provide detailed information on the +# version of a LOFAR package and its dependent packages. +# +# This file should be used as input for a custom target that triggers the +# update of the source files that provide the package's version information. + +# $Id$ +# +# Copyright (C) 2010 +# ASTRON (Netherlands Foundation for Research in Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +include(LofarMacros) + +message(STATUS "Generating package version information source files ...") + +set(_pkg ${PACKAGE_NAME}) +string(TOLOWER ${_pkg} _lpkg) +string(TOUPPER ${_pkg} _upkg) + +set(_cvers "Unknown") +set(_rvers "Unknown") +set(_grev "Unknown") +set(_lrev "Unknown") +set(_nrch "Unknown") + +if(${_pkg}_VERSION) + set(_cvers ${${_pkg}_VERSION}) +endif(${_pkg}_VERSION) + +# Get version and revision (if possible) from repository. +set(_svn_tmp "${PACKAGE_BINARY_DIR}/version.svn.tmp") +execute_process(COMMAND svn info ${PACKAGE_SOURCE_DIR} + RESULT_VARIABLE _result + OUTPUT_FILE "${_svn_tmp}" + ERROR_VARIABLE _error + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE) +if(_result) + message(SEND_ERROR "${_error}") +else(_result) + # Get version. + # It should look like trunk/package or tags/package-version/package + file(STRINGS "${_svn_tmp}" _url REGEX "^URL:") + string(REGEX REPLACE "^URL: *(.*)$" "\\1" _url "${_url}") + file(STRINGS "${_svn_tmp}" _root REGEX "^Repository Root:") + string(REGEX REPLACE "^Repository Root: *(.*)$" "\\1" _root "${_root}") + string(REGEX REPLACE "${_root}" "" _rvers "${_url}") + if(_rvers MATCHES "^/trunk/") + set(_rvers "trunk") + elseif(_rvers MATCHES "^/tags/" OR _rvers MATCHES "^/branches/") + # We have a task branch (for a bug) or a release branch. + # Remove all but version and replace _ in version by . + string(REGEX REPLACE "^/[^/]*/([^/]*)/.*$" "\\1" _rvers "${_rvers}") + # set(_rvers "LCS-Common-3_0-release-branch") + # set(_rvers "MAC-GCF-6_1rc1") + # set(_rvers "CEP-CEPFrame-Bug768-task-branch") + # set(_rvers "LCS-APS-Bug833-premerge1") + if(_rvers MATCHES "-Bug[0-9]+-") # This is a task tag/branch + string(REGEX REPLACE "^.*-(Bug[0-9]+)-.*$" "\\1" _rvers "${_rvers}") + else(_rvers MATCHES "-Bug[0-9]+-") # This is a release tag/branch + string(REGEX REPLACE "^.*-([0-9]+)_([0-9]+[^-]*).*$" "\\1.\\2" + _rvers "${_rvers}") + endif(_rvers MATCHES "-Bug[0-9]+-") + endif(_rvers MATCHES "^/trunk/") + # Get revision. + file(STRINGS "${_svn_tmp}" _grev REGEX "^Revision:") + string(REGEX REPLACE "^Revision: *(.*)$" "\\1" _grev "${_grev}") + file(STRINGS "${_svn_tmp}" _lrev REGEX "^Last Changed Rev:") + string(REGEX REPLACE "^Last Changed Rev: *(.*)$" "\\1" _lrev "${_lrev}") + # Count the number of locally added/deleted/modified/replaced files. + execute_process(COMMAND svn status -q ${PACKAGE_SOURCE_DIR} + COMMAND grep -c "^[ADMR]" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _nrch + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Removed temporary file + file(REMOVE "${_svn_tmp}") +endif(_result) + +message(STATUS "_cvers=${_cvers}") +message(STATUS "_rvers=${_rvers}") +message(STATUS "_grev=${_grev}") +message(STATUS "_lrev=${_lrev}") +message(STATUS "_nrch=${_nrch}") + +message(STATUS "_pkg=${_pkg}") +message(STATUS "${_pkg}_INCLUDE_PATH_SUFFIX=${${_pkg}_INCLUDE_PATH_SUFFIX}") + +# Create/update Package__Version.h. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "${CMAKE_BINARY_DIR}/include/Package__Version/${_pkg}/Package__Version.h") +file(WRITE "${_file}.tmp" + "//# Get revision info; generated by MakePackageVersion.cmake\n" + "\n" + "#ifndef LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "#define LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "\n" + "#include <Common/Version.h>\n" + "\n" + "// Class to get the version (revision) of the package and the packages it uses.\n" + "namespace LOFAR {\n" + " class ${_pkg}Version\n" + " {\n" + " public:\n" + " // Get the info for this package.\n" + " static Version getInfo();\n" + "\n" + " // Get the version number of the package (as given in repository).\n" + " static std::string getVersion();\n" + " // Get the svn version number of the package according to CMakeLists.txt.\n" + " static std::string getConfVersion();\n" + " // Get the global revision number of the package.\n" + " static std::string getRevision();\n" + " // Get the local revision number of the package.\n" + " static std::string getPackageRevision();\n" + " // Get the number of files differing from repository.\n" + " // Usually this is blank, but it can tell the nr of changed files.\n" + " static std::string getNrChangedFiles();\n" + " // Get the date/time the package was built (in fact, configured).\n" + " static std::string getBuildTime();\n" + " // Get the name of the user who built the package.\n" + " static std::string getBuildUser();\n" + " // Get the machine the package was built on.\n" + " static std::string getBuildMachine();\n" + "\n" + " // Append the vector with the vinfo of this package and used packages.\n" + " static void fillInfo (int level,\n" + " std::vector<Version::PkgInfo>& vec);\n" + " };\n" + "}\n" + "\n" + "#endif\n") +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update Package__Version.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "${CMAKE_CURRENT_BINARY_DIR}/Package__Version.cc") +file(WRITE "${_file}.tmp" + "//# Get revision info; generated by MakePackageVersion.cmake\n" + "\n" + "//## pkg=${_pkg}\n" + "//## incpath=${incpath}\n" + "//## incdir=${incdir}\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n" + "#include \"FillPackage__VersionInc.h\"\n" + "\n" + "namespace LOFAR {\n" + " Version ${_pkg}Version::getInfo()\n" + " {\n" + " return Version (\"${_pkg}\",\n" + " getVersion(), getConfVersion(),\n" + " getRevision(), getPackageRevision(),\n" + " getNrChangedFiles(),\n" + " getBuildTime(), getBuildUser(), getBuildMachine());\n" + " }\n" + "\n" + " std::string ${_pkg}Version::getVersion()\n" + " { return \"${_rvers}\"; }\n" + " std::string ${_pkg}Version::getConfVersion()\n" + " { return \"${_cvers}\"; }\n" + " std::string ${_pkg}Version::getRevision()\n" + " { return \"${_grev}\"; }\n" + " std::string ${_pkg}Version::getPackageRevision()\n" + " { return \"${_lrev}\"; }\n" + " std::string ${_pkg}Version::getNrChangedFiles()\n" + " { return \"${_nrch}\"; }\n" + "}\n" + "\n" + "//# FillPackage__VersionFunc.h is generated in the build area by\n" + "//# LofarPackageVersion.cmake. It contains function fillInfo.\n" + "#include \"FillPackage__VersionFunc.h\"\n") +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update version<pkg>.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "${CMAKE_CURRENT_BINARY_DIR}/version${_lpkg}.cc") +file(WRITE "${_file}.tmp" + "//# Print revision info; generated by MakePackageVersion.cmake\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n" + "#include <iostream>\n" + "\n" + "using namespace LOFAR;\n" + "\n" + "int main (int argc, const char* argv[])\n" + "{\n" + " std::string type = \"brief\";\n" + " if (argc > 1) {\n" + " type = argv[1];\n" + " }\n" + " Version::show<${_pkg}Version> (std::cout, \"${_pkg}\", type);\n" + " return 0;\n" + "}\n") +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update FillPackage__VersionInc.h. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "${CMAKE_CURRENT_BINARY_DIR}/FillPackage__VersionInc.h") +file(WRITE "${_file}.tmp" + "/* Generated by CMake for project ${PACKAGE_NAME} */\n\n") +foreach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) + # This hack is for MAC packages, which follow different naming conventions. + if(DEFINED ${dep}_INCLUDE_PATH_SUFFIX) + set(include_path ${${dep}_INCLUDE_PATH_SUFFIX}) + else() + set(include_path ${dep}) + endif(DEFINED ${dep}_INCLUDE_PATH_SUFFIX) + file(APPEND "${_file}.tmp" + "#include <${include_path}/Package__Version.h>\n") +endforeach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update FillPackage__VersionFunc.h. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +lofar_get_hostname(hostname) +set(_file "${CMAKE_CURRENT_BINARY_DIR}/FillPackage__VersionFunc.h") +file(WRITE "${_file}.tmp" + "/* Generated by CMake for project ${PACKAGE_NAME} */\n\n" + "namespace LOFAR {\n" + " std::string ${PACKAGE_NAME}Version::getBuildTime()\n" + " { return std::string(__DATE__) + \" \" + std::string(__TIME__); }\n" + " std::string ${PACKAGE_NAME}Version::getBuildUser()\n" + " { return \"$ENV{USER}\"; }\n" + " std::string ${PACKAGE_NAME}Version::getBuildMachine()\n" + " { return \"${hostname}\"; }\n" + " void ${PACKAGE_NAME}Version::fillInfo\n" + " (int level, std::vector<Version::PkgInfo>& vec)\n" + " {\n" + " // Add info of this package if needed.\n" + " vec.push_back (Version::PkgInfo(level, &getInfo));\n" + " // Add info of packages being used.\n") +foreach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) + file(APPEND "${_file}.tmp" + " ${dep}Version::fillInfo (level+1, vec);\n") +endforeach(dep ${${PACKAGE_NAME}_DEPENDENCIES}) +file(APPEND "${_file}.tmp" + " }\n" + "}\n") +execute_process(COMMAND ${CMAKE_COMMAND} -E + copy_if_different "${_file}.tmp" "${_file}") + +include_directories(${CMAKE_BINARY_DIR}/include/Package__Version) diff --git a/CMake/MakePackageVersion.cmake.in b/CMake/MakePackageVersion.cmake.in new file mode 100644 index 00000000000..7225b6fac33 --- /dev/null +++ b/CMake/MakePackageVersion.cmake.in @@ -0,0 +1,222 @@ +# - Create/update the LOFAR package version information source files. +# +# Create or update the files Package__Version.h, Package__Version.cc and +# version<package>.cc files, which provide detailed information on the +# version of a LOFAR package and its dependent packages. +# +# This file will be configured by LofarPackageVersion.cmake. The configured +# file will then be used as a CMake script in a custom target (also created by +# LofarPackageVersion.cmake) that's considered to be always out-of-date, thus +# triggering an update of the version information with each 'make'. + +# $Id: UpdatePackageVersion.cmake 14806 2010-01-15 11:26:13Z loose $ +# +# Copyright (C) 2010 +# ASTRON (Netherlands Foundation for Research in Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Initialize variables +set(_cvers "Unknown") +set(_rvers "Unknown") +set(_grev "Unknown") +set(_lrev "Unknown") +set(_nrch "Unknown") +set(_pkg @PACKAGE_NAME@) +if("@PACKAGE_VERSION@" MATCHES ".+") + set(_cvers @PACKAGE_VERSION@) +endif("@PACKAGE_VERSION@" MATCHES ".+") +string(TOLOWER ${_pkg} _lpkg) +string(TOUPPER ${_pkg} _upkg) + +#message(STATUS "Updating version info for package ${_pkg}") + +# Retrieve version and revision information from the repository, using +# 'svn info' and 'svn status' +set(_svn_tmp "@PACKAGE_BINARY_DIR@/version.svn.tmp") +execute_process(COMMAND svn info @PACKAGE_SOURCE_DIR@ + RESULT_VARIABLE _result + OUTPUT_FILE "${_svn_tmp}" + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _error + ERROR_STRIP_TRAILING_WHITESPACE) +if(_result) + message(SEND_ERROR "${_error}") +else(_result) + # Get version. + # It should look like trunk/package or tags/package-version/package + file(STRINGS "${_svn_tmp}" _url REGEX "^URL:") + string(REGEX REPLACE "^URL: *(.*)$" "\\1" _url "${_url}") + file(STRINGS "${_svn_tmp}" _root REGEX "^Repository Root:") + string(REGEX REPLACE "^Repository Root: *(.*)$" "\\1" _root "${_root}") + string(REGEX REPLACE "${_root}" "" _rvers "${_url}") + if(_rvers MATCHES "^/trunk/") + set(_rvers "trunk") + elseif(_rvers MATCHES "^/tags/" OR _rvers MATCHES "^/branches/") + # We have a task branch (for a bug) or a release branch. + # Remove all but version and replace _ in version by . + string(REGEX REPLACE "^/[^/]*/([^/]*)/.*$" "\\1" _rvers "${_rvers}") + # set(_rvers "LCS-Common-3_0-release-branch") + # set(_rvers "MAC-GCF-6_1rc1") + # set(_rvers "CEP-CEPFrame-Bug768-task-branch") + # set(_rvers "LCS-APS-Bug833-premerge1") + if(_rvers MATCHES "-Bug[0-9]+-") # This is a task tag/branch + string(REGEX REPLACE "^.*-(Bug[0-9]+)-.*$" "\\1" _rvers "${_rvers}") + else(_rvers MATCHES "-Bug[0-9]+-") # This is a release tag/branch + string(REGEX REPLACE "^.*-([0-9]+)_([0-9]+[^-]*).*$" "\\1.\\2" + _rvers "${_rvers}") + endif(_rvers MATCHES "-Bug[0-9]+-") + endif(_rvers MATCHES "^/trunk/") + # Get revision. + file(STRINGS "${_svn_tmp}" _grev REGEX "^Revision:") + string(REGEX REPLACE "^Revision: *(.*)$" "\\1" _grev "${_grev}") + file(STRINGS "${_svn_tmp}" _lrev REGEX "^Last Changed Rev:") + string(REGEX REPLACE "^Last Changed Rev: *(.*)$" "\\1" _lrev "${_lrev}") + # Count the number of locally added/deleted/modified/replaced files. + execute_process(COMMAND svn status -q @PACKAGE_SOURCE_DIR@ + COMMAND grep -c "^[ADMR]" + OUTPUT_VARIABLE _nrch + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Removed temporary file + file(REMOVE "${_svn_tmp}") +endif(_result) + +# Create/update Package__Version.h. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_BINARY_DIR@/include/Package__Version/${_pkg}/Package__Version.h") +file(WRITE "${_file}.tmp" + "//# Get revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#ifndef LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "#define LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "\n" + "#include <Common/Version.h>\n" + "\n" + "// Class to get the version (revision) of the package and the packages it uses.\n" + "namespace LOFAR {\n" + " class ${_pkg}Version\n" + " {\n" + " public:\n" + " // Get the info for this package.\n" + " static Version getInfo();\n" + "\n" + " // Get the version number of the package (as given in repository).\n" + " static std::string getVersion();\n" + " // Get the svn version number of the package according to CMakeLists.txt.\n" + " static std::string getConfVersion();\n" + " // Get the global revision number of the package.\n" + " static std::string getRevision();\n" + " // Get the local revision number of the package.\n" + " static std::string getPackageRevision();\n" + " // Get the number of files differing from repository.\n" + " // Usually this is blank, but it can tell the nr of changed files.\n" + " static std::string getNrChangedFiles();\n" + " // Get the date/time the package was built (in fact, configured).\n" + " static std::string getBuildTime();\n" + " // Get the name of the user who built the package.\n" + " static std::string getBuildUser();\n" + " // Get the machine the package was built on.\n" + " static std::string getBuildMachine();\n" + "\n" + " // Append the vector with the vinfo of this package and used packages.\n" + " static void fillInfo (int level,\n" + " std::vector<Version::PkgInfo>& vec);\n" + " };\n" + "}\n" + "\n" + "#endif\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update Package__Version.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_CURRENT_BINARY_DIR@/Package__Version.cc") +file(WRITE "${_file}.tmp" + "//# Get revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n") +foreach(_dep @PACKAGE_DEPENDENCIES@) + file(APPEND "${_file}.tmp" + "#include <${_dep}/Package__Version.h>\n") +endforeach(_dep @PACKAGE_DEPENDENCIES@) +file(APPEND "${_file}.tmp" + "\n" + "namespace LOFAR {\n" + " Version ${_pkg}Version::getInfo()\n" + " {\n" + " return Version (\"${_pkg}\",\n" + " getVersion(), getConfVersion(),\n" + " getRevision(), getPackageRevision(),\n" + " getNrChangedFiles(),\n" + " getBuildTime(), getBuildUser(), getBuildMachine());\n" + " }\n" + "\n" + " std::string ${_pkg}Version::getVersion()\n" + " { return \"${_rvers}\"; }\n" + " std::string ${_pkg}Version::getConfVersion()\n" + " { return \"${_cvers}\"; }\n" + " std::string ${_pkg}Version::getRevision()\n" + " { return \"${_grev}\"; }\n" + " std::string ${_pkg}Version::getPackageRevision()\n" + " { return \"${_lrev}\"; }\n" + " std::string ${_pkg}Version::getNrChangedFiles()\n" + " { return \"${_nrch}\"; }\n" + " std::string ${_pkg}Version::getBuildTime()\n" + " { return std::string(__DATE__) + \" \" + std::string(__TIME__); }\n" + " std::string ${_pkg}Version::getBuildUser()\n" + " { return \"$ENV{USER}\"; }\n" + " std::string ${_pkg}Version::getBuildMachine()\n" + " { return \"$ENV{HOST}\"; }\n" + " void ${_pkg}Version::fillInfo\n" + " (int level, std::vector<Version::PkgInfo>& vec)\n" + " {\n" + " // Add info of this package if needed.\n" + " vec.push_back (Version::PkgInfo(level, &getInfo));\n" + " // Add info of packages being used.\n") +foreach(_dep @PACKAGE_DEPENDENCIES@) + file(APPEND "${_file}.tmp" + " ${_dep}Version::fillInfo (level+1, vec);\n") +endforeach(_dep @PACKAGE_DEPENDENCIES@) +file(APPEND "${_file}.tmp" + " }\n" + "}\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") + +# Create/update version<pkg>.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_CURRENT_BINARY_DIR@/version${_lpkg}.cc") +file(WRITE "${_file}.tmp" + "//# Print revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n" + "#include <iostream>\n" + "\n" + "using namespace LOFAR;\n" + "\n" + "int main (int argc, const char* argv[])\n" + "{\n" + " std::string type = \"brief\";\n" + " if (argc > 1) {\n" + " type = argv[1];\n" + " }\n" + " Version::show<${_pkg}Version> (std::cout, \"${_pkg}\", type);\n" + " return 0;\n" + "}\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") diff --git a/CMake/UpdatePackageVersion.cmake.in b/CMake/UpdatePackageVersion.cmake.in new file mode 100644 index 00000000000..dc15f36860f --- /dev/null +++ b/CMake/UpdatePackageVersion.cmake.in @@ -0,0 +1,222 @@ +# - Template for a CMake script to update LOFAR package version information. +# +# Template file for the UpdatePackageVersion.cmake macro that is used to +# create or update the files Package__Version.h, Package__Version.cc and +# version<package>.cc, which provide detailed information about the version of +# a LOFAR package and its dependent packages. +# +# This file will be configured by LofarPackageVersion.cmake. The configured +# file will then be used as a CMake script in a custom target (also created by +# LofarPackageVersion.cmake) that's considered to be always out-of-date, thus +# triggering an update of the version information with each 'make'. +# +# See also LofarPackageVersion.cmake + +# $Id: UpdatePackageVersion.cmake 14806 2010-01-15 11:26:13Z loose $ +# +# Copyright (C) 2010 +# ASTRON (Netherlands Foundation for Research in Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Initialize variables +set(_cvers "Unknown") +set(_rvers "Unknown") +set(_grev "Unknown") +set(_lrev "Unknown") +set(_nrch "Unknown") +set(_pkg @PACKAGE_NAME@) +if("@PACKAGE_VERSION@" MATCHES ".+") + set(_cvers @PACKAGE_VERSION@) +endif("@PACKAGE_VERSION@" MATCHES ".+") +string(TOLOWER ${_pkg} _lpkg) +string(TOUPPER ${_pkg} _upkg) + +# Retrieve version and revision information from the repository, using +# 'svn info' and 'svn status' +set(_svn_tmp "@PACKAGE_BINARY_DIR@/version.svn.tmp") +execute_process(COMMAND svn info @PACKAGE_SOURCE_DIR@ + RESULT_VARIABLE _result + OUTPUT_FILE "${_svn_tmp}" + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _error + ERROR_STRIP_TRAILING_WHITESPACE) +if(_result) + message(SEND_ERROR "${_error}") +else(_result) + # Get version. + # It should look like trunk/package or tags/package-version/package + file(STRINGS "${_svn_tmp}" _url REGEX "^URL:") + string(REGEX REPLACE "^URL: *(.*)$" "\\1" _url "${_url}") + file(STRINGS "${_svn_tmp}" _root REGEX "^Repository Root:") + string(REGEX REPLACE "^Repository Root: *(.*)$" "\\1" _root "${_root}") + string(REGEX REPLACE "${_root}" "" _rvers "${_url}") + if(_rvers MATCHES "^/trunk/") + set(_rvers "trunk") + elseif(_rvers MATCHES "^/tags/" OR _rvers MATCHES "^/branches/") + # We have a task branch (for a bug) or a release branch. + # Remove all but version and replace _ in version by . + string(REGEX REPLACE "^/[^/]*/([^/]*)/.*$" "\\1" _rvers "${_rvers}") + if(_rvers MATCHES "-Bug[0-9]+-") # This is a task tag/branch + string(REGEX REPLACE "^.*-(Bug[0-9]+)-.*$" "\\1" _rvers "${_rvers}") + else(_rvers MATCHES "-Bug[0-9]+-") # This is a release tag/branch + string(REGEX REPLACE "^.*-([0-9]+)_([0-9]+[^-]*).*$" "\\1.\\2" + _rvers "${_rvers}") + endif(_rvers MATCHES "-Bug[0-9]+-") + endif(_rvers MATCHES "^/trunk/") + # Get revision. + file(STRINGS "${_svn_tmp}" _grev REGEX "^Revision:") + string(REGEX REPLACE "^Revision: *(.*)$" "\\1" _grev "${_grev}") + file(STRINGS "${_svn_tmp}" _lrev REGEX "^Last Changed Rev:") + string(REGEX REPLACE "^Last Changed Rev: *(.*)$" "\\1" _lrev "${_lrev}") + # Count the number of locally added/deleted/modified/replaced files. + execute_process(COMMAND svn status -q @PACKAGE_SOURCE_DIR@ + COMMAND grep -c "^[ADMR]" + OUTPUT_VARIABLE _nrch + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Removed temporary file + file(REMOVE "${_svn_tmp}") +endif(_result) + +# Create/update Package__Version.h. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_BINARY_DIR@/include/Package__Version/${_pkg}/Package__Version.h") +file(WRITE "${_file}.tmp" + "//# Get revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#ifndef LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "#define LOFAR_${_upkg}_PACKAGE__VERSION_H\n" + "\n" + "#include <Common/Version.h>\n" + "\n" + "// Class to get the version (revision) of the package and the packages it uses.\n" + "namespace LOFAR {\n" + " class ${_pkg}Version\n" + " {\n" + " public:\n" + " // Get the info for this package.\n" + " static Version getInfo();\n" + "\n" + " // Get the version number of the package (as given in repository).\n" + " static std::string getVersion();\n" + " // Get the svn version number of the package according to CMakeLists.txt.\n" + " static std::string getConfVersion();\n" + " // Get the global revision number of the package.\n" + " static std::string getRevision();\n" + " // Get the local revision number of the package.\n" + " static std::string getPackageRevision();\n" + " // Get the number of files differing from repository.\n" + " // Usually this is blank, but it can tell the nr of changed files.\n" + " static std::string getNrChangedFiles();\n" + " // Get the date/time the package was built (in fact, configured).\n" + " static std::string getBuildTime();\n" + " // Get the name of the user who built the package.\n" + " static std::string getBuildUser();\n" + " // Get the machine the package was built on.\n" + " static std::string getBuildMachine();\n" + "\n" + " // Append the vector with the vinfo of this package and used packages.\n" + " static void fillInfo (int level,\n" + " std::vector<Version::PkgInfo>& vec);\n" + " };\n" + "}\n" + "\n" + "#endif\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") +file(REMOVE "${_file}.tmp") + +# Create/update Package__Version.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_CURRENT_BINARY_DIR@/Package__Version.cc") +file(WRITE "${_file}.tmp" + "//# Get revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n") +foreach(_dep @PACKAGE_DEPENDENCIES@) + file(APPEND "${_file}.tmp" + "#include <${_dep}/Package__Version.h>\n") +endforeach(_dep @PACKAGE_DEPENDENCIES@) +file(APPEND "${_file}.tmp" + "\n" + "namespace LOFAR {\n" + " Version ${_pkg}Version::getInfo()\n" + " {\n" + " return Version (\"${_pkg}\",\n" + " getVersion(), getConfVersion(),\n" + " getRevision(), getPackageRevision(),\n" + " getNrChangedFiles(),\n" + " getBuildTime(), getBuildUser(), getBuildMachine());\n" + " }\n" + "\n" + " std::string ${_pkg}Version::getVersion()\n" + " { return \"${_rvers}\"; }\n" + " std::string ${_pkg}Version::getConfVersion()\n" + " { return \"${_cvers}\"; }\n" + " std::string ${_pkg}Version::getRevision()\n" + " { return \"${_grev}\"; }\n" + " std::string ${_pkg}Version::getPackageRevision()\n" + " { return \"${_lrev}\"; }\n" + " std::string ${_pkg}Version::getNrChangedFiles()\n" + " { return \"${_nrch}\"; }\n" + " std::string ${_pkg}Version::getBuildTime()\n" + " { return std::string(__DATE__) + \" \" + std::string(__TIME__); }\n" + " std::string ${_pkg}Version::getBuildUser()\n" + " { return \"$ENV{USER}\"; }\n" + " std::string ${_pkg}Version::getBuildMachine()\n" + " { return \"$ENV{HOST}\"; }\n" + " void ${_pkg}Version::fillInfo\n" + " (int level, std::vector<Version::PkgInfo>& vec)\n" + " {\n" + " // Add info of this package if needed.\n" + " vec.push_back (Version::PkgInfo(level, &getInfo));\n" + " // Add info of packages being used.\n") +foreach(_dep @PACKAGE_DEPENDENCIES@) + file(APPEND "${_file}.tmp" + " ${_dep}Version::fillInfo (level+1, vec);\n") +endforeach(_dep @PACKAGE_DEPENDENCIES@) +file(APPEND "${_file}.tmp" + " }\n" + "}\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") +file(REMOVE "${_file}.tmp") + +# Create/update version<pkg>.cc. Avoid unnecessary recompilations: +# first create a temporary file; only copy it if files are different. +set(_file "@CMAKE_CURRENT_BINARY_DIR@/version${_lpkg}.cc") +file(WRITE "${_file}.tmp" + "//# Print revision info for package ${_pkg}; generated by CMake\n" + "\n" + "#include <${_pkg}/Package__Version.h>\n" + "#include <Common/Version.h>\n" + "#include <iostream>\n" + "\n" + "using namespace LOFAR;\n" + "\n" + "int main (int argc, const char* argv[])\n" + "{\n" + " std::string type = \"brief\";\n" + " if (argc > 1) {\n" + " type = argv[1];\n" + " }\n" + " Version::show<${_pkg}Version> (std::cout, \"${_pkg}\", type);\n" + " return 0;\n" + "}\n") +execute_process(COMMAND @CMAKE_COMMAND@ -E + copy_if_different "${_file}.tmp" "${_file}") +file(REMOVE "${_file}.tmp") diff --git a/CMake/makeversion b/CMake/makeversion deleted file mode 100755 index a8d7c3ae8cd..00000000000 --- a/CMake/makeversion +++ /dev/null @@ -1,312 +0,0 @@ -#!/bin/sh - -# makeversion: create the version.cc file of a package -# -# Copyright (C) 2007-2009 -# ASTRON (Netherlands Foundation for Research in Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# $Id$ - -# This script creates files <package>Version.h and .cc containing a class -# to return the version and revision of the package. -# The .cc file includes a file which is created by LofarPackageVersion.cmake -# It also creates an file version<package>.cc which is an executable program -# to print the version. -# Optionally the CMakeLists.txt files are changed to build the code. -# Note: The CMakeLists.txt file of each leaf package must contain a line -# lofar_package(<package> [version] [DEPENDS <depend> [depend]]) -# for this to work. - -# The class name used is <package>Version, for eaxmple CommonVersion. -# makeversion retrieves the package name from the basename of the current -# directory which works fine for the normal cases. However, MAC uses some -# special directory structure like GCF/TM/include/GCF/TM. It also detects -# this and sets in this example the package name to GCFTM (removes the /). -# The package name given in lofar_package() has to match the package name -# found here, thus must be GCFTM in this example. - -# Trap handler -trap 'rm -f version.*.tmp; \ - trap - 0; \ - exit' 0 1 2 3 15 - -# Get the package name. -fpkg=`pwd` -pkg=`basename $fpkg` - -# No version info is needed (in fact, not possible) for Tools and pytools. -if [ "$pkg" = Tools -o "$pkg" = pytools ]; then - exit 0 -fi - -# If present, use the package name from the CMakeLists.txt file. -# It looks like: project (GCFProtocols ...) -tpkg=`sed -n 's,^[[:space:]]*[lL][oO][fF][aA][rR]_[pP][aA][cC][kK][aA][gG][eE][[:space:]]*([[:space:]]*\([^[:space:])]*\).*$,\1,p' CMakeLists.txt` -if test "$tpkg" != ""; then - pkg=$tpkg -fi - -# If the include directory exists, find the include path from the package's -# CMakeLists.txt. Otherwise header files are in src and <package> is the -# include path. -incdir=`sed -n 's,^[[:space:]]*[aA][dD][dD]_[sS][uU][bB][dD][iI][rR][eE][cC][tT][oO][rR][yY][[:space:]]*([[:space:]]*\(include/[^)]*\).*$,\1,p' CMakeLists.txt` -incpath="${incdir##include/}" -if test "$incdir" = ""; then - incdir=src - incpath=$pkg -fi - -# Check if source and include directory exist. If not, then it is probably not -# a package directory. -if ! [ -d src -a -d $incdir ]; then - echo "makeversion: no source or include directory found: " - echo " is this a package directory?" - exit 1 -fi - -# Get version and revision (if possible) from repository. -# Both the global revision and local one (i.e. last changed for this version). -cvers=Unknown -rvers=Unknown -grev=Unknown -lrev=Unknown -nrch=0 -svn info > version.svn.tmp 2>&1 -hassvn=$? -if [ $hassvn = 0 ]; then - # Get version. - # It should look like trunk/package or tags/package-version/package - rvers1=`fgrep 'URL: ' version.svn.tmp | sed -e 's%.*/LOFAR/%%'` - rvers=`echo $rvers1 | sed -e 's%/.*%%'` - if test "$rvers" = "tags" -o "$rvers" = "branches"; then - # We have a task branch (for a bug) or a release branch. - # Remove all but version and replace _ in version by . - rvers1=`echo $rvers1 | sed -e 's%^[^/]*/%%' -e 's%/.*%%'` - rvers=`echo $rvers1 | sed -e 's%-Bug[0-9]%%'` - if test "$rvers" = "$rvers1"; then - # No task branch, thus normal version number after the -. - rvers=`echo $rvers1 | sed -e 's%-release-.*%%' -e 's%.*-%%' -e 's%_%.%g'` - else - # Task branch, so extract from 'Bug' on. - rvers=`echo $rvers1 | sed -e 's%-task-.*%%' -e 's%.*-Bug%Bug%'` - fi - fi - # Get revision. - grev=`fgrep 'Revision: ' version.svn.tmp | sed -e 's/.*: *//'` - lrev=`fgrep 'Last Changed Rev: ' version.svn.tmp | sed -e 's/.*: *//'` - # Check if there are locally modified files (excluding CMakeLists.txt) - svn status | egrep '^M ' | fgrep -v CMakeLists.txt > version.svn.tmp 2>&1 - if [ $? ]; then - nrch=`wc -l version.svn.tmp | sed -e 's/^ *//' | sed -e 's/ .*//'` - fi -fi -# Get the version from the CMakeLists.txt. We'll assume (for the time being) -# that the project's CMakeLists.txt file contains a line like -# "lofad_package(<name> [version] [DEPENDS <depend> [depend]]) -cvers1=`sed -n 's,^[[:space:]]*[lL][oO][fF][aA][rR]_[pP][aA][cC][kK][aA][gG][eE][[:space:]]*([[:space:]]*[^[:space:]]*[[:space:]][[:space:]]*\([0-9.][0-9.]*\).*$,\1,p' CMakeLists.txt` -if [ "$cvers1" != "" ]; then - cvers=$cvers1 -fi - -# Get package name in lower and uppercase -lpkg=`echo $pkg | tr A-Z a-z` -upkg=`echo $pkg | tr a-z A-Z` - -# Create temporary version.h/cc -cat > version.h.tmp <<EOF -//# Get revision info; generated by CMake/makeversion - -#ifndef LOFAR_${upkg}_PACKAGE__VERSION_H -#define LOFAR_${upkg}_PACKAGE__VERSION_H - -#include <Common/Version.h> - -// Class to get the version (revision) of the package and the packages it uses. -namespace LOFAR { - class ${pkg}Version - { - public: - // Get the info for this package. - static Version getInfo(); - - // Get the version number of the package (as given in repository). - static std::string getVersion(); - // Get the svn version number of the package according to CMakeLists.txt. - static std::string getConfVersion(); - // Get the global revision number of the package. - static std::string getRevision(); - // Get the local revision number of the package. - static std::string getPackageRevision(); - // Get the number of files differing from repository. - // Usually this is blank, but it can tell the nr of changed files. - static std::string getNrChangedFiles(); - // Get the date/time the package was built (in fact, configured). - static std::string getBuildTime(); - // Get the name of the user who built the package. - static std::string getBuildUser(); - // Get the machine the package was built on. - static std::string getBuildMachine(); - - // Append the vector with the vinfo of this package and used packages. - static void fillInfo (int level, - std::vector<Version::PkgInfo>& vec); - }; -} - -#endif -EOF - -cat > version.cc.tmp <<EOF -//# Get revision info; generated by CMake/makeversion - -//## pkg=$pkg -//## incpath=$incpath -//## incdir=$incdir - -#include <${incpath}/Package__Version.h> -#include <Common/Version.h> -#include "FillPackage__VersionInc.h" - -namespace LOFAR { - Version ${pkg}Version::getInfo() - { - return Version ("${pkg}", - getVersion(), getConfVersion(), - getRevision(), getPackageRevision(), - getNrChangedFiles(), - getBuildTime(), getBuildUser(), getBuildMachine()); - } - - std::string ${pkg}Version::getVersion() - { return "$rvers"; } - std::string ${pkg}Version::getConfVersion() - { return "$cvers"; } - std::string ${pkg}Version::getRevision() - { return "$grev"; } - std::string ${pkg}Version::getPackageRevision() - { return "$lrev"; } - std::string ${pkg}Version::getNrChangedFiles() - { return "$nrch"; } -} - -//# FillPackage__VersionFunc.h is generated in the build area by -//# LofarPackageVersion.cmake. It contains function fillInfo. -#include "FillPackage__VersionFunc.h" -EOF - -cat > version.mcc.tmp <<EOF -//# Print revision info; generated by CMake/makeversion - -#include <${incpath}/Package__Version.h> -#include <Common/Version.h> -#include <iostream> - -using namespace LOFAR; - -int main (int argc, const char* argv[]) -{ - std::string type = "brief"; - if (argc > 1) { - type = argv[1]; - } - Version::show<${pkg}Version> (std::cout, "${pkg}", type); - return 0; -} -EOF - -# Do not copy if existing version is the same, -# so code is not rebuilt needlessly. -if [ ! -e $incdir/Package__Version.h ]; then - cp version.h.tmp $incdir/Package__Version.h - echo "makeversion created $incdir/Package__Version.h" -elif [ $hassvn = 0 ]; then - diff version.h.tmp $incdir/Package__Version.h > /dev/null 2>&1 - if [ $? != 0 ]; then - cp version.h.tmp $incdir/Package__Version.h - echo "makeversion replaced $incdir/Package__Version.h" - fi -fi - -if [ ! -e src/Package__Version.cc ]; then - cp version.cc.tmp src/Package__Version.cc - echo "makeversion created src/Package__Version.cc" -elif [ $hassvn = 0 ]; then - diff version.cc.tmp src/Package__Version.cc > /dev/null 2>&1 - if [ $? != 0 ]; then - cp version.cc.tmp src/Package__Version.cc - echo "makeversion replaced src/Package__Version.cc" - fi -fi - -versmainname=version${lpkg} -if [ ! -e src/${versmainname}.cc ]; then - cp version.mcc.tmp src/${versmainname}.cc - echo "makeversion created src/${versmainname}.cc" -elif [ $hassvn = 0 ]; then - diff version.mcc.tmp src/${versmainname}.cc > /dev/null 2>&1 - if [ $? != 0 ]; then - cp version.mcc.tmp src/${versmainname}.cc - echo "makeversion replaced src/${versmainname}.cc" - fi -fi - -# Get the library name, and the name of the variable containing a list of -# library sources (if present). Get it from the CMakeLists.txt, because -# sometimes it differs from the package name (e.g. libbbms for BB/MS). -# Make sure that the first library is taken unless one matches exactly. -addlib=`sed -n 's,^[[:space:]]*[aA][dD][dD]_[lL][iI][bB][rR][aA][rR][yY][[:space:]]*([[:space:]]*\(.*\)).*$,\1,p' src/CMakeLists.txt | head -1` -if [ "$addlib" != "" ]; then - libnm=`echo $addlib | sed 's,[[:space:]].*,,'` - libsrcs=`echo $addlib | sed 's,^.*\${\(.*\)}.*$,\1,'` -else - libnm=lib${lpkg} - libsrcs=${lpkg}_LIB_SRCS -fi - -# Add Package__Version source file to CMakeLists.txt files as needed. -fgrep Package__Version.cc src/CMakeLists.txt > /dev/null 2>&1 -if [ $? != 0 ]; then - # Lookup variable that contains the list of library sources. - grep "^[[:space:]]*set[[:space:]]*([[:space:]]*${libsrcs}[[:space:]]*$" src/CMakeLists.txt > /dev/null 2>&1 - if [ $? = 0 ]; then - # Found it. Add Package__Version.cc to the list - sed "s,^\([[:space:]]*\)\(set[[:space:]]*([[:space:]]*${libsrcs}\)\(.*\)$,\1\2\n\1 Package__Version.cc\3," src/CMakeLists.txt > version.mf.tmp - else - # It's not there. Create a line with a set() command - cat > version.mf.tmp <<EOF -set(${libsrcs} Package__Version.cc) -add_library(${lpkg} \${$libsrcs}) - -EOF - cat src/CMakeLists.txt >> version.mf.tmp - fi - mv version.mf.tmp src/CMakeLists.txt - echo "makeversion added Package__Version.cc to src/CMakeLists.txt" -fi - -# Add version program tot CMakeLists.txt file as needed. -fgrep "${versmainname}" src/CMakeLists.txt > /dev/null 2>&1 -if [ $? != 0 ]; then - # It's not there, add it. - cat src/CMakeLists.txt > version.mf.tmp - cat >> version.mf.tmp <<EOF -lofar_add_bin_program(${versmainname} ${versmainname}.cc) -EOF - mv version.mf.tmp src/CMakeLists.txt - echo "makeversion added ${versmainname}.cc to src/CMakeLists.txt" -fi diff --git a/LCS/Common/src/CMakeLists.txt b/LCS/Common/src/CMakeLists.txt index 8c005fcd5ba..6cb433c914b 100644 --- a/LCS/Common/src/CMakeLists.txt +++ b/LCS/Common/src/CMakeLists.txt @@ -2,6 +2,9 @@ include(LofarPackageVersion) +set_source_files_properties(Package__Version.cc versioncommon.cc + PROPERTIES GENERATED ON) + set(common_LIB_SRCS Package__Version.cc Allocator.cc diff --git a/LCS/pyparameterset/src/CMakeLists.txt b/LCS/pyparameterset/src/CMakeLists.txt index 60592a42e65..4a4e7e8be85 100644 --- a/LCS/pyparameterset/src/CMakeLists.txt +++ b/LCS/pyparameterset/src/CMakeLists.txt @@ -2,10 +2,9 @@ include(LofarPackageVersion) -# Create symbolic link to include directory. -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME}) +# Add current build directory to the include path. This is needed, because +# pyparameterset.cc #include's Package__Version.cc (yucky!). +include_directories(${CMAKE_CURRENT_BINARY_DIR}) lofar_add_library(_pyparameterset MODULE pyparameterset.cc) set_target_properties(_pyparameterset PROPERTIES @@ -18,10 +17,11 @@ set_target_properties(_pyparameterset PROPERTIES install(TARGETS _pyparameterset DESTINATION ${PYTHON_INSTALL_DIR}/lofar/parameterset) +# Dummy library, needed because lofar_add_executable() takes its dependencies +# from libraries added with lofar_add_library() (see bug #1430) lofar_add_library(lofar_pyparameterset Package__Version.cc) -lofar_add_bin_program(versionpyparameterset - versionpyparameterset.cc) +lofar_add_bin_program(versionpyparameterset versionpyparameterset.cc) # Install Python modules include(PythonInstall) diff --git a/LCS/pyparameterset/src/pyparameterset.cc b/LCS/pyparameterset/src/pyparameterset.cc index 95ee470c22e..416fbf77b90 100644 --- a/LCS/pyparameterset/src/pyparameterset.cc +++ b/LCS/pyparameterset/src/pyparameterset.cc @@ -21,7 +21,6 @@ #include <lofar_config.h> #include <Common/ParameterSet.h> - #include <pyrap/Converters/PycExcp.h> #include <pyrap/Converters/PycBasicData.h> #include <pyrap/Converters/PycRecord.h> @@ -30,6 +29,7 @@ #include <boost/python/args.hpp> #include "Package__Version.cc" +//#include <pyparameterset/Package__Version.h> using namespace boost::python; using namespace casa::pyrap; diff --git a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc b/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc index a28db057331..4ed74194652 100644 --- a/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc +++ b/MAC/APL/CUDaemons/src/CTStartDaemon/CTStartDaemon.cc @@ -36,7 +36,7 @@ #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StartDaemon_Protocol.ph> #include "CTStartDaemon.h" -#include "../Package__Version.h" +#include <CUDaemons/Package__Version.h> using namespace LOFAR::GCF::TM; diff --git a/MAC/APL/CUDaemons/src/LogClient/LogClient.cc b/MAC/APL/CUDaemons/src/LogClient/LogClient.cc index 9217058fd35..86f0c2045f9 100644 --- a/MAC/APL/CUDaemons/src/LogClient/LogClient.cc +++ b/MAC/APL/CUDaemons/src/LogClient/LogClient.cc @@ -31,7 +31,7 @@ #include <MACIO/LOG_Protocol.ph> #include <log4cplus/socketappender.h> #include "LogClient.h" -#include "../Package__Version.h" +#include <CUDaemons/Package__Version.h> using namespace log4cplus; using namespace log4cplus::helpers; diff --git a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc b/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc index 34ce99bb5ce..bc231eaaa45 100644 --- a/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc +++ b/MAC/APL/CUDaemons/src/ServiceBroker/ServiceBroker.cc @@ -32,7 +32,7 @@ #include <MACIO/GCF_Event.h> //#include <GCF/TM/GCF_Protocols.h> #include "ServiceBroker.h" -#include "../Package__Version.h" +#include <CUDaemons/Package__Version.h> namespace LOFAR { using namespace MACIO; diff --git a/MAC/APL/PAC/Beam_Server/src/BeamServer.cc b/MAC/APL/PAC/Beam_Server/src/BeamServer.cc index a0f130db8ed..f3ae109fd7a 100644 --- a/MAC/APL/PAC/Beam_Server/src/BeamServer.cc +++ b/MAC/APL/PAC/Beam_Server/src/BeamServer.cc @@ -38,7 +38,7 @@ #include "BeamServerConstants.h" #include "Beam.h" #include "Beamlet.h" -#include "Package__Version.h" +#include <Beam_Server/Package__Version.h> #include <getopt.h> #include <iostream> diff --git a/MAC/APL/PAC/Cal_Server/src/CalServer.cc b/MAC/APL/PAC/Cal_Server/src/CalServer.cc index f789b4a2e64..dce7d6b9f1e 100644 --- a/MAC/APL/PAC/Cal_Server/src/CalServer.cc +++ b/MAC/APL/PAC/Cal_Server/src/CalServer.cc @@ -41,7 +41,7 @@ #include "SubArraySubscription.h" #include "RemoteStationCalibration.h" #include "CalibrationAlgorithm.h" -#include "Package__Version.h" +#include <Cal_Server/Package__Version.h> #ifdef USE_CAL_THREAD #include "CalibrationThread.h" diff --git a/MAC/APL/PIC/RSP_Driver/src/RSPDriver.cc b/MAC/APL/PIC/RSP_Driver/src/RSPDriver.cc index 5f1df566583..a7789558b5b 100644 --- a/MAC/APL/PIC/RSP_Driver/src/RSPDriver.cc +++ b/MAC/APL/PIC/RSP_Driver/src/RSPDriver.cc @@ -134,7 +134,7 @@ #include "Cache.h" #include "RawEvent.h" #include "Sequencer.h" -#include "Package__Version.h" +#include <RSP_Driver/Package__Version.h> #ifdef HAVE_UNISTD_H #include <unistd.h> diff --git a/RTCP/CNProc/src/CN_Processing_main.cc b/RTCP/CNProc/src/CN_Processing_main.cc index 86447339ef4..e106063b628 100644 --- a/RTCP/CNProc/src/CN_Processing_main.cc +++ b/RTCP/CNProc/src/CN_Processing_main.cc @@ -31,9 +31,7 @@ #include <CNProc/LocationInfo.h> #include <CNProc/CN_Processing.h> #include <Common/LofarLogger.h> -#if !defined HAVE_PKVERSION #include <CNProc/Package__Version.h> -#endif #include <boost/lexical_cast.hpp> #include <execinfo.h> diff --git a/RTCP/IONProc/src/ION_main.cc b/RTCP/IONProc/src/ION_main.cc index df595ed0103..4d36452042d 100644 --- a/RTCP/IONProc/src/ION_main.cc +++ b/RTCP/IONProc/src/ION_main.cc @@ -39,9 +39,7 @@ #include <Stream/NullStream.h> #include <Stream/SocketStream.h> #include <Stream/SystemCallException.h> -#if !defined HAVE_PKVERSION -#include <Package__Version.h> -#endif +#include <IONProc/Package__Version.h> #include <algorithm> #include <cmath> #include <cstdlib> diff --git a/RTCP/Storage/src/Storage_main.cc b/RTCP/Storage/src/Storage_main.cc index a17f8d0b626..f3dc760f3eb 100644 --- a/RTCP/Storage/src/Storage_main.cc +++ b/RTCP/Storage/src/Storage_main.cc @@ -17,10 +17,7 @@ #include <Interface/Parset.h> #include <Interface/Thread.h> #include <Storage/SubbandWriter.h> - -#if !defined HAVE_PKVERSION #include <Storage/Package__Version.h> -#endif #if defined HAVE_MPI #include <mpi.h> #endif -- GitLab