[CMake] How to emulate autotools "make check"?

Hendrik Sattler post at hendrik-sattler.de
Wed Mar 25 12:40:47 EDT 2009


Marcel Loose schrieb:
> On Wed, 2009-03-25 at 15:16 +0100, Eric Noulard wrote:
>> 2009/3/25 Marcel Loose <loose at astron.nl>:
>>> On Fri, 2009-03-20 at 16:34 +0100, Eric Noulard wrote:
>>>> 2009/3/20 Marcel Loose <loose at astron.nl>:
>>>>> Perfect!
>>>> Ok fine.
>>>>
>>>>> I now use add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) and
>>>>> that indeed solves the parallel build issue.
>>>>> And yes, I have MAKEFLAGS set to "-j4".
>>>>
>>>> Now that you make check is working, may be it's time to describe
>>>> the way to go on a wiki page, may be in a new "Specific Topic"
>>>> http://www.cmake.org/Wiki/CMake#Specific_Topics
>>>>
>>> Hi Erk,
>>>
>>> How do I add a topic on the wiki page? Do I need to register somewhere
>>> and get a login name?
>> yes you need that, may be other can help for this
>> I'm on leave with limited internet access.
>>
> 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


More information about the CMake mailing list