environmentVariables

320 views
Skip to first unread message

Kevin Clarke

unread,
Nov 30, 2012, 10:16:18 PM11/30/12
to cmake-maven-...@googlegroups.com
Hi, I'm trying to run something that activates a variable.  This works:

cmake -DBUILD_THIRDPARTY:bool=on .

but it doesn't work from within the maven plugin when I have:

<environmentVariables>
<BUILD_THIRDPARTY>bool=on</BUILD_THIRDPARTY>
</environmentVariables>

I'm I missing anything?  I didn't see an example that used an environmental variable.

Thanks!
Kevin

cowwoc

unread,
Nov 30, 2012, 10:18:43 PM11/30/12
to cmake-maven-...@googlegroups.com
    Everything to the left of the equal sign is the key. Everything to the right is the value. Try:

<environmentVariables>
<BUILD_THIRDPARTY:bool>on</BUILD_THIRDPARTY:bool>
</environmentVariables>

PS: You might need to escape the colon.

Gili

Kevin S. Clarke

unread,
Nov 30, 2012, 10:59:30 PM11/30/12
to cmake-maven-...@googlegroups.com
Hmm, tried that and it also didn't work. The colon there would
indicate a namespace. I tried escaping it with &... but the ampersand
isn't a valid character in an XML element name.

I don't think there is a reason to expect that the code would treat a
namespace as a part of the XML element's local name. Is there another
form of escaping that you meant that wouldn't have the ampersand?

Thanks for the speedy response, btw!

Kevin

Kevin S. Clarke

unread,
Nov 30, 2012, 11:18:49 PM11/30/12
to cmake-maven-...@googlegroups.com
Ah, I realized <BUILD_THIRDPARTY>on</BUILD_THIRDPARTY> will work (just
leaving off the colon and bool). I thought I'd tried that already and
it hadn't worked. Guess it does.

Problem solved, thanks!

Kevin S. Clarke

unread,
Nov 30, 2012, 11:30:00 PM11/30/12
to cmake-maven-...@googlegroups.com
Or I may have been mistaken. Gah. It's not doing it now after a clean.

Kevin

Kevin S. Clarke

unread,
Nov 30, 2012, 11:31:09 PM11/30/12
to cmake-maven-...@googlegroups.com
I think I ran it before without a clean after I'd generated it from
the command line. So it wasn't doing it through the cmake maven
plugin but because it had already been generated.

Kevin

cowwoc

unread,
Nov 30, 2012, 11:49:11 PM11/30/12
to cmake-maven-...@googlegroups.com

What you've got is an XML or Maven problem. This shouldn't be
specific to this plugin. I would recommend the following:

1. Do you really need a colon in the key name? Look for a workaround
that allows you to use a key without a colon in its name.
2. Use a Maven plugin (this one or maven-exec-plugin) to execute a
command that prints out all environment variables. This will allow you
to try different key names and see how they get picked up in the spawned
executable.
3. Post a question on Stackoverflow. Again, I suspect this is more of an
XML question. If it turns out there is a workaround for XML but it still
fails, then it's a Maven question. If it turns out it works in
maven-exec-plugin but not in this plugin then it's really a bug in my
plugin.

Please let me know how this turns out. I'm curious to know how you
solve it.

Thanks,
Gili

Kevin S. Clarke

unread,
Dec 1, 2012, 12:30:43 AM12/1/12
to cmake-maven-...@googlegroups.com
Maybe I've been misunderstanding the difference between environmental
variables and cmake cache entries. When I turn Maven's debugging on I
can see that the environmental variable is set correctly. I can also
see that cmake is called without it; cmake is called like:

[DEBUG] command-line:
[/home/kevin/Workspace/openjpeg/target/dependency/cmake/bin/cmake,
/home/kevin/Workspace/openjpeg, -G, Unix Makefiles]

