[CMake] digging in the dark corners of the command line argument
interpreter
Axel Roebel
Axel.Roebel at ircam.fr
Wed Dec 13 04:29:46 EST 2006
Dear CMakers
I run into a little problem with the command line flag -D.
I'll often use the command line flag -D to pass variables to cmake.
Because typing long names like
-DTT_EXECUTABLE:PATH=tt
is boring I was pretty happy to see that I could do
-DTT_EXECUTABLE=tt
as well. Before you start shortcutting I have to add
some salt to this nice soup because unfortunately
it turns out that this nearly always works besides
if in CMakeLists.txt I do a FIND_PROGRAM. For example with
MESSAGE("varstate: ${TT_EXECUTABLE}")
FIND_PROGRAM(TT_EXECUTABLE NAMES whatever)
MESSAGE("varstate: ${TT_EXECUTABLE}")
what happens is
$> cd /home/roebel/tmp/
$> cmake . -DTT_EXECUTABLE=whatever
varstate: whatever
varstate: /home/roebel/tmp/whatever
which shows that FIND_PROGRAM replaced the content of variable TT_EXECUTABLE
by $PWD/${TT_EXECUTABLE} which is nonsense most of the time.
After some more digging I found that with
-DTT_EXECUTABLE=whatever no cache variable is created
so the variable seems to be in kind of a zomby state.
However, it turns out that
cmake . -DTT_EXECUTABLE:=whatever
works correctly creating a string type cache variable.
So the questions are,
1. what is
-DTT_EXECUTABLE=whatever
supposed to do in contrast to
-DTT_EXECUTABLE:=whatever
or the book version
-DTT_EXECUTABLE:STRING=whatever
2.
can I rely on -DTT_EXECUTABLE:=whatever to work or am I still abusing a
current weakness of the command line type check.
Thanks for any illumination!
--
Axel Roebel
IRCAM Analysis/Synthesis Team
Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540
More information about the CMake
mailing list