Reputation: 1711
In code below is from a CMakeLists.txt file. It builds and installs a library that uses cmake also. My question is what is the difference between BINARY_DIR
AND CONFIGURE_COMMAND
, one uses double quotes and the other does not?
ExternalProject_Add(simple_amqp
GIT_REPOSITORY https://github.com/alanxz/SimpleAmqpClient.git
GIT_TAG master
SOURCE_DIR "${CMAKE_BINARY_DIR}/simpleamqp-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/simpleamqp-build"
CONFIGURE_COMMAND ${CMAKE_EXE} ../simpleamqp-src
BUILD_COMMAND ${MAKE_EXE} -j4
INSTALL_COMMAND sudo ${MAKE_EXE} install
TEST_COMMAND ""
)
Upvotes: 0
Views: 447
Reputation: 171167
Double quotes serve to escape certain special characters in CMake, primarily the semi-colon. In CMake, the semi-colon acts as an argument separator even if it is produced by an expansion of a variable. In the (unlikely) case that the variable CMAKE_BINARY_DIR
contains a semi-colon, ${CMAKE_BINARY_DIR}/simpleamqp-src
would be treated as two arguments, while "${CMAKE_BINARY_DIR}/simpleamqp-src"
will be a single argument.
However, given that CMake's language is somewhat obscure and esoteric at times, it's perfectly possible the real explanation is closer to "some lines were copy-pasted from code which used quotes, and some were written by someone who thought they were [not] required, and ..."
To learn more about CMake syntax, quoting, and escaping, you can read its docs, particularly the section about quoted arguments.
Upvotes: 3