install - Set installation prefix automatically to custom path if not explicitly specified on the command line -


for internal tests, install prefix default subdirectory of build directory, unless explicitly overridden user. know user can specify install prefix by:

$ cmake -dcmake_install_prefix=/foo/bar .. 

but if user not specify this, should default to, e.g. ${pwd}/installed.

the variable cmake_install_prefix set /usr/local, cannot check see if unset/empty before setting it.

my current solution add custom switch user has invoke specify cmake_install_prefix variable gets respected:

option(enable_install_prefix "install build targets system (path given '-dcmake_install_prefix' or '${cmake_install_prefix}' if not specified)." off) if ( enable_install_prefix )     set (cmake_install_prefix installed cache path "installation root") else()     set (cmake_install_prefix installed cache path "installation root" force) endif() 

my questions are:

(a) there issues above, beyond annoyance of flag needing passed cmake cmake_install_prefix have effect?

(b) there better, cleaner, more robust, more idiomatic and/or less annoying way achieve above?

thanks.

cmake sets boolean variable cmake_install_prefix_initialized_to_default if cmake_install_prefix has not been explicitly specified , initialized default setting. can override in following way:

if (cmake_install_prefix_initialized_to_default)     set (cmake_install_prefix "${cmake_binary_dir}/installed" cache path "default install path" force ) endif() 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -