Home > database >  What type should I use for a list of file or directory paths in CMake?
What type should I use for a list of file or directory paths in CMake?

Time:11-14

Cached variables in CMake have one of several types:

Type identifier Description
BOOL Boolean ON/OFF value.
FILEPATH Path to a file on disk.
PATH Path to a directory on disk.
STRING A line of text.
INTERNAL A line of text. cmake-gui does not show internal entries. They may be used to store variables persistently across runs.

If I want to store a CMake-style* list of file paths or directory paths, should I define it as FILEPATH or PATH, respectively? As a STRING?

* - i.e. represented in a semicolon-separated string.

CodePudding user response:

FILEPATH and PATH are suitable only for a single path. E.g. when a user fills parameters of one of these types, CMake GUI provides a path-selection dialog.

For the list of paths use STRING parameter.


In case you will use non-semicolon separator between paths, you will need to convert that separator to semicolon before use that list in CMakeLists.txt. E.g. you could choose a colon (:) to be used a separator, like for the PATH variable on Linux.

  • Related