[CMake] Best way to handle application data path for local run vs. installation

Dmitry Marakasov amdmi3 at amdmi3.ru
Fri Dec 4 06:05:19 EST 2015


* Dmitry Marakasov (amdmi3 at hades.panopticon) wrote:

> Anyway for now, I did some research and solved the problem of inplace
> vs. systemwide compilation in a way that I find acceptable.
> 
> I check for CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT to basically
> know whether a user has explicitly specified CMAKE_INSTALL_PREFIX.
> If user specified install prefix, I prepare for systemwide install,
> otherwise I prepare for inplace run.
> 
> https://github.com/AMDmi3/hoverboard-sdl/blob/0.4.0/CMakeLists.txt
> 
> This doesn't support inplace and systemwide /at the same time/, but
> still supports either of them cleanly, doesn't require extra actions
> from user and behaves sensibly by default.

Wanted to add that this doesn't really work well. When cmake is run
second time, it always switches to systemwide installation because of
cache. I think I'll go with adding explicit SYSTEMWIDE and STANDALONE
options, former builds for systemwide installation with global paths,
and latter for installation into self-contained directory with local
paths (e.g. for windows/macos), and if neither is specified the
project runs from the build directory.

I don't see any better solution right now.

-- 
Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3 at amdmi3.ru  ..:  jabber: amdmi3 at jabber.ru      http://amdmi3.ru


More information about the CMake mailing list