-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
46 lines (39 loc) · 1.16 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
project(usbwrap)
# Create a shared library
file(GLOB SOURCES src/*.cpp src/*.c)
add_library(${PROJECT_NAME} SHARED ${SOURCES})
# Ensure clients can find the includes
target_include_directories(${PROJECT_NAME} PUBLIC include)
# Dependencies
set(LIB_DEPENDS common error usb-1.0)
target_link_libraries(${PROJECT_NAME} PUBLIC ${LIB_DEPENDS})
# What to install
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY include/makestuff DESTINATION include
)
# List endpoints tool
add_subdirectory(lsep)
# Maybe build tests
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
# On Windows we need to fetch libusb itself
if(MSVC)
include(FetchContent)
FetchContent_Declare(
libusb
GIT_REPOSITORY https://github.com/libusb/libusb.git
GIT_TAG v1.0.23
GIT_SHALLOW ON
PATCH_COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_SOURCE_DIR}/libusb.patch
)
if(NOT libusb_POPULATED)
FetchContent_Populate(libusb)
endif()
add_subdirectory(${libusb_SOURCE_DIR} ${libusb_BINARY_DIR})
endif()