blob: 273a42a29b1989d97353145da8d26a2f1dd9dd76 [file] [log] [blame]
Kuiying Wang64ff7ce2018-08-15 11:17:06 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
Ed Tanousf61ca6f2019-08-15 15:09:05 -07002project(chassisi2c CXX)
James Feist676d2c32019-02-14 10:07:27 -08003set(CMAKE_CXX_STANDARD 17)
Kuiying Wang64ff7ce2018-08-15 11:17:06 +08004set(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
Ed Tanousf61ca6f2019-08-15 15:09:05 -070018add_library(${PROJECT_NAME} SHARED src/i2c.cpp)
Kuiying Wang64ff7ce2018-08-15 11:17:06 +080019
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
Ed Tanousf61ca6f2019-08-15 15:09:05 -070030install(FILES "inc/i2c.hpp"
Kuiying Wang64ff7ce2018-08-15 11:17:06 +080031 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)