blob: bd51f3e0de9d0a9729ef98f4ad753395713aa3e9 [file] [log] [blame]
Kuiying Wang64ff7ce2018-08-15 11:17:06 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
2project(chassisgpio CXX)
3set(CMAKE_CXX_STANDARD 14)
4set(CMAKE_CXX_STANDARD_REQUIRED ON)
5
6set(LIBRARY_NAME "${PROJECT_NAME}")
7set(INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
8set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
9set(PROJECT_CMAKE_FILES ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
10
11set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
12set(DEF_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake)
13set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR})
14
15include(GNUInstallDirs)
16include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
17
18add_library(${PROJECT_NAME} SHARED src/gpio.cpp)
19
20set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "0.1.0")
21set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "0")
22
23install(TARGETS ${PROJECT_NAME}
24 EXPORT "${PROJECT_NAME}EXPORT"
25 RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
26 LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
27 ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT stlib
28 COMPONENT dev)
29
30install(FILES "inc/gpio.hpp"
31 DESTINATION "${INSTALL_INCLUDE_DIR}/" )
32
33install(EXPORT "${PROJECT_NAME}EXPORT"
34 DESTINATION "lib/cmake"
35 FILE ${PROJECT_NAME}Targets.cmake)
36
37configure_file(${CMAKE_SOURCE_DIR}/cmake/Config.cmake.in
38 "${PROJECT_CMAKE_FILES}/${PROJECT_NAME}-config.cmake" @ONLY)
39
40install(FILES
41 "${PROJECT_CMAKE_FILES}/${PROJECT_NAME}-config.cmake"
42 DESTINATION "lib/cmake" COMPONENT dev)