[CMake] correct way to pass CMake path variables to ADD_DEFINITIONS?

Wojciech Jarosz wjarosz at ucsd.edu
Sun Sep 24 13:35:55 EDT 2006


I am writing a confidence test which needs to read some asset files. In 
order to tell the test where these files are located I do the following 
within the test's CMakeLists.txt:
ADD_DEFINITIONS(-DRB_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\")

Within the test code I then ensure that this define works properly like so:
#define STRINGIZE(a) DO_STRINGIZE(a)
#define DO_STRINGIZE(a) # a
...
cout << "RB_DATA_DIR = " << STRINGIZE(RB_DATA_DIR) << endl;

This works fine on linux, however on Windows it returns:
RB_DATA_DIR = "C,ocuments and Settings/wjarosz/My Documents/Visual 
Studio 2005/Projects/gfx/VMULTest/"

Sure enough, checking the Preprocessor Definitions line within the 
generated Project, I see:
"RB_DATA_DIR=\"C","ocuments and Settings/wjarosz/My Documents/Visual 
Studio 2005/Projects/gfx/VMULTest/\"",

What is the proper way to pass paths using the preprocessor with CMake?

Thanks!
-wojciech



More information about the CMake mailing list