Skip to content
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
55 changes: 55 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
* text=auto eol=lf

# Source and build files
*.c text eol=lf
*.cc text eol=lf
*.cpp text eol=lf
*.cxx text eol=lf
*.h text eol=lf
*.hh text eol=lf
*.hpp text eol=lf
*.hxx text eol=lf
*.inl text eol=lf
*.ipp text eol=lf
CMakeLists.txt text eol=lf
*.cmake text eol=lf
CMakePresets.json text eol=lf
CTestPresets.json text eol=lf

# Project and config files
*.txt text eol=lf
*.md text eol=lf
*.json text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
*.ini text eol=lf
*.cfg text eol=lf
*.conf text eol=lf
*.clang-format text eol=lf
*.clang-tidy text eol=lf
*.clangd text eol=lf
.gitignore text eol=lf
.gitattributes text eol=lf
.gitmodules text eol=lf
.editorconfig text eol=lf
Dockerfile text eol=lf
Doxyfile.in text eol=lf

# Scripts
*.sh text eol=lf
*.bash text eol=lf
*.py text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# Binary assets
*.png binary
*.gif binary
*.jpg binary
*.jpeg binary
*.ico binary
*.zip binary
*.gz binary
*.7z binary
23 changes: 12 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,29 @@ jobs:
- build_type: Release

env:
EXTERNAL_ROOT: /home/runner/3party
BUILD_TYPE: ${{ matrix.build_type }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install latest Boost
shell: bash
run: |
sudo apt-add-repository ppa:mhier/libboost-latest
sudo apt install libboost1.74-dev
- name: Setup vcpkg (with binary caching)
uses: lukka/run-vcpkg@v11
with:
runVcpkgInstall: false
vcpkgDirectory: "${{ github.workspace }}/.vcpkg"
vcpkgGitCommitId: "58950f88544e4637524dbd6a01d0317cf4cb77fc"

- name: Install dependencies from source
run: .ci/fetch_system_dependencies.sh
- name: Install dependencies
shell: bash
run: $VCPKG_ROOT/vcpkg install boost-asio boost-signals2 boost-smart-ptr gtest

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PREFIX_PATH=$EXTERNAL_ROOT
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake

- name: Build
shell: bash
Expand All @@ -48,7 +49,7 @@ jobs:
- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
run: ctest -C $BUILD_TYPE
run: ctest -C $BUILD_TYPE --output-on-failure

build-docs:
runs-on: ubuntu-latest
Expand Down
50 changes: 36 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
project(CONSOLEPP VERSION 0.1.1)
else()
project(CONSOLEPP)
endif()

cmake_minimum_required(VERSION 3.22 FATAL_ERROR)
cmake_policy(VERSION 3.22)
project(CONSOLEPP VERSION 0.1.1)

option(CONOSOLEPP_COVERAGE "Build with code coverage options")
option(CONSOLEPP_SANITIZE "Build using sanitizers" "")
Expand Down Expand Up @@ -45,12 +40,15 @@ set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

# If we are building with tests, then we require the GTest library
if (${CONSOLEPP_WITH_TESTS})
find_package(GTest REQUIRED)
find_package(GTest CONFIG REQUIRED)
endif()

# Console++ requires at least Boost 1.69.
find_package(Boost 1.69.0 REQUIRED)

# GTest imported targets depend on Threads::Threads in this toolchain.
find_package(Threads REQUIRED)

# When building shared objects, etc., we only want to export certain symbols.
# Therefore, we need to generate a header suitable for declaring which
# symbols should be included.
Expand All @@ -69,12 +67,21 @@ endif()
add_library(consolepp)
add_library(KazDragon::consolepp ALIAS consolepp)

set(CONSOLEPP_GENERATED_INCLUDE_DIR
"${PROJECT_BINARY_DIR}/generated/include")
set(CONSOLEPP_GENERATED_EXPORT_HEADER
"${CONSOLEPP_GENERATED_INCLUDE_DIR}/consolepp/detail/export.hpp")
set(CONSOLEPP_GENERATED_VERSION_HEADER
"${CONSOLEPP_GENERATED_INCLUDE_DIR}/consolepp/version.hpp")

file(MAKE_DIRECTORY "${CONSOLEPP_GENERATED_INCLUDE_DIR}/consolepp/detail")

target_sources(consolepp
PRIVATE
include/consolepp/detail/export.hpp
${CONSOLEPP_GENERATED_EXPORT_HEADER}
include/consolepp/console.hpp
include/consolepp/core.hpp
include/consolepp/version.hpp
${CONSOLEPP_GENERATED_VERSION_HEADER}

src/console.cpp
)
Expand All @@ -86,6 +93,7 @@ target_link_libraries(consolepp

target_include_directories(consolepp
PUBLIC
$<BUILD_INTERFACE:${CONSOLEPP_GENERATED_INCLUDE_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/consolepp-${CONSOLEPP_VERSION}>
)
Expand Down Expand Up @@ -117,12 +125,12 @@ target_compile_options(consolepp
)

generate_export_header(consolepp
EXPORT_FILE_NAME "${PROJECT_SOURCE_DIR}/include/consolepp/detail/export.hpp"
EXPORT_FILE_NAME "${CONSOLEPP_GENERATED_EXPORT_HEADER}"
)

configure_file(
${PROJECT_SOURCE_DIR}/include/consolepp/version.hpp.in
${PROJECT_SOURCE_DIR}/include/consolepp/version.hpp
${CONSOLEPP_GENERATED_VERSION_HEADER}
@ONLY)

include(GNUInstallDirs)
Expand Down Expand Up @@ -178,6 +186,20 @@ install(
${CMAKE_INSTALL_INCLUDEDIR}/consolepp-${CONSOLEPP_VERSION}
)

install(
FILES
"${CONSOLEPP_GENERATED_EXPORT_HEADER}"
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/consolepp-${CONSOLEPP_VERSION}/consolepp/detail
)

install(
FILES
"${CONSOLEPP_GENERATED_VERSION_HEADER}"
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/consolepp-${CONSOLEPP_VERSION}/consolepp
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/consolepp-config.cmake"
Expand All @@ -199,8 +221,8 @@ if (CONSOLEPP_WITH_TESTS)
target_link_libraries(consolepp_tester
PRIVATE
consolepp
GTest::GTest
GTest::Main
GTest::gtest
GTest::gtest_main
)

add_test(consolepp_test consolepp_tester)
Expand Down
4 changes: 4 additions & 0 deletions cmake/consolepp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(Boost 1.69.0)

include(${CMAKE_CURRENT_LIST_DIR}/consolepp-targets.cmake)
check_required_components(consolepp)
Loading