Anytime John! I ran into the same problem as you when I tried to figure out a
way to parse the arguments to my functions and/or macros. Because I couldn't
find the right documentation, I just went ahead and opened up the module file
itself
(YourCMakeInstallPath/share/cmake-2.8/Modules/CMakeParseArguments.cmake). I
have found from a lot of banging my head against the wall that sometimes it is
just easier to look at the code itself. Typically, the module developers do an
excellent job of documenting the commands within the comments header of the
file, and I have found that to be the easiest way to find exactly what I need
to explain how to use it. Just as an example, here is the section in the
CMakeParseArguments.cmake file that explains what I explained to you:
# As an example here a my_install() macro, which takes similar arguments as the
# real install() command:
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
# ...
Do you happen to know what docs you were looking at? It may be worth a little
bit to post that to this mailing list so that hopefully the person that wrote
those docs could be so kind as to update them with the correct syntax.
Take Care!
Eric
From: Biddiscombe, John A. [mailto:[email protected]]
Sent: Friday, October 19, 2012 2:35 PM
To: Eric Clark
Cc: CMake Mailing List ([email protected])
Subject: RE: help with cmake_parse_arguments
Eric
Thanks for pointing that out, the help docs I was looking at didn't mention
<multi_value_keywords>, with that added it works as expected.
Cheers
JB
From: Eric Clark [mailto:[email protected]]
Sent: 19 October 2012 19:17
To: Biddiscombe, John A.
Cc: CMake Mailing List ([email protected]<mailto:[email protected]>)
Subject: RE: help with cmake_parse_arguments
John,
The cmake_parse_arguments command takes 5 arguments, not 4. My guess is that
you just need to get the arguments right and things should then work for you
assuming the rest of your code is correct. If you look in
CMakeParseArguments.cmake you should see the documentation for the command, but
I can tell you that the command takes the following arguments:
cmake_parse_arguments(prefix options singleValueArgs multiValueArgs ${ARGN})
The prefix is what is added to the beginning of each variable that is set, the
options is a list of parameters that do not have any arguments associated with
them (i.e. REQUIRED, NO_DEFAULT_PATH, etc.), the singleValueArgs is a list of
all parameters that have only one argument associated with them, the
mutliValueArgs is a list of all parameters that have one or more arguments
associated with them, and the last parameter should always be ${ARGN}.
Hope this helps...
Eric
From: [email protected]<mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Biddiscombe, John A.
Sent: Friday, October 19, 2012 11:32 AM
To: [email protected]<mailto:[email protected]>
Subject: [CMake] help with cmake_parse_arguments
I don't understand why this stripped down test gives the wrong results. Can
anyone point out what I've done wrong. I'm using cmake 2.8.9
Thanks
JB
=== TEST cmake ===
include (CMakeParseArguments)
MACRO(ADD_TEXT_TEST)
CMAKE_PARSE_ARGUMENTS(
TEST ""
"NAME;COMMAND;ARGSLIST;BASELINE"
${ARGN}
)
message("TEST_DEFAULT_ARGS is ${TEST_DEFAULT_ARGS} from ${ARGN}")
message("TEST_NAME is ${TEST_NAME}")
message("TEST_COMMAND is ${TEST_COMMAND}")
message("TEST_ARGSLIST is ${TEST_ARGSLIST}")
message("TEST_BASELINE is ${TEST_BASELINE}")
ENDMACRO(ADD_TEXT_TEST)
set (datafile "Test1.xxx")
ADD_TEXT_TEST(
NAME
testiso_${datafile}
COMMAND
"RunMe"
ARGSLIST
3.5555 nodal "${EAVL_SOURCE_DIR}/data/${datafile}"
BASELINE
"${CMAKE_CURRENT_SOURCE_DIR}/baseline/testiso/${datafile}.out"
)
=== output ===
Gives output as follows - the name is missing and the arglist is truncated ...
TEST_DEFAULT_ARGS is from
NAME;testiso_Test1.xxx;COMMAND;RunMe;ARGSLIST;3.5555;nodal;D:/Code/EAVL/data/Test1.xxx;BASELINE;D:/Code/EAVL/test/baseline/testiso/Test1.xxx.out
TEST_NAME is
TEST_COMMAND is RunMe
TEST_ARGSLIST is 3.5555
TEST_BASELINE is D:/Code/EAVL/test/baseline/testiso/Test1.xxx.out
--
John Biddiscombe, email:biddisco @.at.@ cscs.ch
http://www.cscs.ch/
CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07
Via Trevano 131, 6900 Lugano, Switzerland | Fax: +41 (91) 610.82.82
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake