[CMake] Out-of-source build and access to data
David Cole
david.cole at kitware.com
Wed Jan 26 10:12:43 EST 2011
Send some code for us to look at.
If the cwd is where your exe is, and there's a file at "./data/file1"
then you should certainly be able to open and read that file with that
file name.
Maybe your cwd is not what you think it is.
Maybe your code changes it somewhere between launching and attempting
to open the file.
I don't understand where you're using a
filepath = "./data/file1"
reference? In your source code? In a settings file of some sort?
Certainly not in a CMakeLists.txt file since this is not cmake
syntax...
??
David
On Wed, Jan 26, 2011 at 9:54 AM, Benjamin Kurz
<benjamin.kurz at bioskill.com> wrote:
> 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
>
More information about the CMake
mailing list