From 3da07536e793a769f97455a69a11874129dd2646 Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Fri, 23 Sep 2022 16:11:45 +0200 Subject: [PATCH 1/8] Update install-rules.cmake The current install rules double indent the include folder, like so: `include/libname/libname/header.hpp` --- cmake-init/templates/common/cmake/install-rules.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index f7f69f8..e75af6c 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,7 +1,3 @@ -{% if not exe %}if(PROJECT_IS_TOP_LEVEL) - set(CMAKE_INSTALL_INCLUDEDIR include/{= name =} CACHE PATH "") -endif(){% if header %} - # Project is configured with no languages, so tell GNUInstallDirs the lib dir set(CMAKE_INSTALL_LIBDIR lib CACHE PATH ""){% end %} From b68493bb13a8cbaa5176630b1d7032a3af6b17bb Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Fri, 23 Sep 2022 21:42:26 +0200 Subject: [PATCH 2/8] Update install-rules.cmake --- cmake-init/templates/common/cmake/install-rules.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index e75af6c..ed5bfe3 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,4 +1,10 @@ # Project is configured with no languages, so tell GNUInstallDirs the lib dir +{% if not exe %}if(PROJECT_IS_TOP_LEVEL) + set(CMAKE_INSTALL_INCLUDEDIR include/{= name =}-${CMAKE_PROJECT_VERSION} CACHE PATH "") +endif(){% if header %} + + + set(CMAKE_INSTALL_LIBDIR lib CACHE PATH ""){% end %} include(CMakePackageConfigHelpers) From 4f5a537d781359d1ec8d69839f0352ffe9a15c75 Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Fri, 23 Sep 2022 21:42:45 +0200 Subject: [PATCH 3/8] Update install-rules.cmake --- cmake-init/templates/common/cmake/install-rules.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index ed5bfe3..0542f28 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,10 +1,8 @@ -# Project is configured with no languages, so tell GNUInstallDirs the lib dir {% if not exe %}if(PROJECT_IS_TOP_LEVEL) set(CMAKE_INSTALL_INCLUDEDIR include/{= name =}-${CMAKE_PROJECT_VERSION} CACHE PATH "") endif(){% if header %} - - +# Project is configured with no languages, so tell GNUInstallDirs the lib dir set(CMAKE_INSTALL_LIBDIR lib CACHE PATH ""){% end %} include(CMakePackageConfigHelpers) From 1e798132b4db5794df743f68c0f0d54fc73ed008 Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Sat, 24 Sep 2022 10:42:38 +0200 Subject: [PATCH 4/8] Update install-rules.cmake Co-authored-by: friendlyanon <1736896+friendlyanon@users.noreply.github.com> --- cmake-init/templates/common/cmake/install-rules.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index 0542f28..537ec35 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,5 +1,5 @@ {% if not exe %}if(PROJECT_IS_TOP_LEVEL) - set(CMAKE_INSTALL_INCLUDEDIR include/{= name =}-${CMAKE_PROJECT_VERSION} CACHE PATH "") + set(CMAKE_INSTALL_INCLUDEDIR "include/{= name =}-${PROJECT_VERSION}" CACHE PATH "") endif(){% if header %} # Project is configured with no languages, so tell GNUInstallDirs the lib dir From 47e7854535f111480469fc1d78e11fe94a312ed4 Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Wed, 12 Oct 2022 16:36:57 +0200 Subject: [PATCH 5/8] Update install-rules.cmake --- cmake-init/templates/common/cmake/install-rules.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index 537ec35..4d184d3 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,4 +1,6 @@ {% if not exe %}if(PROJECT_IS_TOP_LEVEL) + # CMAKE_INSTALL_INCLUDEDIR is nested in one more ${PROJECT_VERSION} directory to prevent inclusion of all other headers in the install prefix directory. + # See https://github.com/friendlyanon/cmake-init/issues/43 for more info set(CMAKE_INSTALL_INCLUDEDIR "include/{= name =}-${PROJECT_VERSION}" CACHE PATH "") endif(){% if header %} From 1dc06d4ef46084db23c7c29393d1d27be39936df Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Wed, 12 Oct 2022 17:04:55 +0200 Subject: [PATCH 6/8] Adding info on how to create a vcpkg port --- cmake-init/templates/common/BUILDING.md | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cmake-init/templates/common/BUILDING.md b/cmake-init/templates/common/BUILDING.md index 7bf6f13..f3b5812 100644 --- a/cmake-init/templates/common/BUILDING.md +++ b/cmake-init/templates/common/BUILDING.md @@ -79,6 +79,37 @@ target_link_libraries( {= name =}::{= name =} ) ``` + +### Creating a VCPKG port +If you wish to expose your package on vcpkg the following `portfile.cmake` + +```cmake +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO + REF + HEAD_REF master + SHA512 +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DCMAKE_INSTALL_INCLUDEDIR=${CURRENT_PACKAGES_DIR}/include" +) + +vcpkg_cmake_build() + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +``` + {% end %} [1]: https://cmake.org/download/ [2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project{% if not exe %} From f338e0ed9112fc8304f36c7eb6f786b629f1f6bf Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Thu, 13 Oct 2022 09:29:08 +0200 Subject: [PATCH 7/8] Update BUILDING.md --- cmake-init/templates/common/BUILDING.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake-init/templates/common/BUILDING.md b/cmake-init/templates/common/BUILDING.md index f3b5812..812a3e0 100644 --- a/cmake-init/templates/common/BUILDING.md +++ b/cmake-init/templates/common/BUILDING.md @@ -80,7 +80,12 @@ target_link_libraries( ) ``` -### Creating a VCPKG port +### Note to packagers +If you wish to expose your library as a package, you should carefully review how +`CMAKE_INSTALL_INCLUDEDIR` is set, as the default behavior might not match your +package mangagers expectations. + +#### Creating a vcpkg port If you wish to expose your package on vcpkg the following `portfile.cmake` ```cmake @@ -107,7 +112,9 @@ vcpkg_cmake_config_fixup() file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") -file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) +file(INSTALL "${SOURCE_PATH}/LICENSE" + DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" + RENAME copyright) ``` {% end %} From bbf2b2e2f4b758bb58603915ea5ce44eda3fddd7 Mon Sep 17 00:00:00 2001 From: Anders Wind Date: Thu, 13 Oct 2022 09:33:16 +0200 Subject: [PATCH 8/8] Update install-rules.cmake --- cmake-init/templates/common/cmake/install-rules.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake-init/templates/common/cmake/install-rules.cmake b/cmake-init/templates/common/cmake/install-rules.cmake index 4d184d3..40bd4c9 100644 --- a/cmake-init/templates/common/cmake/install-rules.cmake +++ b/cmake-init/templates/common/cmake/install-rules.cmake @@ -1,6 +1,7 @@ {% if not exe %}if(PROJECT_IS_TOP_LEVEL) - # CMAKE_INSTALL_INCLUDEDIR is nested in one more ${PROJECT_VERSION} directory to prevent inclusion of all other headers in the install prefix directory. - # See https://github.com/friendlyanon/cmake-init/issues/43 for more info + # CMAKE_INSTALL_INCLUDEDIR is nested in one more "{= name =}-${PROJECT_VERSION}" + # directory to prevent direct inclusion of headers from other libraries + # which share the prefix directory. set(CMAKE_INSTALL_INCLUDEDIR "include/{= name =}-${PROJECT_VERSION}" CACHE PATH "") endif(){% if header %}