coin cheung
coin cheung

Reputation: 1095

How to assign cmake variables in the CMakeLists.txt

I can use cmake like this:

cmake -DPYTHON_EXECUTABLE=~/build/python ..

How could I write this in my CMakeLists.txt so that I could simply run this:

cmake ..

Upvotes: 1

Views: 1517

Answers (1)

Raul Laasner
Raul Laasner

Reputation: 1585

Include

set(PYTHON_EXECUTABLE $ENV{HOME}/build/python CACHE FILEPATH "")

in your CMakeLists.txt. For more information about the set command see the online documentation or run cmake --help set.

EDIT: The CACHE FILEPATH "" part here is mandatory, as pointed out below.

Upvotes: 1

Related Questions