Kuiying Wang | 64ff7ce | 2018-08-15 11:17:06 +0800 | [diff] [blame^] | 1 | cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) |
| 2 | project(chassisgpio CXX) |
| 3 | set(CMAKE_CXX_STANDARD 14) |
| 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 5 | |
| 6 | set(LIBRARY_NAME "${PROJECT_NAME}") |
| 7 | set(INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin) |
| 8 | set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib) |
| 9 | set(PROJECT_CMAKE_FILES ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) |
| 10 | |
| 11 | set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include) |
| 12 | set(DEF_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake) |
| 13 | set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR}) |
| 14 | |
| 15 | include(GNUInstallDirs) |
| 16 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) |
| 17 | |
| 18 | add_library(${PROJECT_NAME} SHARED src/gpio.cpp) |
| 19 | |
| 20 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "0.1.0") |
| 21 | set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "0") |
| 22 | |
| 23 | install(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 | |
| 30 | install(FILES "inc/gpio.hpp" |
| 31 | DESTINATION "${INSTALL_INCLUDE_DIR}/" ) |
| 32 | |
| 33 | install(EXPORT "${PROJECT_NAME}EXPORT" |
| 34 | DESTINATION "lib/cmake" |
| 35 | FILE ${PROJECT_NAME}Targets.cmake) |
| 36 | |
| 37 | configure_file(${CMAKE_SOURCE_DIR}/cmake/Config.cmake.in |
| 38 | "${PROJECT_CMAKE_FILES}/${PROJECT_NAME}-config.cmake" @ONLY) |
| 39 | |
| 40 | install(FILES |
| 41 | "${PROJECT_CMAKE_FILES}/${PROJECT_NAME}-config.cmake" |
| 42 | DESTINATION "lib/cmake" COMPONENT dev) |