ExternalProject: CMAKE_CACHE_ARGS adds an unwanted semicolon to PATH variables if quoted
Bug happend with cmake 3.16.3 on Ubuntu 20.04
when using parameter CMAKE_CACHE_ARGS on ExternalProject_Add:
ExternalProject_Add(project_name
URL "...."
URL_MD5 "..."
...
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_BINARY_DIR}/install/path"
)
if you use quotes like the provided example, than an unwanted semicolon is created to the install path by ExternalProject
that case the resulting path will be "install/path;/..." instead of "install/path/..." similary, if you set a final slash than an extra subdirectory ; will be created so
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_BINARY_DIR}/install/path/"
will installs external project in "install/path/;/..." instead of "install/path"
Avoiding, instead, using quotes will work correctly so
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/install/path
will correctly install external project in "install/path" as desired.
this is the real code causing the issue when CMAKE_CACHE_ARGS is quoted as previously described (posting the working, non-quoted, code):
ExternalProject_Add(project_lua
URL "http://www.lua.org/ftp/lua-5.3.6.tar.gz"
URL_MD5 "83f23dbd5230140a3770d5f54076948d"
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/download
SOURCE_DIR ${CMAKE_BINARY_DIR}/lib/src/lua53
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/lib/install/lua
)
ExternalProject_Add_Step(project_lua clone_cmakelists
DEPENDEES mkdir download
DEPENDERS configure
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/lib/mods/lua/CMakeLists.txt" "${CMAKE_BINARY_DIR}/lib/src/lua53"
)