Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get the system home directory in CMake on Linux?

Tags:

linux

cmake

Is there a variable related to the home_dir(like /home/user) of Linux system in CMake. Or some other easy ways to get it.

like image 982
Samuel Avatar asked Sep 30 '15 12:09

Samuel


People also ask

How do I get the CMake path?

CMake will use whatever path the running CMake executable is in. Furthermore, it may get confused if you switch paths between runs without clearing the cache. So what you have to do is simply instead of running cmake <path_to_src> from the command line, run ~/usr/cmake-path/bin/cmake <path_to_src> .

How do I view environment variables in CMake?

Operator to read environment variables. Use the syntax $ENV{VAR} to read environment variable VAR . To test whether an environment variable is defined, use the signature if(DEFINED ENV{<name>}) of the if() command.

Where is CMakeLists TXT located in Ubuntu?

CMakeLists. txt is placed at the root of the source tree of any application, library it will work for. If there are multiple modules, and each module can be compiled and built separately, CMakeLists.

Where is my CMake executable?

Run cmake-gui.exe, which should be in your Start menu under Program Files, there may also be a shortcut on your desktop, or if you built from source, it will be in the build directory.


1 Answers

Home directory is referred to by the HOME environment variable, so you can access it in CMake script by:

$ENV{HOME} 
like image 164
Tsyvarev Avatar answered Sep 29 '22 17:09

Tsyvarev