Greetings! i have a project located on one place with src, build , install folders. After building project(that consume a lot of time), i want to copy full folder structure in another place without rebilding again. However, after “make” command it builds anyway. How can i avoid such temper?
P.S. i typed locations through the …/ so in configuration should be releative paths
You should create an install of the project. That can be relocated if the rpaths ($ORIGIN or @executable_path and friends) and library ids (@rpath/) are set up properly. The code also needs to not use CMAKE_INSTALL_PREFIX or the like.
If you make a relocatable install, you should be able to just move the entire tree under CMAKE_INSTALL_PREFIX and things keep working.
I’m saying the C++ code (or whatever language) should not use CMAKE_INSTALL_PREFIX. So, don’t do things like target_compile_definitions(tgt PRIVATE prefix=${CMAKE_INSTALL_PREFIX}). This makes the code “aware” of where it expects to live which breaks relocatability. Instead, use platform-specific APIs like dladdr to detect where the code lives on the filesystem at runtime and compute relative paths based on that.