[CMake] [CTest] Access test data from c++ code

Thomas p_thomas at gmx.net
Tue Nov 3 10:59:22 EST 2009


Hallo,

I want to write a test, that needs pregenerated test data. What is the
correct way to access and store it?

My idea is to put it into the source tree like:

File structure:
/mylib/<library files>
/mylib/test/CMakeLists.txt
/mylib/test/data.txt <- pregenerated test data
/mylib/test/test.cpp

In CMakeLists.txt:
add_definitions(-DTEST_PATH=${CMAKE_CURRENT_SOURCE_DIR})

In C++ (test.cpp):
string testPath = TEST_PATH;

Is this correct?

Thank you :)



More information about the CMake mailing list