Commit f7c9502dfbcf6eef85b246780f9a0ef426ed81b2

Sam Lantinga 2020-03-20T12:13:26

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index ee8421f..6c33c25 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1088,7 +1088,7 @@ macro(CheckHIDAPI)
       set(HAVE_SDL_JOYSTICK TRUE)
       file(GLOB HIDAPI_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/hidapi/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${HIDAPI_SOURCES})
-      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} -I${SDL2_SOURCE_DIR}/src/hidapi/hidapi")
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBUSB_CFLAGS} \"-I${SDL2_SOURCE_DIR}/src/hidapi/hidapi\"")
       if(NOT HIDAPI_SKIP_LIBUSB)
         if(HIDAPI_ONLY_LIBUSB)
           set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/hidapi/libusb/hid.c)