Commit 2b059cbdbe844450e1675a5dda3cb8acb1147631

Authored by Henry Schreiner
Committed by GitHub
1 parent a2bf5cde

fix: add quotes (#471)

* fix: add quotes

* Update CMakeLists.txt

* Try 2

* fix: Support paths with spaces using @ZeeD26's suggestion
Showing 1 changed file with 23 additions and 10 deletions
CMakeLists.txt
... ... @@ -4,12 +4,12 @@ cmake_minimum_required(VERSION 3.4)
4 4  
5 5 # Make sure users don't get warnings on a tested (3.4 to 3.16) version
6 6 # of CMake. For most of the policies, the new version is better (hence the change).
7   -# We don't use the 3.4...3.16 syntax because of a bug in an older MSVC's
  7 +# We don't use the 3.4...3.17 syntax because of a bug in an older MSVC's
8 8 # built-in and modified CMake 3.11
9   -if(${CMAKE_VERSION} VERSION_LESS 3.16)
  9 +if(${CMAKE_VERSION} VERSION_LESS 3.17)
10 10 cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
11 11 else()
12   - cmake_policy(VERSION 3.16)
  12 + cmake_policy(VERSION 3.17)
13 13 endif()
14 14  
15 15 set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"")
... ... @@ -46,7 +46,20 @@ list(APPEND force-libcxx "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME")
46 46 list(APPEND build-docs "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME")
47 47 list(APPEND build-docs "NOT CMAKE_VERSION VERSION_LESS 3.11")
48 48 list(APPEND build-docs "Doxygen_FOUND")
49   -list(APPEND build-docs "EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/docs")
  49 +
  50 +# Necessary to support paths with spaces, see #457
  51 +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
  52 + set(docs_EXIST TRUE)
  53 +else()
  54 + set(docs_EXIST FALSE)
  55 +endif()
  56 +list(APPEND build-docs "docs_EXIST")
  57 +
  58 +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples")
  59 + set(examples_EXIST TRUE)
  60 +else()
  61 + set(examples_EXIST FALSE)
  62 +endif()
50 63  
51 64 option(CLI11_WARNINGS_AS_ERRORS "Turn all warnings into errors (for CI)")
52 65 option(CLI11_SINGLE_FILE "Generate a single header file")
... ... @@ -64,7 +77,7 @@ cmake_dependent_option(CLI11_BUILD_TESTS
64 77  
65 78 cmake_dependent_option(CLI11_BUILD_EXAMPLES
66 79 "Build CLI11 examples" ON
67   - "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME;EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/examples" OFF)
  80 + "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME;${examples_EXIST}" OFF)
68 81  
69 82 cmake_dependent_option(CLI11_BUILD_EXAMPLES_JSON
70 83 "Build CLI11 json example" OFF
... ... @@ -181,8 +194,8 @@ endif()
181 194  
182 195 # This folder should be installed
183 196 if(CLI11_INSTALL)
184   - install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
185   - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
  197 + install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
  198 + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
186 199  
187 200 # Make an export target
188 201 install(TARGETS CLI11 EXPORT CLI11Targets)
... ... @@ -198,13 +211,13 @@ if(CLI11_INSTALL)
198 211  
199 212 # Make version available in the install
200 213 install(FILES "${PROJECT_BINARY_DIR}/CLI11ConfigVersion.cmake"
201   - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CLI11)
  214 + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CLI11")
202 215  
203 216 # Install the export target as a file
204 217 install(EXPORT CLI11Targets
205 218 FILE CLI11Config.cmake
206 219 NAMESPACE CLI11::
207   - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/CLI11)
  220 + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/CLI11")
208 221  
209 222 # Use find_package on the installed package
210 223 export(TARGETS CLI11
... ... @@ -239,7 +252,7 @@ if(CLI11_SINGLE_FILE)
239 252 add_custom_target(CLI11-generate-single-file ALL
240 253 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp")
241 254 set_property(TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts")
242   - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp
  255 + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
243 256 DESTINATION include)
244 257 add_library(CLI11_SINGLE INTERFACE)
245 258 target_link_libraries(CLI11_SINGLE INTERFACE CLI11)
... ...