CMake and PATH variables

In CMake, how do I define a cache variable like PATH, which (on Windows cmake-gui.exe) gives me a small "..." button to get a popup dialog? Right now, I'm using a syntax like:

SET(LIBRARY_INCLUDE_DIR "something" CACHE PATH "Location of libraries") 

But it looks like it is considered a string.

Update:

Here is a clear example:

 IF(EIGEN_DIR) SET(EIGEN_INCLUDE_DIRS ${EIGEN_DIR} CACHE PATH "Location of the Eigen include files") ELSE() SET(EIGEN_INCLUDE_DIRS "" CACHE path "Location of the Eigen include files") ENDIF(EIGEN_DIR) 

And EIGEN_INCLUDE_DIRS terminates as a string, even when cmake is first run.

+4
source share
1 answer

Your team is right.

However, it seems that to change the type of the variable you need to close cmake-gui.exe, delete the variable from CMakeCache.txt (or delete the entire file), and then re-open cmake-gui.exe

Another possibility is that you set the same value before the type STRING (in this case, the first type is saved):

 SET(LIBRARY_INCLUDE_DIR "something" CACHE STRING "Location of libraries") SET(LIBRARY_INCLUDE_DIR "something" CACHE PATH "Location of libraries") 

otherwise you unset change the same value and set to a different type:

 SET(LIBRARY_INCLUDE_DIR "something" CACHE PATH "Location of libraries") UNSET(LIBRARY_INCLUDE_DIR CACHE) SET(LIBRARY_INCLUDE_DIR "something" CACHE STRING "Location of libraries") 
+2
source

Source: https://habr.com/ru/post/1480233/


All Articles