You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type mismatch in CMake configure arguments is a common issue that is really hard to track down, and as such I'm really pedantic about specifying the type of the variables when configuring CMake, especially for path/filepath ones.
There is a special case for handling values initially declared without a type on the cmake command
line. If the project’s CMakeLists.txt file then tries to set the same cache variable and specifies a type
of FILEPATH or PATH , then if the value of that cache variable is a relative path, CMake will treat it as
being relative to the directory from which cmake was invoked and automatically convert it to an
absolute path. This is not particularly robust, since cmake could be invoked from any directory, not
just the build directory. Therefore, developers are advised to always include a type if specifying a
variable on the cmake command line for a variable that represents some kind of path.
It is a good habit to always specify the type of the variable on the command line in general anyway so that it is
likely to be shown in GUI applications in the most appropriate form. It will also prevent one of the
surprising behavior scenarios mentioned in the previous section
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
jmarrec
added a commit
to jmarrec/conan
that referenced
this issue
Apr 15, 2024
What is your suggestion?
Type mismatch in CMake configure arguments is a common issue that is really hard to track down, and as such I'm really pedantic about specifying the type of the variables when configuring CMake, especially for path/filepath ones.
I noticed that the CMake presets do not hold a type for
cacheVariables
, while the CMake documentation explicitly says it can be a value, or a an object with bothtype
andvalue
, cf https://cmake.org/cmake/help/v3.29/manual/cmake-presets.7.html#configure-presetPerhaps should consider explictly setting it, around
conan/conan/tools/cmake/toolchain/toolchain.py
Lines 240 to 271 in f1ef6e4
Related:
cache_variables
convert recipe options to CMake bool butvariables
converts them to strings? #14590Quoting Professional CMake - Practical Guide, 15th edition by Craig Scott (I hope that's ok, since I can already find the same online at https://discourse.cmake.org/t/cmake-d-var-type-value/1135)
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: