-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
56 lines (45 loc) · 2.47 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
47
48
49
50
51
52
53
54
55
56
cmake_minimum_required(VERSION 2.6)
project(dfu C CXX)
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
include(GNUInstallDirs)
find_package(M REQUIRED)
find_package(Threads REQUIRED)
find_package(USB REQUIRED)
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(DFU_VERSION_MAJOR 1)
set(DFU_VERSION_MINOR 0)
set(DFU_VERSION_RELEASE 0)
set(DFU_VERSION "${DFU_VERSION_MAJOR}.${DFU_VERSION_MINOR}.${DFU_VERSION_RELEASE}")
set(DFU_SOVERSION ${DFU_VERSION_MAJOR})
set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/dfu.c
${CMAKE_CURRENT_SOURCE_DIR}/dfu_load.c
${CMAKE_CURRENT_SOURCE_DIR}/dfuse.c
${CMAKE_CURRENT_SOURCE_DIR}/quirks.c
${CMAKE_CURRENT_SOURCE_DIR}/dfu_file.c
${CMAKE_CURRENT_SOURCE_DIR}/dfu_util.c
${CMAKE_CURRENT_SOURCE_DIR}/dfuse_mem.c
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_INCLUDE_PATH})
link_directories(${CMAKE_LIBRARY_PATH})
include_directories(${USB_INCLUDE_DIR})
add_library(dfu SHARED ${SOURCES})
if(MINGW)
target_link_libraries(dfu ws2_32)
else(MINGW)
set_target_properties(dfu PROPERTIES VERSION ${DFU_VERSION} SOVERSION ${DFU_SOVERSION})
endif(MINGW)
target_link_libraries(dfu ${CMAKE_THREAD_LIBS_INIT} ${M_LIB} ${USB_LIBRARIES})
install(TARGETS dfu LIBRARY DESTINATION ${LIB_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libdfu.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfu.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfu_file.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfu_load.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfuse_mem.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/portable.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/usb_dfu.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfuse.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dfu_util.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/quirks.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/dfu)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/FindDFU.cmake DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/cmake-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}/Modules")