2022-10-04 01:53:37 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12.4)
|
|
|
|
|
2023-12-18 02:29:05 +00:00
|
|
|
if(NOT DEFINED PROJECT_NAME)
|
|
|
|
set(ARGPARSE_IS_TOP_LEVEL ON)
|
|
|
|
else()
|
|
|
|
set(ARGPARSE_IS_TOP_LEVEL OFF)
|
|
|
|
endif()
|
|
|
|
|
2022-10-04 01:53:37 +00:00
|
|
|
project(argparse
|
2023-12-18 02:29:05 +00:00
|
|
|
VERSION 3.0.0
|
2022-10-04 01:53:37 +00:00
|
|
|
DESCRIPTION "A single header argument parser for C++17"
|
|
|
|
HOMEPAGE_URL "https://github.com/p-ranav/argparse"
|
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
|
|
|
|
2023-09-01 02:09:34 +00:00
|
|
|
option(ARGPARSE_INSTALL "Include an install target" ON)
|
2023-12-18 02:29:05 +00:00
|
|
|
option(ARGPARSE_BUILD_TESTS "Build tests" ON)
|
|
|
|
option(ARGPARSE_BUILD_SAMPLES "Build samples" OFF)
|
2022-10-04 01:53:37 +00:00
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
add_library(argparse INTERFACE)
|
|
|
|
add_library(argparse::argparse ALIAS argparse)
|
|
|
|
|
|
|
|
target_compile_features(argparse INTERFACE cxx_std_17)
|
|
|
|
target_include_directories(argparse INTERFACE
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>)
|
|
|
|
|
|
|
|
if(ARGPARSE_BUILD_SAMPLES)
|
|
|
|
add_subdirectory(samples)
|
|
|
|
endif()
|
2023-12-18 02:29:05 +00:00
|
|
|
|
|
|
|
if(ARGPARSE_BUILD_TESTS AND ARGPARSE_IS_TOP_LEVEL)
|
2022-10-04 01:53:37 +00:00
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2023-12-18 02:29:05 +00:00
|
|
|
|
|
|
|
if(ARGPARSE_INSTALL AND ARGPARSE_IS_TOP_LEVEL)
|
2022-11-13 16:50:27 +00:00
|
|
|
install(TARGETS argparse EXPORT argparseConfig)
|
|
|
|
install(EXPORT argparseConfig
|
|
|
|
NAMESPACE argparse::
|
2023-09-01 02:09:34 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
|
2022-11-13 16:50:27 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_LIST_DIR}/include/argparse/argparse.hpp
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/argparse)
|
|
|
|
|
|
|
|
|
|
|
|
set(CONFIG_FILE_NAME_WITHOUT_EXT "${PROJECT_NAME}Config")
|
|
|
|
set(CMAKE_CONFIG_FILE_BASENAME "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_FILE_NAME_WITHOUT_EXT}")
|
|
|
|
set(CMAKE_CONFIG_VERSION_FILE_NAME "${CMAKE_CONFIG_FILE_BASENAME}-version.cmake")
|
|
|
|
set(CMAKE_CONFIG_FILE_NAME "${CMAKE_CONFIG_FILE_BASENAME}.cmake")
|
|
|
|
|
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER "3.14")
|
|
|
|
set(OPTIONAL_ARCH_INDEPENDENT "ARCH_INDEPENDENT")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
write_basic_package_version_file("${CMAKE_CONFIG_VERSION_FILE_NAME}"
|
|
|
|
COMPATIBILITY ExactVersion
|
|
|
|
${OPTIONAL_ARCH_INDEPENDENT}
|
|
|
|
)
|
|
|
|
|
|
|
|
export(EXPORT argparseConfig
|
|
|
|
NAMESPACE argparse::)
|
|
|
|
|
|
|
|
install(FILES "${CMAKE_CONFIG_VERSION_FILE_NAME}"
|
2023-09-01 02:09:34 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
2022-11-13 16:50:27 +00:00
|
|
|
|
|
|
|
set(PackagingTemplatesDir "${CMAKE_CURRENT_SOURCE_DIR}/packaging")
|
|
|
|
|
|
|
|
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "argparse (C++) developers")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
|
|
|
|
set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
|
|
|
|
set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}")
|
|
|
|
set(CPACK_PACKAGE_MAINTAINER "Pranav Srinivas Kumar")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_MAINTAINER}")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
|
|
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_NAME "lib${PROJECT_NAME}-dev")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6-dev")
|
|
|
|
set(CPACK_DEBIAN_PACKAGE_SUGGESTS "cmake, pkg-config, pkg-conf")
|
|
|
|
|
|
|
|
set(CPACK_RPM_PACKAGE_NAME "lib${PROJECT_NAME}-devel")
|
|
|
|
set(CPACK_RPM_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}")
|
|
|
|
|
|
|
|
set(CPACK_DEB_COMPONENT_INSTALL ON)
|
|
|
|
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
|
|
|
set(CPACK_NSIS_COMPONENT_INSTALL ON)
|
|
|
|
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
|
|
|
|
|
|
|
|
set(PKG_CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc")
|
|
|
|
configure_file("${PackagingTemplatesDir}/pkgconfig.pc.in" "${PKG_CONFIG_FILE_NAME}" @ONLY)
|
|
|
|
install(FILES "${PKG_CONFIG_FILE_NAME}"
|
2023-09-01 02:09:34 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
2022-11-13 16:50:27 +00:00
|
|
|
)
|
|
|
|
endif()
|
2023-09-01 02:09:34 +00:00
|
|
|
|
|
|
|
include(CPack)
|