Yeraze
Yeraze

Reputation: 3289

CMake & "PATH" Variables

In CMake, how do I define a PATH-type cache variable that (in Windows, cmake-gui.exe) gives me the little "..." button to get the Popup dialog? Right now, I'm using syntax like:

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

But it seems to treat it as a String.

Update:

Here's an explicit 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 winds up as a String, even upon a fresh first-time run of CMake.

Upvotes: 4

Views: 13955

Answers (1)

Fraser
Fraser

Reputation: 78280

Your command is correct.

However, it appears that to change the type of a variable, you need to close cmake-gui.exe, delete the variable from CMakeCache.txt (or delete the whole file), then reopen cmake-gui.exe

Another possibility is that you set the same value earlier to STRING type (in which case the first type is kept):

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

or else you unset the same value later and set it 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")

Upvotes: 2

Related Questions