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

CMake: Include libenet.pc in installation #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 2.8.12...3.20)

project(enet)
# I.e. The ABI version
project(enet VERSION 7.0.5)
set(ENET_VERSION "1.3.18")

# The "configure" step.
include(CheckFunctionExists)
Expand Down Expand Up @@ -93,6 +95,10 @@ add_library(enet
${INCLUDE_FILES}
${SOURCE_FILES}
)
set_target_properties(enet PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)

if (WIN32)
target_link_libraries(enet winmm ws2_32)
Expand All @@ -104,6 +110,16 @@ install(TARGETS enet
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/enet
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove ${CMAKE_CURRENT_SOURCE_DIR}?

Copy link
Author

@h3xx h3xx Apr 29, 2024

Choose a reason for hiding this comment

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

It's not necessary. Per the CMake documentation for install() (https://cmake.org/cmake/help/latest/command/install.html):

The FILES form [i.e. install(FILES...) or install(DIRECTORY...)] specifies rules for installing files for a project. File names given as relative paths are interpreted with respect to the current source directory. Files installed by this form are by default given permissions OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given.

Try it! :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, this part looks good to me.
Don't have the knowledge to review the rest

install(DIRECTORY include/enet
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Add variables for substitution in libenet.pc.in
set(PACKAGE_VERSION ${ENET_VERSION})
set(PACKAGE_NAME "lib${PROJECT_NAME}")
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
configure_file(libenet.pc.in libenet.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libenet.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)