Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update install-rules.cmake #74

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions cmake-init/templates/common/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,37 @@ target_link_libraries(
{= name =}::{= name =}
)
```

### Creating a VCPKG port
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Officially" vcpkg is used like a regular word in its docs, so it shouldn't be all caps.

The additional directory in the include path also affects every other form of packaging, there is no need to make it vcpkg specific. Something like a "Note to packagers" section with cautioning them to review the usage of CMAKE_INSTALL_INCLUDEDIR. This should also be guarded with {% if not exe %}.

If you wish to expose your package on vcpkg the following `portfile.cmake`

```cmake
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO <org_name/repo_name>
REF <insert git ref here>
HEAD_REF master
SHA512 <insert sha here>
)

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 %}
Expand Down
4 changes: 3 additions & 1 deletion cmake-init/templates/common/cmake/install-rules.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% if not exe %}if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_INSTALL_INCLUDEDIR include/{= name =} CACHE PATH "")
# 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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides not keeping the 80 column limit and the period at the end, I also don't feel okay about a link back to this project.

The idea of cmake-init is that it generates projects that - in a perfect world - everyone would write to begin with, so links back feel icky to me.

Something more generic about the purpose of avoiding indirect inclusion of other projects in a shared prefix would fit better.

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
Expand Down