[CMake] Accessing targets at test time on MSVC

Stuart Herring cmake at stuartherring.com
Sun Apr 1 09:04:39 EDT 2007


Hi,

I have a situation where I want to add a test that runs a target built
in another directory - so I used GET_TARGET_PROPERTY to get the
LOCATION property of the target, and it works fine with non MS build
systems.
However, with VS6, building the RUN_TESTS project gives the following error:
CMake Error: config type specified on the command line, but test
executable not found.c:/build/TestRun/testtool/$(IntDir)/testtool.exe/Debug/testtool.exe
Unable to find executable: c:/build/TestRun/testtool/$(IntDir)/testtool.exe

This appears to be because the LOCATION property is rendered into the
DartTestFile.txt with $(IntDir) to represent the configuration type.
If I manually change it to ${IntDir} it correctly locates the exe.

Is this a bug?  Or should I be using a different approach?

Here's a minimal example project that demonstrates what I'm doing:

==== Top level CMakeLists.txt ====
PROJECT(TestRun C)
INCLUDE(CTest)
ADD_SUBDIRECTORY(testtool)
GET_TARGET_PROPERTY(tt testtool LOCATION)
ADD_TEST(testtool_test ${tt} foo bar)

==== testtool/CMakeLists.txt ====
ADD_EXECUTABLE(testtool testtool.c)

==== testtool/testtool.c ====
#include <stdio.h>
int main(int argc, const char *argv[]) {
        int i;
        for(i = 0; i< argc; i++) {
                printf("%s\n", argv[i]);
        }
        return 0;
}

Regards,
Stuart


More information about the CMake mailing list