[CMake] dependency in custom command?

King, Steven R steven.r.king at intel.com
Mon Aug 31 13:12:25 EDT 2009


> > add_test    (
> >            test_my_module
> >            ${CMAKE_BINARY_DIR}/bin/test_my_module
> >            )
> 
> This will only work on Unix like systems. Doesn't CTest figure out
> that the program name is a target? I.e. doesn't this work (provided
> you did add_executable(test_my_module ...)):
> 
> add_test(test_my_module test_my_module)
 
Hi Michael,

I have the add_executable just as you show, but CTest gives up immediately since it can't find the test_my_module executable in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}.

Here are the bugs I think I've encountered with your collective help:

Bug 1: Cmake ignores ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} in the add_test() command.  Consequently ctest reports a failure due to not finding the test binary.

Bug 2: Locating a build output using the LOCATION property of a target is deprecated, but commands cannot substitute the target name for build output location.  In other words, commands like this fail:
	add_executable( foo foo.cpp )
	add_custom_command( OUTPUT new_foo COMMAND $(CMAKE_COMMAND) -E copy foo new_foo )

Cmake should recognize 'foo' as a target and implicitly substitute foo's build output.


But back to the dll test problem: Changing ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} forces me to hack all the ctests in my whole build tree, which I'm unwilling to do.  I will stick with Clint's copy_if_different idea to move the dll to the binary directory of the test program.
 
Thanks Clint, Michael, Philip Tyler and the list.  Community support here has been great even if the answers weren't what I hoped to hear.

Cheers,
-steve


More information about the CMake mailing list