[CMake] help with cmake_parse_arguments

Eric Clark eclark at ara.com
Fri Oct 19 13:17:12 EDT 2012


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: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of Biddiscombe, John A.
Sent: Friday, October 19, 2012 11:32 AM
To: cmake at cmake.org
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121019/88b87ec0/attachment-0001.htm>


More information about the CMake mailing list