-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
70 lines (59 loc) · 1.97 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cmake_minimum_required (VERSION 2.8.8)
project (libkindrv)
set (libkindrv_INCLUDE_DIRS include/)
set (CONFIG_PACKAGE_LOCATION lib/${PROJECT_NAME})
# The version number.
set (libkindrv_VERSION_MAJOR 0)
set (libkindrv_VERSION_MINOR 1)
set (libkindrv_VERSION_PATCH 0)
set (libkindrv_VERSION ${libkindrv_VERSION_MAJOR}.${libkindrv_VERSION_MINOR}.${libkindrv_VERSION_PATCH})
# find libusb library
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
find_package (libusb-1.0 REQUIRED)
include_directories (
include
${LIBUSB_1_INCLUDE_DIRS})
add_library (${PROJECT_NAME} SHARED
src/kindrv.cpp
src/exception.cpp)
target_link_libraries (${PROJECT_NAME}
${LIBUSB_1_LIBRARIES})
set_property(TARGET ${PROJECT_NAME}
PROPERTY VERSION ${libkindrv_VERSION})
# Install headers.
install (DIRECTORY include/${PROJECT_NAME}
DESTINATION include
)
# Install targets.
install (TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION lib/${PROJECT_NAME}
INCLUDES DESTINATION include/${PROJECT_NAME}
)
# Install the package.xml file to be compatible with REP-136.
install (FILES package.xml
DESTINATION share/${PROJECT_NAME}
)
# Generate and install a CMake configuration file.
include (CMakePackageConfigHelpers)
write_basic_package_version_file (
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${libkindrv_VERSION}
COMPATIBILITY SameMajorVersion
)
export (TARGETS ${PROJECT_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake"
)
configure_file (cmake_modules/${PROJECT_NAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
COPYONLY
)
install (EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install (
FILES
cmake_modules/${PROJECT_NAME}Config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)