Commit b4992084 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Added function to declare subdir name and version

parent d4d61a44
gaudi_subdir(GaudiCoreSvc v1r0)
depends_on_subdirs(GaudiKernel)
find_package(Boost COMPONENTS system filesystem regex thread)
......@@ -13,8 +15,3 @@ gaudi_add_module(GaudiCoreSvc
JobOptionsSvc/*.cpp
MessageSvc/*.cpp
LINK_LIBRARIES GaudiKernel Boost)
# Generate the version header for the package.
execute_process(COMMAND
${versheader_cmd}
GaudiCoreSvc v1r0 ${CMAKE_CURRENT_BINARY_DIR}/GaudiCoreSvcVersion.h)
#!/usr/bin/env python
import os
import sys
import re
from optparse import OptionParser
def main():
import os, sys, re
if len(sys.argv) != 4:
print "ERROR: Usage %s <project> <version> <outputfile>"%sys.argv[0]
exit(1)
parser = OptionParser(usage="ERROR: Usage %prog <project> <version> <outputfile>")
parser.add_option("-q", "--quiet", action="store_true",
help="Do not print messages.")
opts, args = parser.parse_args()
if len(args) != 3:
parser.error("wrong number of arguments")
project, version, outputfile = sys.argv[1:]
print "Creating %s for %s %s"%(outputfile, project, version)
project, version, outputfile = args
if not opts.quiet:
print "Creating %s for %s %s" % (outputfile, project, version)
m = re.match("(v|([A-Za-z]+\-))(?P<maj_ver>[0-9]+)(r|\-)(?P<min_ver>[0-9]+)(?:(p|\-)(?P<pat_ver>[0-9]+))?",version)
m = re.match("(v|([A-Za-z]+\-))(?P<maj_ver>[0-9]+)(r|\-)(?P<min_ver>[0-9]+)(?:(p|\-)(?P<pat_ver>[0-9]+))?", version)
majver = int(m.groupdict()['maj_ver'])
minver = int(m.groupdict()['min_ver'])
patver = int(m.groupdict()['pat_ver'] or 0)
outdir = os.path.dirname(outputfile)
if not os.path.exists(outdir):
print "Creating directory", outdir
if not opts.quiet:
print "Creating directory", outdir
os.makedirs(outdir)
open(outputfile,"w").write(
open(outputfile, "w").write(
"""#ifndef %(proj)s_VERSION
/* Automatically generated file: do not modify! */
#ifndef CALC_GAUDI_VERSION
......
......@@ -491,14 +491,42 @@ function(gaudi_get_packages var)
set(${var} ${packages} PARENT_SCOPE)
endfunction()
#-------------------------------------------------------------------------------
# gaudi_subdir(name version)
#
# Declare name and version of the subdirectory.
#-------------------------------------------------------------------------------
macro(gaudi_subdir name version)
gaudi_get_package_name(_guessed_name)
if (NOT _guessed_name STREQUAL "${name}")
message(WARNING "Declared subdir name (${name}) does not match the name of the directory (${_guessed_name})")
endif()
# Set useful variables and properties
set(subdir_name ${name})
set(subdir_version ${version})
set_directory_properties(PROPERTIES name ${name})
set_directory_properties(PROPERTIES version ${version})
# Generate the version header for the package.
execute_process(COMMAND
${versheader_cmd} --quiet
${name} ${version} ${CMAKE_CURRENT_BINARY_DIR}/${name}Version.h)
endmacro()
#-------------------------------------------------------------------------------
# gaudi_get_package_name(VAR)
#
# Set the variable VAR to the current "package" (subdirectory) name.
#-------------------------------------------------------------------------------
macro(gaudi_get_package_name VAR)
# By convention, the package is the name of the source directory.
get_filename_component(${VAR} ${CMAKE_CURRENT_SOURCE_DIR} NAME)
if (subdir_name)
set(${VAR} ${subdir_name})
else()
# By convention, the package is the name of the source directory.
get_filename_component(${VAR} ${CMAKE_CURRENT_SOURCE_DIR} NAME)
endif()
endmacro()
#-------------------------------------------------------------------------------
......
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