[CMake] (no subject)

Teto mattator at gmail.com
Wed Jul 10 12:16:55 EDT 2013


[sry for not having a title to the mail]

thanks a lot mark, your solution is cleaner than what I had in mind so
that's what I tried. your code ran out of the box or so.

I still have a problem though, that is the working directory seems to
be taken into account by cmake. If I follow the Makefile dependancies
I get to:
====== subMakefile generated by cmake ====
                @$(CMAKE_COMMAND) -E cmake_echo_color
--switch=$(COLOR) --blue --bold "executing gengetopt"cd
/home/teto/dir1/dir2 && echo "pwd ${PWD}" &&  /usr/bin/gengetopt -i\
menudescriptor.ggo\

Now if I I launch "make gengetopt", I get this result:
===== result of "make gengetopt" ====
[100%] executing gengetopt
pwd /home/teto/dir1
Error opening input file:  menudescriptor.ggo

My menudescriptor.ggo is in "/home/teto/dir1/dir2". How can I solve
that (well I could eventually give the fullpath to menudescriptor.ggo)
? It feels like the WORKING_DIRECTORY is supplanted by make.

Matt


NB: As a sidenote is it possible to declare constants in cmake ?

On Wed, Jul 10, 2013 at 12:18 AM, Mark Stijnman <mark.stijnman at gmail.com> wrote:
> On Tue, Jul 9, 2013 at 5:59 PM, Teto <mattator at gmail.com> wrote:
>> Hi,
>>
>> I am trying to pass several arguments of add_custom_target via a
>> custom proxy function that takes 1 argument only. I find it hard to
>> explain but this piece of code should be clearer:
>>
>> === custom function ===
>> function(myfunc PROGRAM command_line)
>>       .... // some code here
>>       add_custom_target(
>>             ${PROGRAM}
>>                         COMMAND ${PROGRAM_BINARY}
>>                          ${command_line}
>>                         )
>> endfunction()
>>
>> == how I call it ==
>> myfunc( gengetopt "-i menudescriptor.ggo WORKING_DIRECTORY
>> ${CMAKE_CURRENT_LIST_DIR}")
>>
> [snip]
>> Is there any "eval" function I could use ?
>>
>> Best regards
>>
>> Matt
>
> What I would do is more something like this:
>
> include(CMakeParseArguments)
> function(myfunc PROGRAM command_line)
>   CMAKE_PARSE_ARGUMENTS(myfunc "" "WORKING_DIRECTORY" "" ${ARGN})
>   if(NOT myfunc_WORKING_DIRECTORY)
>     set(myfunc_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) # or
> some other suitable default
>   endif()
>   add_custom_target(${PROGRAM}
>     COMMAND ${PROGRAM_BINARY} ${command_line}
>     WORKING_DIRECTORY ${myfunc_WORKING_DIRECTORY})
> endfunction()
>
> Now your function has a "WORKING_DIRECTORY" keyword with a single
> parameter, which it will read from any arguments beyond the
> fixed-position arguments (available in ${ARGN}). Check the
> documentation for CMAKE_PARSE_ARGUMENTS for more info. Call your new
> function like
> myfunc( gengetopt "-i menudescriptor.ggo" WORKING_DIRECTORY
> "${CMAKE_CURRENT_LIST_DIR}")
>
> Good luck,
>
> regards Mark


More information about the CMake mailing list