test-shared-lib/CMakeLists.txt
2020-05-17 10:11:58 +02:00

30 lines
1.1 KiB
CMake

cmake_minimum_required(VERSION 3.9)
project(test_shared_library LANGUAGES C VERSION 1.0.2 DESCRIPTION "Shared C Library for testing of various cmake configurations")
include(GNUInstallDirs)
add_library(test_shared_library SHARED test_shared_library.c test_shared_library.h)
set(CMAKE_C_STANDARD 99)
enable_testing()
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 EXPORT test_shared_library_export
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)
install(EXPORT test_shared_library_export DESTINATION share/test_shared_library/cmake)
add_executable(test_library test.c)
target_link_libraries(test_library test_shared_library)
add_test(test_shared_lib_dynamic test_library)