[CMake] altering RUN_TESTS post-build command (MSVC + CTest)

Tyler Roscoe tyler at cryptio.net
Thu Sep 30 16:54:46 EDT 2010


On Mon, Sep 20, 2010 at 09:07:34AM -0700, Keith Gunderson wrote:
> I'm using a MSVC 9.0 Generator with Cmake 2.8.2
> 
> How do I add a change so that the command for my RUN_TESTS project changes from 
> the default of:
> 
> "C:\Program Files\CMake 2.8\bin\ctest.exe" --force-new-ctest-process  -C 
> $(OutDir)
> if errorlevel 1 goto VCReportError
> 
> to
> 
> "C:\Program Files\CMake 2.8\bin\ctest.exe" --force-new-ctest-process  -VV -C 
> $(OutDir)
> if errorlevel 1 goto VCReportError

AFAIK, there is no way to do this without patching CMake.

What we do instead is just create our own equivalent of the RUN_TESTS
target:

set (cmd ${CMAKE_CTEST_COMMAND} -VV)
if (MSVC)
    set (cmd ${cmd} -C ${CMAKE_CFG_INTDIR})
else ()
    set (cmd ${cmd} -C ${CMAKE_BUILD_TYPE})
endif ()
add_custom_target (my_run_tests
    COMMAND ${cmd}
)

hth,
tyler


More information about the CMake mailing list