Set installation prefix automatically to custom path if not explicitly specified on the command line
问题 For some internal tests, I would like the install prefix to default to a subdirectory of the build directory, unless explicitly overridden by the user. I know the user can specify a install prefix by: $ cmake -DCMAKE_INSTALL_PREFIX=/foo/bar .. But if the user does not specify this, it should default to, e.g. ${PWD}/installed . The variable CMAKE_INSTALL_PREFIX is already set to /usr/local , so I cannot just check to see if it unset/empty before setting it. My current solution is to add a