cmake: Quote more strings in if().

This commit is contained in:
Ryan Pavlik 2019-04-08 15:18:57 -05:00
parent cd97d12fc9
commit 606ee6ca41
2 changed files with 16 additions and 16 deletions

View file

@ -52,20 +52,20 @@
set(HIDAPI_ROOT_DIR "${HIDAPI_ROOT_DIR}" CACHE PATH "Root to search for HIDAPI")
# Clean up components
if(HIDAPI_FIND_COMPONENTS)
if("${HIDAPI_FIND_COMPONENTS}")
if(WIN32 OR APPLE)
# This makes no sense on Windows or Mac, which have native APIs
list(REMOVE HIDAPI_FIND_COMPONENTS libusb)
list(REMOVE "${HIDAPI_FIND_COMPONENTS}" libusb)
endif()
if(NOT ${CMAKE_SYSTEM} MATCHES "Linux")
# hidraw is only on linux
list(REMOVE HIDAPI_FIND_COMPONENTS hidraw)
list(REMOVE "${HIDAPI_FIND_COMPONENTS}" hidraw)
endif()
endif()
if(NOT HIDAPI_FIND_COMPONENTS)
if(NOT "${HIDAPI_FIND_COMPONENTS}")
# Default to any
set(HIDAPI_FIND_COMPONENTS any)
set("${HIDAPI_FIND_COMPONENTS}" any)
endif()
# Ask pkg-config for hints
@ -126,10 +126,10 @@ find_package(Threads QUIET)
set(HIDAPI_LIBRARY)
# First, try to use a preferred backend if supplied
if(HIDAPI_FIND_COMPONENTS MATCHES "libusb" AND HIDAPI_LIBUSB_LIBRARY AND NOT HIDAPI_LIBRARY)
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "libusb" AND HIDAPI_LIBUSB_LIBRARY AND NOT HIDAPI_LIBRARY)
set(HIDAPI_LIBRARY ${HIDAPI_LIBUSB_LIBRARY})
endif()
if(HIDAPI_FIND_COMPONENTS MATCHES "hidraw" AND HIDAPI_HIDRAW_LIBRARY AND NOT HIDAPI_LIBRARY)
if("${HIDAPI_FIND_COMPONENTS}" MATCHES "hidraw" AND HIDAPI_HIDRAW_LIBRARY AND NOT HIDAPI_LIBRARY)
set(HIDAPI_LIBRARY ${HIDAPI_HIDRAW_LIBRARY})
endif()
@ -150,7 +150,7 @@ endif()
set(_hidapi_component_required_vars)
foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
if(${_comp} STREQUAL "any")
if("${_comp}" STREQUAL "any")
list(APPEND _hidapi_component_required_vars
HIDAPI_INCLUDE_DIR
HIDAPI_LIBRARY)
@ -161,7 +161,7 @@ foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
set(HIDAPI_any_FOUND FALSE)
endif()
elseif(${_comp} STREQUAL "libusb")
elseif("${_comp}" STREQUAL "libusb")
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR HIDAPI_LIBUSB_LIBRARY)
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_LIBUSB_LIBRARY}")
set(HIDAPI_libusb_FOUND TRUE)
@ -170,7 +170,7 @@ foreach(_comp IN LISTS HIDAPI_FIND_COMPONENTS)
set(HIDAPI_libusb_FOUND FALSE)
endif()
elseif(${_comp} STREQUAL "hidraw")
elseif("${_comp}" STREQUAL "hidraw")
list(APPEND _hidapi_component_required_vars HIDAPI_INCLUDE_DIR HIDAPI_HIDRAW_LIBRARY)
if(HIDAPI_INCLUDE_DIR AND EXISTS "${HIDAPI_HIDRAW_LIBRARY}")
set(HIDAPI_hidraw_FOUND TRUE)

View file

@ -100,8 +100,8 @@ find_package_handle_standard_args(OpenHMD
THREADS_FOUND
)
if(OPENHMD_FOUND)
set(OPENHMD_INCLUDE_DIRS ${OPENHMD_INCLUDE_DIR})
set(OPENHMD_LIBRARIES ${OPENHMD_LIBRARY})
set(OPENHMD_INCLUDE_DIRS "${OPENHMD_INCLUDE_DIR}")
set(OPENHMD_LIBRARIES "${OPENHMD_LIBRARY}")
if(NOT TARGET OpenHMD::OpenHMD)
add_library(OpenHMD::OpenHMD UNKNOWN IMPORTED)
endif()
@ -109,20 +109,20 @@ if(OPENHMD_FOUND)
INTERFACE_INCLUDE_DIRECTORIES "${OPENHMD_INCLUDE_DIR}")
set_target_properties(OpenHMD::OpenHMD PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION ${OPENHMD_LIBRARY})
IMPORTED_LOCATION "${OPENHMD_LIBRARY}")
set_property(TARGET OpenHMD::OpenHMD PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES Threads::Threads)
if(${OPENHMD_HIDAPI_TYPE} STREQUAL libusb)
if("${OPENHMD_HIDAPI_TYPE}" STREQUAL libusb)
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-libusb)
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-libusb)
elseif(${OPENHMD_HIDAPI_TYPE} STREQUAL hidraw)
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL hidraw)
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi-hidraw)
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi-hidraw)
elseif(${OPENHMD_HIDAPI_TYPE} STREQUAL undifferentiated)
elseif("${OPENHMD_HIDAPI_TYPE}" STREQUAL undifferentiated)
set_property(TARGET OpenHMD::OpenHMD APPEND PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES HIDAPI::hidapi)
list(APPEND OPENHMD_LIBRARIES HIDAPI::hidapi)