test-shared-lib/CMakeLists.txt

24 lines
897 B
CMake

cmake_minimum_required(VERSION 3.9)
project(test_shared_library LANGUAGES C VERSION 1.0.1 DESCRIPTION "Shared C Library for testin")
include(GNUInstallDirs)
add_library(test_shared_library SHARED test_shared_library.c test_shared_library.h)
set(CMAKE_C_STANDARD 99)
set_target_properties(test_shared_library PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 1
PUBLIC_HEADER test_shared_library.h)
configure_file(test_shared_library.pc.in test_shared_library.pc @ONLY)
target_include_directories(test_shared_library PRIVATE .)
install(TARGETS test_shared_library
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${CMAKE_BINARY_DIR}/test_shared_library.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
add_executable(test test.c)
target_link_libraries(test test_shared_library)