[CMake] Out-of-source build and access to data

Alexey Livshits livchits at web.de
Wed Jan 26 12:21:06 EST 2011


You can install target and data and then run your program.

2011/1/26, Benjamin Kurz <benjamin.kurz at bioskill.com>:
> Hello everyone,
>
> Currently I'm using cmake for building my c++/Qt project.
> The source directory structure looks like this:
> Project
> |_ src
> |_ include
> |_ data
>
>
> Currently I run cmake from the source directory, having an in-source-build.
> Now I want to be able to have a complete seperate build folder.
> It compiles fine and it runs ok, unless I need access to a file in the
> data folder.
> Currently I access files like this: filepath = "./data/file1"
> But data is of course not available in the build directory.
> So I copied the files during the cmake process, which also works fine.
>
> But when I run the program I get an exception because the file is not found.
> I tried a lot of possibilities:
> filepath = "../data/file1"
> filepath = "data/file1"
> filepath = "file1"
>
> but nothing seems to work.
>
> The executable is on the top directory in the build directory.
> The filepath is defined and used in a class in ./src directory.
>
> I am not sure how to fix this or which path to use?!
>
> Any advice is appreciated.
>
> Thanks
>
> Benjamin
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


-- 
BG,
Alexey


More information about the CMake mailing list