mirror of
https://github.com/jarro2783/cxxopts.git
synced 2026-01-18 01:11:24 +01:00
Fix a number of packaging issues (#423)
* cmake: set PROJECT_DESCRIPTION and PROJECT_HOMEPAGE_URL after project() Otherwise they are set to an empty string. * cmake: set the pkg-config URL field Since the information is already there to set it. * cmake: use CMAKE_INSTALL_DATAROOTDIR if CMAKE_LIBRARY_ARCHITECTURE is unset This causes files on NixOS to be put in the proper architecture independent place, which otherwise was selecting the architecture dependent location. * cmake: Properly set pkg-config requires when configured with ICU In this case the pkg-config file needs to set icu-cu in the `Required` field, and needs to add the flag `-DCXXOPTS_USE_UNICODE` to the `Cflags` field. * cmake: cxxopts is not arch independent when built with ICU support Since it links to an architecture dependent ICU
This commit is contained in:
@@ -21,8 +21,6 @@ cmake_minimum_required(VERSION 3.1...3.19)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||
include(cxxopts)
|
||||
set("PROJECT_DESCRIPTION" "A header-only lightweight C++ command line option parser")
|
||||
set("PROJECT_HOMEPAGE_URL" "https://github.com/jarro2783/cxxopts")
|
||||
|
||||
# Get the version of the library
|
||||
cxxopts_getversion(VERSION)
|
||||
@@ -32,6 +30,9 @@ project(cxxopts
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
set("PROJECT_DESCRIPTION" "A header-only lightweight C++ command line option parser")
|
||||
set("PROJECT_HOMEPAGE_URL" "https://github.com/jarro2783/cxxopts")
|
||||
|
||||
# Must include after the project call due to GNUInstallDirs requiring a language be enabled (IE. CXX)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
|
||||
@@ -87,10 +87,17 @@ endfunction()
|
||||
|
||||
# Helper function to ecapsulate install logic
|
||||
function(cxxopts_install_logic)
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE)
|
||||
string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}")
|
||||
if(NOT CXXOPTS_USE_UNICODE_HELP)
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE)
|
||||
string(REPLACE "/${CMAKE_LIBRARY_ARCHITECTURE}" "" CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
# On some systems (e.g. NixOS), `CMAKE_LIBRARY_ARCHITECTURE` can be empty
|
||||
set(CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_DATAROOTDIR}")
|
||||
endif()
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "3.14")
|
||||
set(OPTIONAL_ARCH_INDEPENDENT "ARCH_INDEPENDENT")
|
||||
endif()
|
||||
else()
|
||||
# On some systems (e.g. NixOS), `CMAKE_LIBRARY_ARCHITECTURE` can be empty
|
||||
set(CMAKE_INSTALL_LIBDIR_ARCHIND "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
set(CXXOPTS_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR_ARCHIND}/cmake/cxxopts" CACHE STRING "Installation directory for cmake files, relative to ${CMAKE_INSTALL_PREFIX}.")
|
||||
@@ -99,11 +106,6 @@ function(cxxopts_install_logic)
|
||||
set(targets_export_name cxxopts-targets)
|
||||
set(PackagingTemplatesDir "${PROJECT_SOURCE_DIR}/packaging")
|
||||
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "3.14")
|
||||
set(OPTIONAL_ARCH_INDEPENDENT "ARCH_INDEPENDENT")
|
||||
endif()
|
||||
|
||||
# Generate the version, config and target files into the build directory.
|
||||
write_basic_package_version_file(
|
||||
${version_config}
|
||||
@@ -154,6 +156,10 @@ function(cxxopts_install_logic)
|
||||
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
|
||||
|
||||
set(PKG_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc")
|
||||
if(CXXOPTS_USE_UNICODE_HELP)
|
||||
set(PKG_CONFIG_REQUIRES "icu-cu")
|
||||
set(PKG_CONFIG_EXTRA_CFLAGS "-DCXXOPTS_USE_UNICODE")
|
||||
endif()
|
||||
configure_file("${PackagingTemplatesDir}/pkgconfig.pc.in" "${PKG_CONFIG_FILE_NAME}" @ONLY)
|
||||
install(FILES "${PKG_CONFIG_FILE_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR_ARCHIND}/pkgconfig"
|
||||
|
||||
@@ -3,5 +3,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: @PROJECT_NAME@
|
||||
Description: @PROJECT_DESCRIPTION@
|
||||
URL: @PROJECT_HOMEPAGE_URL@
|
||||
Version: @PROJECT_VERSION@
|
||||
Cflags: -I${includedir}
|
||||
Requires: @PKG_CONFIG_REQUIRES@
|
||||
Cflags: -I${includedir} @PKG_CONFIG_EXTRA_CFLAGS@
|
||||
|
||||
Reference in New Issue
Block a user