I try that exact command putting the variable in front as a system
variable (and it still doesn't work):

BUILD_THIRDPARTY=on \
/home/kevin/Workspace/openjpeg/target/dependency/cmake/bin/cmake \
/home/kevin/Workspace/openjpeg -G "Unix Makefiles"

But when I put it in the command line as a "cache entry" (that's what
the man page calls it) it works:

/home/kevin/Workspace/openjpeg/target/dependency/cmake/bin/cmake \
-DBUILD_THIRDPARTY=on /home/kevin/Workspace/openjpeg \
-G "Unix Makefiles"

So, perhaps my question is does the plugin provide a way to supply a
cache entry on the command line? In Java -D would be a system
property but it looks like it means something different to cmake
(which I'm not very familiar with)?

Thanks,
Kevin

cowwoc

unread,
Dec 1, 2012, 2:41:44 AM12/1/12
to cmake-maven-...@googlegroups.com

Ah. That's a different matter altogether. Environment variables
have nothing to do with command-line arguments. The plugin does not
provide a mechanism for passing arbitrary arguments to cmake.

The plugin provides two operations:

1. Downloads and runs a local copy of cmake.
2. Executes cmake with the basic command-line options.

I'm reluctant to add support for -D because there are many other
parameters in cmake and it's too much work adding support one by one.
How about I add an <options> configuration parameter which allows you to
pass an arbitrary string to cmake? Currently I'm executing:

cmake -G [generator] [sourcePath]

I'm proposing the following command-line instead:

cmake [options] -G [generator] [sourcePath]

Will this meet your needs?

Gili

Kevin S. Clarke

unread,
Dec 1, 2012, 10:33:32 AM12/1/12
to cmake-maven-...@googlegroups.com

Yes, that would work, thanks!

Kevin

cowwoc

unread,
Dec 3, 2012, 2:16:19 AM12/3/12
to cmake-maven-...@googlegroups.com
Hi Kevin,

    Can you try the version 2.8.10-b1 found at this staging repository? https://oss.sonatype.org/service/local/repositories/comgooglecodecmake-maven-project-166/content/

    There is a new <options> configuration option and the final command-line looks like this:

cmake -G [generator] [options] [sourcePath]

Thanks,
Gili

Kevin S. Clarke

unread,
Dec 3, 2012, 10:50:46 AM12/3/12
to cmake-maven-...@googlegroups.com
Hmm, I'm not sure how to grab it from there. I have the sonatype
staging repositories enabled in my pom (for repositories and
pluginRepositories:
https://oss.sonatype.org/content/repositories/snapshots), but I don't
see the .10 version at
https://oss.sonatype.org/index.html#nexus-search;quick~cmake-maven-project

Is there something else I need to do?

Thanks,
Kevin

Kevin S. Clarke

unread,
Dec 3, 2012, 10:54:19 AM12/3/12
to cmake-maven-...@googlegroups.com

cowwoc

unread,
Dec 4, 2012, 1:29:28 AM12/4/12
to cmake-maven-...@googlegroups.com
Hi Kevin,

I just deployed the binaries into the staging repository. Try again
and let me know if it works.

Thanks,
Gili

Kevin S. Clarke

unread,
Dec 4, 2012, 11:29:33 PM12/4/12
to cmake-maven-...@googlegroups.com
Hi Gili,

Thanks! The only problem with it was I want to be able to pass
multiple options like:

<options>-DBUILD_THIRDPARTY:bool=on -DBUILD_JAVA:bool=on</options>

To pass these to ProcessBuilder, they need to be tokenized on the
whitespace and added to the list one at a time (otherwise only the
first one is passed). I've attached a patch for GenerateMojo that
makes this change. When I built and used cmake-maven-plugin with the
patched GenerateMojo.java everything worked fine.

Thanks again for making these changes!
Kevin
GenerateMojo.patch

cowwoc

unread,
Dec 5, 2012, 1:34:13 PM12/5/12
to cmake-maven-...@googlegroups.com

Okay. Instead of integrating the patch I will end up using a
List<String>. Meaning you'd have:

<options>
<option>-DBUILD_THIRDPARTY:bool=on</option>
<option>-DBUILD_JAVA:bool=on</option>
</options>

This is safer than assuming that assuming whitespace denotes a delimiter (which it does not if quotes are used). I assume you're okay with your private version of the plugin for now? Or are you waiting on me? If you're okay, I will try working on an official release in the coming weeks.

Gili

Kevin S. Clarke

unread,
Dec 5, 2012, 1:57:08 PM12/5/12
to cmake-maven-...@googlegroups.com
Yes, that makes more sense. I'm okay with my private version for now.
I'm just in the initial stages of my project.

Thanks again,
Kevin

cowwoc

unread,
Dec 21, 2012, 2:11:59 PM12/21/12
to cmake-maven-...@googlegroups.com
Hi Kevin,

I just published version 2.8.10.2-b1 into the staging repository. Can you please try the "options" configuration as discussed on http://code.google.com/p/cmake-maven-project/ and let me know if it works? Once that's done I'll release it to the public.

Thanks,
Gili

Kevin S. Clarke

unread,
Dec 29, 2012, 10:09:30 PM12/29/12
to cmake-maven-...@googlegroups.com
Hi,

Sorry for the delay. I found a 2.8.10.2-b2 version in the staging
repository (https://oss.sonatype.org/content/repositories/staging/com/googlecode/cmake-maven-project/cmake-maven-plugin/)
and tested that and it worked fine.

Thanks!
Kevin

cowwoc

unread,
Dec 30, 2012, 11:39:05 AM12/30/12
to cmake-maven-...@googlegroups.com
Perfect, thanks Kevin!

Gili
Reply all
Reply to author
Forward
0 new messages