From 986f9e6c3ea9d1f2df140549ea7294f2031d61cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek?= Date: Sun, 17 May 2020 21:52:14 +0200 Subject: [PATCH] Update cmake exports --- CMakeLists.txt | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e6452e..51deddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,39 @@ 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) +# project properties, version etc +project(test_shared_library LANGUAGES C VERSION 1.0.3 DESCRIPTION "Shared C Library for testing of various cmake configurations") set(CMAKE_C_STANDARD 99) +# include GNU Install dirs +include(GNUInstallDirs) + enable_testing() +# define library +add_library(test_shared_library SHARED test_shared_library.c test_shared_library.h) + +# library properties - dynamic set_target_properties(test_shared_library PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 1 PUBLIC_HEADER test_shared_library.h) +# pkg-config stuff configure_file(test_shared_library.pc.in test_shared_library.pc @ONLY) -target_include_directories(test_shared_library PRIVATE .) +#target_include_directories(test_shared_library PRIVATE .) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + PRIVATE .) -install(TARGETS test_shared_library EXPORT test_shared_library_export +# export native cmake package +install(TARGETS test_shared_library EXPORT test_shared_libraryConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +# export pkg-config package 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) +install(EXPORT test_shared_libraryConfig DESTINATION share/test_shared_library/cmake) add_executable(test_library test.c)