Hi Nils,
Clever. I didn't even consider specifying the SOURCES argument of the custom
target with a generator expression. But it seems to work perfectly.
Thanks!
Attila
> On 03 Dec 2015, at 16:00, Nils Gladitz <[email protected]> wrote:
>
> On 12/03/2015 03:47 PM, Attila Krasznahorkay wrote:
>> Dear All,
>>
>> Is it possible to add additional source files to an already existing custom
>> target?
>>
>> My project needs to generate a number of "different things", which it does
>> by setting up many custom commands. In order to trigger the generation of
>> everything, I currently need to set up an inconvenient number of custom
>> targets as well. Would it be possible to attach multiple custom commands to
>> an already existing custom target?
>>
>
> e.g. this nonsense example seems to work:
>
> cmake_minimum_required(VERSION 3.4)
>
> add_custom_target(foo ALL
> COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,MY_INPUTS>
> DEPENDS "$<TARGET_PROPERTY:foo,MY_INPUTS>"
> VERBATIM
> )
>
> function(add_custom_input input)
> set(_output "${CMAKE_CURRENT_BINARY_DIR}/${input}.out")
> set(_input "${CMAKE_CURRENT_SOURCE_DIR}/${input}")
>
> add_custom_command(OUTPUT ${_output}
> COMMAND ${CMAKE_COMMAND} -E copy ${_input} ${_output}
> DEPENDS ${_input}
> VERBATIM
> )
>
> set_property(TARGET foo APPEND PROPERTY MY_INPUTS ${_output})
> endfunction()
>
> file(WRITE input1)
> add_custom_input(input1)
>
> file(WRITE input2)
> add_custom_input(input2)
> Nils
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake