It's possible to separate cmake parameters into files so that you don't
have to edit the main file when moving it from freedv-dev to freedv,
etc. This also keeps your revision control history clean when you change
parameters. Given a list of parameter names for the argument, the macro
below loads files in the parameters/ directory and sets them to
variables called Param.<name> .
# Parameters are stored as .txt files in the parameters/ subdirectory.
# They use semicolon to separate arguments, because this is what cmake uses
# in its list type. Thus, parameters/version.txt looks like this:
#
# 0;1;2
#
# Those are easy to separate at each semicolon into the major, minor,
# and patch version.
#
# You can override parameters on the command line, using
# -DParam.name=value
#
macro(load_parameters)
foreach(name ${ARGN})
set(filename "${CMAKE_SOURCE_DIR}/parameters/${name}.txt")
if("${Param.${name}}" STREQUAL "" AND EXISTS ${filename})
file(STRINGS ${filename} string)
set("Param.${name}" ${string})
endif("${Param.${name}}" STREQUAL "" AND EXISTS ${filename})
endforeach(name)
unset(filename)
endmacro(load_parameters)
Here's how I use this to do version numbers.
parameters/version.txt contains
0;1;0
You can separate these for easy use in the cmake file:
# This loads three parameters, version, codename, and build-type
load_parameters(version codename build-type)
# This separates version into three parameters (perhaps I can use an
array instead of a list?)
list(GET Param.version 0 Version.major)
list(GET Param.version 1 Version.minor)
list(GET Param.version 2 Version.patch)
unset(list)
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Freetel-codec2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freetel-codec2