installation - CMake resources in source code for build and install -
this has been on mind years. using resource files cmake in code such can accessed when running in build directory , when installed.
say have files necessary run program in top-level directory called res. contains res/file1.txt , res/file2.txt. build program , resources copied build directory program can run during development. then, program installed resources /usr/share/my_program or , program runs accessing files. question in source code same code works when running build directory , when installed. i've seen several different answers how handle resources each seems have flaw:
- the program searches in preconfigured absolute directory such cmake_install_prefix/share/my_program , must installed first run, not ideal easy use during development.
- finding way use relative paths binary don't see how work since build tree not mirror installed file paths, being installed bin , share directories.
- differentiating between 2 cmake variable searches relative path in 1 scenario or installed location another. possibly debug/release variable. require rerunning cmake before installing rebuild new resource paths.
- baking files executable. seems uneccessary when dealing resources since opened instead , may inconvenient large directories of files.
is 1 of these best solution? there i'm not misunderstanding? i've been under impression programs should able run build directory before installing see if work. if possible, know both cmake , c/c++ code like, such open("my_resource_location");
, my_cmake_command()
. answers i've seen relating resources don't include both.
Comments
Post a Comment