[CMake] To quote (path) variables or not, and everywhere?
Mateusz Loskot
mateusz at loskot.net
Mon Sep 25 04:33:20 EDT 2017
Hi,
A user of one of projects I maintain pointed out that according to
CMake guidelines [1] all variables with strings (also paths) should be
quoted, ie.
include_directories(${SOCI_SOURCE_DIR}/core)
should read
include_directories("${SOCI_SOURCE_DIR}/core")
Is that so?
What is the current CMake recommendation?
Some other guidelines [2] suggest rule of thumb when using
variables in COMMAND calls:
Use quotes for the arguments that contain file paths
Does this apply to include_directories. set_target_properties, etc.?
I found "Paths with spaces - Visual Studio" [3] post which reports a
problem with not quoted paths but David Cole's recommendation [4]
uses add_library with path not quoted.
I sense, the answer to quote or not to quote might depend on
which CMake command is used.
Could anyone tell what is the current recommendation?
[1] https://cmake.org/Wiki/CMake/Language_Syntax#CMake_splits_arguments_unless_you_use_quotation_marks_or_escapes.
[2] https://stackoverflow.com/a/35853080/151641
[3] https://public.kitware.com/pipermail/cmake/2012-July/051138.html
[4] https://public.kitware.com/pipermail/cmake/2012-July/051139.html
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
More information about the CMake
mailing list