[CMake] Problems using add_custom_command and perl
Maxime Lecourt
maxime.lecourt at gmail.com
Thu Apr 21 10:34:47 EDT 2011
2011/4/21 David Cole <david.cole at kitware.com>
> On Thu, Apr 21, 2011 at 9:48 AM, Maxime Lecourt <maxime.lecourt at gmail.com>wrote:
>
>> Hi,
>>
>> I'm currently trying to use add_custom_command, but I do not get any
>> output (it's working fine in other projects, with Bison and Flex).
>>
>> Basically, I have a CMakeLists.txt file with
>>
>> include(CMakeCallPerl.cmake)
>> PERL_SCRIPT("${GLISS_PATH}/nmp2nml.pl" "ppc.nmp")
>>
>>
>> And in my CMakeCallPerl.cmake file :
>>
>> find_program(PERL perl)
>> IF(PERL)
>> MACRO(PERL_SCRIPT SCRIPT FILENAME)
>> GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
>> GET_FILENAME_COMPONENT(PREFIX "${FILENAME}" NAME_WE)
>> SET(OUTFILE "${PREFIX}.nml")
>> MESSAGE(STATUS "${PERL} ${SCRIPT} ${FILENAME} ${OUTFILE}")
>> ADD_CUSTOM_COMMAND(
>> OUTPUT "${OUTFILE}"
>> COMMAND "${PERL}"
>> "${SCRIPT}"
>> "${FILENAME}"
>> "${OUTFILE}"
>> )
>> SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
>> ENDMACRO(PERL_SCRIPT)
>> ENDIF(PERL)
>>
>> What am I doing wrong ?
>>
>> Copy/Pasting the MESSAGE output in command line, everything works fine,
>> but not when compiling after generating with CMake.
>> (it looks like this :
>> C:/Win16App/rational/TestRealTime/bin/intel/win32/perl.exe
>> D:/workspace/ppc/../gliss/nmp2nml.pl ppc.nmp ppc.nml)
>> There is also no mention for Perl in any CMake generated file.
>> Using Windows XP and MinGW
>>
>> Regards,
>>
>> Maxime
>>
>> _______________________________________________
>> 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
>>
>
>
> The output of the custom command needs to be used by something in order for
> a build to trigger it...
>
> After calling your macro, you can depend on the output of it with a custom
> target if there is no other dependency on it:
>
> add_custom_target(run_perl_scripts ALL
> DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/file1.nml
> ${CMAKE_CURRENT_BINARY_DIR}/file2.nml ...
> )
>
> Then a "make" will trigger running perl.
>
> You should also probably add:
> DEPENDS ${FILENAME} ${SCRIPT}
> to the custom command so that it re-runs if the input or the script
> changes...
>
>
> HTH,
> David
>
>
Hi,
that was indeed the problem, there was nothing using the target file.
Thank you
Maxime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110421/c733487b/attachment.htm>
More information about the CMake
mailing list