Answer the question
In order to leave comments, you need to log in
How to properly use your options in cmake?
I want to add my options to the project. I do so
option(DEPEND_DOWNLOAD_FROM_GIT "Select download dependens" OFF)
cmake -DEPEND_DOWNLOAD_FROM_GIT=ON ..
-- Build files have been written to: F:/code/C++/test/build/DEPEND_DOWNLOAD_FROM_GIT=ON
-LH, then cmake will show this option. the documentation ( https://cmake.org/cmake/help/latest/command/option.html ) only says that the user can select OFF, ON and the case when the option is not set. I did not find an example of use. How do I use self-written options correctly?
Answer the question
In order to leave comments, you need to log in
1. The first parameter when starting cmake is the path to the CMakeLists.txt file to be processed.
Usually, the build process using cmake looks something like this:
I create an empty directory for building the project in an arbitrary place, go to it, and execute there: cmake <путь к cmakelists.txt>
In this case, the source directory is not filled with build artifacts that are not needed there.
2. options in cmake are passed like cmake ... -D<имя опции>[=значение]
this -D is the key followed by the option name. Now compare with how you apply it.
The syntax is similar to defining macros on the command line of C/C++ compilers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question