From c4f5b6a68fab9837a67b097ee064ccb93ea61991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Apr 2022 14:31:01 +0200 Subject: [PATCH 1/2] Install libs to CMAKE_INSTALL_LIBDIR CMake's GNUInstallDirs defines CMAKE_INSTALL_LIBDIR which will honor things like "make install DESTDIR=" and is the recommended installation directory for libraries. It also avoids hardcoding "usr/lib". --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 551538b..afee1d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,4 +21,4 @@ set(LIBDFX_INCLUDE_DIRS file(COPY include/libdfx.h DESTINATION ${CMAKE_BINARY_DIR}/include) add_library(dfx ${libdfx_sources}) target_include_directories(dfx PUBLIC ${LIBDFX_INCLUDE_DIRS}) -install(TARGETS dfx ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/usr/lib) +install(TARGETS dfx ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) From b73d9df48b96666bceff8a4d6f4b33df57e12940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Apr 2022 14:45:19 +0200 Subject: [PATCH 2/2] Define libdfx.h as a public header and install it libdfx.h is the main public API and should be installed for programs to link against it. --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index afee1d3..92c3508 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,5 +20,6 @@ set(LIBDFX_INCLUDE_DIRS file(COPY include/libdfx.h DESTINATION ${CMAKE_BINARY_DIR}/include) add_library(dfx ${libdfx_sources}) +set_target_properties(dfx PROPERTIES PUBLIC_HEADER "include/libdfx.h") target_include_directories(dfx PUBLIC ${LIBDFX_INCLUDE_DIRS}) -install(TARGETS dfx ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS dfx ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER ${CMAKE_INSTALL_INCLUDEDIR})