CMake/Tests/GeneratorExpression/pwd.c
Ben Boeckel d331292c12 cmTestGenerator: Evaluate generator expressions in test properties
This is useful for cases like:

  add_test(NAME mytest COMMAND mydriver $<TARGET_FILE:myexe>)
  set_tests_properties(mytest PROPERTIES
    REQUIRED_FILES "$<TARGET_FILE:myexe>"
    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>"
    )

In this example we require the actual test executable to exist to
run the test in addition to the test driver at argv[0].  Also the
$<CONFIGURATION> expression improves over \${CTEST_CONFIGURATION_TYPE}
because the latter is not normalized for case-sensitive filesystems.
2013-09-20 08:18:22 -04:00

35 lines
492 B
C

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <direct.h>
#define getcurdir _getcwd
#else
#include <unistd.h>
#define getcurdir getcwd
#endif
int main(int argc, char* argv[])
{
#define BUFSZ 20000
char buf[BUFSZ + 1];
#ifdef _WIN32
char *pos;
#endif
getcurdir(buf, BUFSZ);
#ifdef _WIN32
pos = buf;
while (*pos)
{
if (*pos == '\\')
{
*pos = '/';
}
++pos;
}
#endif
printf("%s\n", buf);
return EXIT_SUCCESS;
}