-
Notifications
You must be signed in to change notification settings - Fork 146
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
Export cmake config set with namespace #165
Open
ClausKlein
wants to merge
3
commits into
docopt:master
Choose a base branch
from
ClausKlein:develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | ||
name: CMake on multiple platforms | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: false | ||
|
||
# Set up a matrix to run the following 3 configurations: | ||
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | ||
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | ||
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | ||
# | ||
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
build_type: [Release] | ||
c_compiler: [gcc, clang, cl] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
- os: ubuntu-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
c_compiler: cl | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set reusable strings | ||
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-D CMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-D WITH_TESTS=YES | ||
-D WITH_EXAMPLE=YES | ||
-S ${{ github.workspace }} | ||
|
||
- name: Build | ||
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | ||
|
||
- name: Test | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | ||
run: ctest --build-config ${{ matrix.build_type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(docopt.cpp VERSION 0.6.2) | ||
cmake_minimum_required(VERSION 3.21...3.27) | ||
project(docopt.cpp VERSION 0.6.3) | ||
|
||
include(GNUInstallDirs) | ||
|
||
|
@@ -16,31 +16,32 @@ option(USE_BOOST_REGEX "Replace std::regex with Boost.Regex" OFF) | |
# C++ standard | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
if(NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 11) | ||
set(CMAKE_CXX_STANDARD 11) | ||
if(NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
#============================================================================ | ||
# Sources & headers | ||
#============================================================================ | ||
set(docopt_SOURCES docopt.cpp) | ||
set(docopt_HEADERS | ||
docopt.h | ||
docopt_private.h | ||
docopt_util.h | ||
docopt_value.h | ||
) | ||
docopt.h | ||
docopt_private.h | ||
docopt_util.h | ||
docopt_value.h | ||
) | ||
|
||
#============================================================================ | ||
# Compile targets | ||
#============================================================================ | ||
add_library(docopt ${docopt_SOURCES} ${docopt_HEADERS}) | ||
add_library(docopt::docopt ALIAS docopt) | ||
set_target_properties(docopt PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
) | ||
|
||
target_include_directories(docopt PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> $<INSTALL_INTERFACE:include/docopt>) | ||
target_include_directories(docopt PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICT this would change the include dir from |
||
|
||
if(MSVC AND BUILD_SHARED_LIBS) | ||
# DOCOPT_DLL: Must be specified when building *and* when using the DLL. | ||
|
@@ -56,9 +57,9 @@ if(USE_BOOST_REGEX) | |
# This is needed on Linux, where linking a static library into docopt.so | ||
# fails because boost static libs are not compiled with -fPIC | ||
set(Boost_USE_STATIC_LIBS OFF) | ||
find_package(Boost 1.53 REQUIRED COMPONENTS regex) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
target_link_libraries(docopt ${Boost_LIBRARIES}) | ||
find_package(Boost 1.71 REQUIRED COMPONENTS regex) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
target_link_libraries(docopt ${Boost_LIBRARIES}) | ||
endif() | ||
|
||
#============================================================================ | ||
|
@@ -73,14 +74,16 @@ endif() | |
# Tests | ||
#============================================================================ | ||
if(WITH_TESTS) | ||
enable_testing() | ||
|
||
set(TESTPROG "${CMAKE_CURRENT_BINARY_DIR}/run_testcase") | ||
set(TESTCASES "${PROJECT_SOURCE_DIR}/testcases.docopt") | ||
add_executable(run_testcase run_testcase.cpp) | ||
target_link_libraries(run_testcase docopt) | ||
configure_file( | ||
"${PROJECT_SOURCE_DIR}/run_tests.py" | ||
"${CMAKE_CURRENT_BINARY_DIR}/run_tests" | ||
ESCAPE_QUOTES | ||
"${PROJECT_SOURCE_DIR}/run_tests.py" | ||
"${CMAKE_CURRENT_BINARY_DIR}/run_tests" | ||
ESCAPE_QUOTES | ||
) | ||
add_test("Testcases docopt" ${TESTPROG}) | ||
endif() | ||
|
@@ -97,13 +100,13 @@ install(TARGETS docopt EXPORT ${export_name} | |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
||
# Development package | ||
install(FILES ${docopt_HEADERS} DESTINATION include/docopt) | ||
install(FILES ${docopt_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/docopt) | ||
|
||
# CMake Package | ||
include(CMakePackageConfigHelpers) | ||
write_basic_package_version_file("${PROJECT_BINARY_DIR}/docopt-config-version.cmake" COMPATIBILITY SameMajorVersion) | ||
install(FILES docopt-config.cmake ${PROJECT_BINARY_DIR}/docopt-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") | ||
install(EXPORT ${export_name} DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt") | ||
install(EXPORT ${export_name} DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/docopt" NAMESPACE docopt::docopt) | ||
|
||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docopt.pc.in ${CMAKE_CURRENT_BINARY_DIR}/docopt.pc @ONLY) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/docopt.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "docopt.h" | ||
#include "docopt/docopt.h" | ||
|
||
#include <iostream> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make reviewing easier if whitespace change (in .github/workflows/cmake-multi-platform.yml) were in a separate commit