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

add pkg-config definitions #146

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
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,7 +1,15 @@
cmake_minimum_required(VERSION 3.11...3.15)

# Setting up project
project(curlcpp LANGUAGES CXX)
project(curlcpp
VERSION 1.4
DESCRIPTION "An object oriented C++ wrapper for CURL (libcurl)"
HOMEPAGE_URL "https://github.com/JosephP91/curlcpp/"
LANGUAGES CXX)

# For the pkg-config file. Please read https://github.com/jtojnar/cmake-snips
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeScripts")
include(JoinPaths)

include(GNUInstallDirs)

Expand Down Expand Up @@ -48,4 +56,12 @@ include(CMakePackageConfigHelpers)
configure_package_config_file(CMake/curlcppConfig.cmake.in
"${PROJECT_BINARY_DIR}/curlcppConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/curlcpp")
install(FILES ${PROJECT_BINARY_DIR}/curlcppConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/curlcpp)
install(FILES ${PROJECT_BINARY_DIR}/curlcppConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/curlcpp)

join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file("${PROJECT_SOURCE_DIR}/src/curlcpp.pc.in"
"${PROJECT_BINARY_DIR}/src/curlcpp.pc"
@ONLY)
install(FILES "${PROJECT_BINARY_DIR}/src/curlcpp.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
23 changes: 23 additions & 0 deletions CMakeScripts/JoinPaths.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This module provides function for joining paths
# known from most languages
#
# SPDX-License-Identifier: (MIT OR CC0-1.0)
# Copyright 2020 Jan Tojnar
# https://github.com/jtojnar/cmake-snips
#
# Modelled after Python’s os.path.join
# https://docs.python.org/3.7/library/os.path.html#os.path.join
# Windows not supported
function(join_paths joined_path first_path_segment)
set(temp_path "${first_path_segment}")
foreach(current_segment IN LISTS ARGN)
if(NOT ("${current_segment}" STREQUAL ""))
if(IS_ABSOLUTE "${current_segment}")
set(temp_path "${current_segment}")
else()
set(temp_path "${temp_path}/${current_segment}")
endif()
endif()
endforeach()
set(${joined_path} "${temp_path}" PARENT_SCOPE)
endfunction()
12 changes: 12 additions & 0 deletions src/curlcpp.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
includedir=@includedir_for_pc_file@
libdir=@libdir_for_pc_file@

Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Version: @PROJECT_VERSION@
Requires: libcurl >= @CURL_MIN_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lcurlcpp