[CMake] How to emulate autotools "make check"?
Hendrik Sattler
post at hendrik-sattler.de
Thu Mar 26 11:11:25 EDT 2009
Marcel Loose schrieb:
> On Wed, 2009-03-25 at 17:40 +0100, Hendrik Sattler wrote:
>> Marcel Loose schrieb:
>>> On Wed, 2009-03-25 at 15:16 +0100, Eric Noulard wrote:
>>>> 2009/3/25 Marcel Loose <loose at astron.nl>:
>>>>
>>> OK, it's done.
>>>
>>> I've added http://www.cmake.org/Wiki/CMakeEmulateMakeCheck to "Specific
>>> Topics".
>> Wouldn't a macro for
>> add_executable(<testprog> EXCLUDE_FROM_ALL ...)
>> add_test(<testprog> <testprog>)
>> add_dependencies(check <testprog>)
>>
>> be better than complaining about having to retype that all (untested):
>> macro ( add_check prog )
>> if ( NOT TARGET check )
>> add_custom_target(check COMMAND ${CMAKE_TEST_COMMAND})
>> endif ( NOT TARGET check )
>> add_executable(${prog} EXCLUDE_FROM_ALL ${ARGN})
>> add_test(${prog})
>> add_dependencies(check ${prog})
>> endmacro ( add_check )
>>
>> then use add_check() like add_executable().
>>
>> HS
>
> Hi Hendrik,
>
> Your idea sounds good, but usually you will also need to use a
> target_link_libraries() command. How would you fit that into your macro?
> So the sequence of commands would be something like:
> add_executable(<prog> <prog-srcs>)
> add_test(<prog> <prog>)
> add_dependencies(check <prog>)
> target_link_libraries(prog <dep-libs>)
>
> How do I pass both <prog-srcs> and <dep-libs> as arguments to the
> add_check macro?
You don't:
add_check(<prog> <prog-srcs>)
target_link_libraries(<prog> <dep-libs>)
HS
More information about the CMake
mailing list