diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f439724..a378525f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,20 @@ cmake_minimum_required(VERSION 3.16) project(PSMoveAPI) -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/hidapi/hidapi/hidapi.h") - message(FATAL_ERROR "hidapi not found, did you forget to run 'git submodule update --init'?") -endif() +option(PSMOVEAPI_VENDORING "Vendor dependencies" ON) -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/libusb-1.0/libusb/libusb.h") - message(FATAL_ERROR "libusb not found, did you forget to run 'git submodule update --init'?") -endif() +if (PSMOVEAPI_VENDORING) + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/hidapi/hidapi/hidapi.h") + message(FATAL_ERROR "hidapi not found, did you forget to run 'git submodule update --init'?") + endif() + + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/libusb-1.0/libusb/libusb.h") + message(FATAL_ERROR "libusb not found, did you forget to run 'git submodule update --init'?") + endif() -if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/PS3EYEDriver/src/ps3eye.h") - message(FATAL_ERROR "PS3EYEDriver not found, did you forget to run 'git submodule update --init'?") + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external/PS3EYEDriver/src/ps3eye.h") + message(FATAL_ERROR "PS3EYEDriver not found, did you forget to run 'git submodule update --init'?") + endif() endif() # get rid of Visual Studio's default "Debug" and "Release" output directories diff --git a/cmake/FindUSB1.cmake b/cmake/FindUSB1.cmake index 3b6d2e0f..0900881a 100644 --- a/cmake/FindUSB1.cmake +++ b/cmake/FindUSB1.cmake @@ -21,6 +21,9 @@ IF (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) set(LIBUSB_FOUND TRUE) ELSE (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) + IF (NOT PSMOVEAPI_VENDORING) + message(FATAL_ERROR "libusb was not found and vendoring is disabled") + ENDIF() # Because we want to use the static library, # look locally only. find_path(LIBUSB_INCLUDE_DIR diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 32f12d0e..18fefbd8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,8 +15,11 @@ set(PSMOVEAPI_PLATFORM_SRC) # Container for source files set(PSMOVEAPI_INSTALL_TARGETS) # Container for build targets to be installed set(PSMOVEAPI_MATH_SRC) # Container for math related source files -include_directories(${ROOT_DIR}/external/hidapi/hidapi) -include_directories(${ROOT_DIR}/external/glm) + +IF(PSMOVEAPI_VENDORING) + include_directories(${ROOT_DIR}/external/hidapi/hidapi) + include_directories(${ROOT_DIR}/external/glm) +ENDIF() include_directories(${CMAKE_BINARY_DIR}) set(INFO_LICENSE "BSD") @@ -54,7 +57,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") list(APPEND PSMOVEAPI_REQUIRED_LIBS ${COREFOUNDATION}) list(APPEND PSMOVEAPI_REQUIRED_LIBS ${IOBLUETOOTH}) - set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/mac/hid.c) + IF(PSMOVEAPI_VENDORING) + set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/mac/hid.c) + ELSE() + message(FATAL_ERROR "disabling vendoring is currently not supported for ${CMAKE_SYSTEM_NAME}") + ENDIF() list(APPEND PSMOVEAPI_PLATFORM_SRC ${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_osx.mm) @@ -69,7 +76,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND PSMOVEAPI_REQUIRED_LIBS setupapi bthprops kernel32 ws2_32 winmm version imm32) - set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/windows/hid.c) + IF(PSMOVEAPI_VENDORING) + set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/windows/hid.c) + ELSE() + message(FATAL_ERROR "disabling vendoring is currently not supported for ${CMAKE_SYSTEM_NAME}") + ENDIF() list(APPEND PSMOVEAPI_PLATFORM_SRC ${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_windows.c) @@ -93,7 +104,17 @@ ELSE() include_directories(${BLUEZ_INCLUDE_DIRS}) list(APPEND PSMOVEAPI_REQUIRED_LIBS ${BLUEZ_LIBRARIES}) - set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/linux/hid.c) + IF(PSMOVEAPI_VENDORING) + set(HIDAPI_SRC ${ROOT_DIR}/external/hidapi/linux/hid.c) + ELSE() + pkg_check_modules(HIDAPI REQUIRED hidapi-hidraw) + include_directories(${HIDAPI_INCLUDE_DIRS}) + list(APPEND PSMOVEAPI_REQUIRED_LIBS hidapi-hidraw) + + pkg_check_modules(GLM REQUIRED glm) + include_directories(${GLM_INCLUDE_DIRS}) + list(APPEND PSMOVEAPI_REQUIRED_LIBS ${GLM_LIBRARIES}) + ENDIF() list(APPEND PSMOVEAPI_PLATFORM_SRC ${CMAKE_CURRENT_LIST_DIR}/platform/psmove_port_linux.cpp) diff --git a/src/tracker/CMakeLists.txt b/src/tracker/CMakeLists.txt index 013d9a00..7f978e2d 100644 --- a/src/tracker/CMakeLists.txt +++ b/src/tracker/CMakeLists.txt @@ -16,6 +16,9 @@ option(PSMOVE_USE_DEBUG_CAPTURE "Always show camera capture input" OFF) IF(PSMOVE_USE_PS3EYE_DRIVER) + IF(NOT PSMOVEAPI_VENDORING) + message(FATAL_ERROR "disabling vendoring is currently not supported for PS3EYEDriver") + ENDIF() # PS3EYEDriver is based on GPL'd code set(INFO_LICENSE "GPL")