Fixed bug 5044 - CMake messes up hidapi path when project directory contains spaces
authorSam Lantinga <slouken@libsdl.org>
Fri, 20 Mar 2020 12:13:26 -0700
changeset 136481631ba283bc4
parent 13647 c8f27a5e868e
child 13649 00ee90243d11
Fixed bug 5044 - CMake messes up hidapi path when project directory contains spaces

Eric Jing

When the project directory path contains spaces, CMake butchers the include path for the hidapi files.

I traced the problem to the cmake/sdlchecks.cmake file at line 1091, which sets flags for the build process. I surrounded the problem flag with double quotes, shown below, and CMake works with spaces in the project directory path.
cmake/sdlchecks.cmake
     1.1 --- a/cmake/sdlchecks.cmake	Fri Mar 20 11:52:18 2020 +0300
     1.2 +++ b/cmake/sdlchecks.cmake	Fri Mar 20 12:13:26 2020 -0700
     1.3 @@ -1088,7 +1088,7 @@
     1.4        set(HAVE_SDL_JOYSTICK TRUE)
     1.5        file(GLOB HIDAPI_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
     1.6        set(SOURCE_FILES ${SOURCE_FILES} ${HIDAPI_SOURCES})
     1.7 -      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} -I${SDL2_SOURCE_DIR}/src/hidapi/hidapi")
     1.8 +      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} \"-I${SDL2_SOURCE_DIR}/src/hidapi/hidapi\"")
     1.9        if(NOT HIDAPI_SKIP_LIBUSB)
    1.10          if(HIDAPI_ONLY_LIBUSB)
    1.11            set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/libusb/hid.c)