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
12 changes: 6 additions & 6 deletions .github/actions/cmake-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
args:
description: "Other arguments"
required: false
default: ""
default: -D_7BIT_DI_BUILD_TESTS:BOOL=true -D_7BIT_DI_BUILD_EXAMPLES:BOOL=true
build-type:
description: "Build type"
required: false
Expand All @@ -13,10 +13,10 @@ inputs:
description: "Toolchain file"
required: false
default: conan_toolchain.cmake
shared-lib:
description: "Shared lib"
library-type:
description: "Library type"
required: false
default: "OFF"
default: Static
build-dir:
description: "Build directory"
required: true
Expand All @@ -26,10 +26,10 @@ runs:
steps:
- name: Configure CMake
working-directory: ${{ inputs.build-dir }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -DSEVEN_BIT_DI_BUILD_SHARED:STRING="${{ inputs.shared-lib }}" -DCMAKE_TOOLCHAIN_FILE:STRING="${{ inputs.toolchain }}" -DSEVEN_BIT_DI_BUILD_TESTS:BOOL=true -DSEVEN_BIT_DI_BUILD_EXAMPLES:BOOL=true ${{ inputs.args }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{ inputs.build-type }} -D_7BIT_DI_LIBRARY_TYPE=${{ inputs.library-type }} -DCMAKE_TOOLCHAIN_FILE:STRING="${{ inputs.toolchain }}" ${{ inputs.args }}
shell: pwsh

- name: Build
working-directory: ${{ inputs.build-dir }}
run: cmake --build . --config ${{ inputs.build-type }}
shell: pwsh
shell: pwsh
4 changes: 2 additions & 2 deletions .github/workflows/DevCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
shared-lib: ["ON", "OFF"]
libraryType: [HeaderOnly, Static, Shared]
os: [ubuntu-22.04, macos-12, windows-2022]

runs-on: ${{matrix.os}}
Expand All @@ -35,7 +35,7 @@ jobs:
with:
build-dir: ${{ env.BUILD_DIR }}
build-type: ${{ env.BUILD_TYPE }}
shared-lib: ${{ matrix.shared-lib }}
library-type: ${{ matrix.libraryType }}

- name: Test
working-directory: ${{ env.BUILD_DIR }}
Expand Down
57 changes: 34 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
cmake_minimum_required(VERSION 3.15.0)

set(SEVEN_BIT_DI_PROJECT_NAME 7bitDI)
set(_7BIT_DI_VERSION_MAJOR 1)
set(_7BIT_DI_VERSION_MINOR 0)
set(_7BIT_DI_VERSION_PATCH 0)

set(SEVEN_BIT_DI_VERSION_MAJOR 1)
set(SEVEN_BIT_DI_VERSION_MINOR 0)
set(SEVEN_BIT_DI_VERSION_PATCH 0)
set(_7BIT_DI_VERSION ${_7BIT_DI_VERSION_MAJOR}.${_7BIT_DI_VERSION_MINOR}.${_7BIT_DI_VERSION_PATCH})

set(SEVEN_BIT_DI_VERSION ${SEVEN_BIT_DI_VERSION_MAJOR}.${SEVEN_BIT_DI_VERSION_MINOR}.${SEVEN_BIT_DI_VERSION_PATCH})
project(7bitDI LANGUAGES CXX VERSION ${_7BIT_DI_VERSION})

project(${SEVEN_BIT_DI_PROJECT_NAME} VERSION ${SEVEN_BIT_DI_VERSION})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/Cmake)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Cmake")

include_directories(Include)
include(Setup)
Expand All @@ -20,33 +18,46 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(Source)

if(SEVEN_BIT_DI_BUILD_DOCS)
if(_7BIT_DI_BUILD_DOCS)
add_subdirectory(Docs)
endif()

if(SEVEN_BIT_DI_BUILD_TESTS OR SEVEN_BIT_DI_BUILD_TESTS_HO)
if(_7BIT_DI_BUILD_TESTS)
include(GoogleTest)
include(CPack)
enable_testing()

add_subdirectory(Tests)
endif()

if(SEVEN_BIT_DI_BUILD_EXAMPLES OR SEVEN_BIT_DI_BUILD_EXAMPLE_HO)
if(_7BIT_DI_BUILD_EXAMPLES)
add_subdirectory(Examples)
endif()

install(DIRECTORY ${SEVEN_BIT_DI_HEADERS_DIR}/ DESTINATION include)
if(_7BIT_DI_INSTALL)
install(DIRECTORY ${_7BIT_DI_HEADERS_DIR}/ DESTINATION include)

export(
TARGETS 7BitDI
NAMESPACE 7BitDI::
FILE ${CONFIG_TARGETS_FILE})

install(
EXPORT 7BitDI
DESTINATION ${EXPORT_DEST_DIR}
NAMESPACE 7BitDI::
FILE ${CONFIG_TARGETS_FILE})

export(
TARGETS 7BitDI
NAMESPACE 7BitDI::
FILE ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_TARGETS_FILE})
install(EXPORT 7BitDI DESTINATION ${EXPORT_DEST_DIR} NAMESPACE 7BitDI:: FILE ${CONFIG_TARGETS_FILE})
include(CMakePackageConfigHelpers)

include(CMakePackageConfigHelpers)
configure_package_config_file(${PROJECT_CONFIG_IN} ${PROJECT_CONFIG_OUT}
INSTALL_DESTINATION ${EXPORT_DEST_DIR})
configure_package_config_file(${PROJECT_CONFIG_IN} ${PROJECT_CONFIG_OUT}
INSTALL_DESTINATION ${EXPORT_DEST_DIR})

write_basic_package_version_file(${VERSIONS_CONFIG_FILE} COMPATIBILITY SameMajorVersion)
install(FILES ${PROJECT_CONFIG_OUT} ${VERSIONS_CONFIG_FILE} DESTINATION ${EXPORT_DEST_DIR})
write_basic_package_version_file(${VERSIONS_CONFIG_FILE} COMPATIBILITY SameMajorVersion)
install(FILES ${PROJECT_CONFIG_OUT} ${VERSIONS_CONFIG_FILE} DESTINATION ${EXPORT_DEST_DIR})

include(7bitDIGeneratePkgConfig)

export(PACKAGE 7bitDI)

include(CPack)
endif()
12 changes: 12 additions & 0 deletions Cmake/7bitDI.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@PKG_CONFIG_INCLUDEDIR@
libdir=@PKG_CONFIG_LIBDIR@

Name: lib@PROJECT_NAME@
Description: Fast C++ logging library.
URL: https://github.com/7bitcoder/@PROJECT_NAME@
Version: @_7BIT_DI_VERSION@
CFlags: -I${includedir} @PKG_CONFIG_DEFINES@
Libs: -L${libdir} -lspdlog -pthread
Requires: @PKG_CONFIG_REQUIRES@
2 changes: 1 addition & 1 deletion Cmake/7bitDIConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}")

check_required_components(spdlog)
check_required_components(7bitDI)
3 changes: 3 additions & 0 deletions Cmake/7bitDIGeneratePkgConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
configure_file("cmake/7bitDI.pc.in" "7bitDI.pc" @ONLY)

install(FILES "${PROJECT_BINARY_DIR}/7bitDI.pc" DESTINATION "lib/pkgconfig")
83 changes: 51 additions & 32 deletions Cmake/Setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,80 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)

set(CPACK_PROJECT_NAME ${SEVEN_BIT_DI_PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${SEVEN_BIT_DI_VERSION})
set(CPACK_PROJECT_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${_7BIT_DI_VERSION})
set(CPACK_PACKAGE_VENDOR "github.com/7bitcoder/7bitDI")
set(CPACK_PACKAGE_CONTACT "https://${CPACK_PACKAGE_VENDOR}")
set(CPACK_PACKAGE_VERSION_MAJOR ${_7BIT_DI_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${_7BIT_DI_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${_7BIT_DI_VERSION_PATCH})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "7bitInjector is a simple C++ dependency injection library")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")

set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/publish)

set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:\$ORIGIN/../bin:\$ORIGIN)

set(SEVEN_BIT_DI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/Include")
set(_7BIT_DI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/Include")

file(GLOB SEVEN_BIT_DI_TOP_HEADERS "${SEVEN_BIT_DI_HEADERS_DIR}/SevenBit/DI/*.hpp")
file(GLOB SEVEN_BIT_DI_DETAILS_HEADERS "${SEVEN_BIT_DI_HEADERS_DIR}/SevenBit/DI/Details/*.hpp")
file(GLOB SEVEN_BIT_DI_IMPL_HEADERS "${SEVEN_BIT_DI_HEADERS_DIR}/SevenBit/DI/Impl/*.hpp")
set(SEVEN_BIT_DI_ALL_HEADERS ${SEVEN_BIT_DI_TOP_HEADERS} ${SEVEN_BIT_DI_DETAILS_HEADERS} ${SEVEN_BIT_DI_IMPL_HEADERS})
file(GLOB _7BIT_DI_TOP_HEADERS "${_7BIT_DI_HEADERS_DIR}/SevenBit/DI/*.hpp")
file(GLOB _7BIT_DI_DETAILS_HEADERS "${_7BIT_DI_HEADERS_DIR}/SevenBit/DI/Details/*.hpp")
file(GLOB _7BIT_DI_IMPL_HEADERS "${_7BIT_DI_HEADERS_DIR}/SevenBit/DI/Impl/*.hpp")
set(_7BIT_DI_ALL_HEADERS ${_7BIT_DI_TOP_HEADERS} ${_7BIT_DI_DETAILS_HEADERS} ${_7BIT_DI_IMPL_HEADERS})

source_group("Header Files\\SevenBit" FILES ${SEVEN_BIT_DI_TOP_HEADERS})
source_group("Header Files\\SevenBit\\Details" FILES ${SEVEN_BIT_DI_DETAILS_HEADERS})
source_group("Header Files\\SevenBit\\Details\\Impl" FILES ${SEVEN_BIT_DI_IMPL_HEADERS})
source_group("Header Files\\SevenBit" FILES ${_7BIT_DI_TOP_HEADERS})
source_group("Header Files\\SevenBit\\Details" FILES ${_7BIT_DI_DETAILS_HEADERS})
source_group("Header Files\\SevenBit\\Details\\Impl" FILES ${_7BIT_DI_IMPL_HEADERS})

# build shared option
option(SEVEN_BIT_DI_BUILD_SHARED "Build shared library" OFF)
option(_7BIT_DI_LIBRARY_TYPE "Library build type: Shared;Static;HeaderOnly" "Static")

# build position independent code
option(SEVEN_BIT_DI_BUILD_PIC "Build position independent code (-fPIC)" OFF)
option(_7BIT_DI_LIBRARY_TYPE_VALUES "List of possible BUILD_LIBRARY_Type values" "Shared;Static;HeaderOnly")

# example options
option(SEVEN_BIT_DI_BUILD_EXAMPLES "Build example" OFF)
option(SEVEN_BIT_DI_BUILD_EXAMPLES_HO "Build header only example" OFF)
set_property(CACHE _7BIT_DI_LIBRARY_TYPE PROPERTY STRINGS ${_7BIT_DI_LIBRARY_TYPE_VALUES})

# testing options
option(SEVEN_BIT_DI_BUILD_TESTS "Build tests" OFF)
option(SEVEN_BIT_DI_BUILD_TESTS_HO "Build tests using the header only version" OFF)
option(_7BIT_DI_BUILD_SHARED "Build shared library" OFF)

# build documentation option (requires sphinx and doxygen installed)
option(SEVEN_BIT_DI_BUILD_DOCS "Turn on to build documentation" OFF)
option(_7BIT_DI_BUILD_PIC "Build position independent code (-fPIC)" OFF)

if(SEVEN_BIT_DI_BUILD_PIC)
option(_7BIT_DI_BUILD_EXAMPLES "Build example" OFF)

option(_7BIT_DI_BUILD_TESTS "Build tests" OFF)

option(_7BIT_DI_BUILD_DOCS "Turn on to build documentation (requires sphinx and doxygen installed)" OFF)

option(_7BIT_DI_INSTALL "Installs 7bitDI" OFF)

if(_7BIT_DI_BUILD_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

if(_7BIT_DI_LIBRARY_TYPE STREQUAL "Shared")
set(_7BIT_DI_BUILD_LIBRARY_TYPE "Shared")
set(_7BIT_DI_SHARED_LIB true)
elseif(_7BIT_DI_LIBRARY_TYPE STREQUAL "HeaderOnly")
set(_7BIT_DI_BUILD_LIBRARY_TYPE "HeaderOnly")
set(_7BIT_DI_HEADER_ONLY_LIB true)
else()
set(_7BIT_DI_BUILD_LIBRARY_TYPE "Static")
set(_7BIT_DI_STATIC_LIB true)
endif()

set(PROJECT_CONFIG_IN ${CMAKE_SOURCE_DIR}/Cmake/7bitDIConfig.cmake.in)
set(PROJECT_CONFIG_OUT ${CMAKE_BINARY_DIR}/7bitDIConfig.cmake)
set(CONFIG_TARGETS_FILE 7bitDIConfigTargets.cmake)
set(VERSIONS_CONFIG_FILE ${CMAKE_BINARY_DIR}/7bitDIConfigVersion.cmake)
set(EXPORT_DEST_DIR cmake/7bitDI)
set(EXPORT_DEST_DIR lib/cmake/7bitDI)

configure_file(${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/Version.hpp.input ${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/Version.hpp)
configure_file(${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/CmakeDef.hpp.input ${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/CmakeDef.hpp)

set(INFOS
"${SEVEN_BIT_DI_PROJECT_NAME} version: ${SEVEN_BIT_DI_VERSION}"
"${SEVEN_BIT_DI_PROJECT_NAME} build as shared library ${SEVEN_BIT_DI_BUILD_SHARED} "
"${CMAKE_PROJECT_NAME} version: ${_7BIT_DI_VERSION}"
"${CMAKE_PROJECT_NAME} build as ${_7BIT_DI_BUILD_LIBRARY_TYPE} library"
"=================================================="
"Build tests: ${SEVEN_BIT_DI_BUILD_TESTS}"
"Build tests header only: ${SEVEN_BIT_DI_BUILD_TESTS_HO}"
"Build examples: ${SEVEN_BIT_DI_BUILD_EXAMPLES}"
"Build examples header only: ${SEVEN_BIT_DI_BUILD_EXAMPLES_HO}"
"Build documentation: ${SEVEN_BIT_DI_BUILD_DOCS}"
"Build tests: ${_7BIT_DI_BUILD_TESTS}"
"Build examples: ${_7BIT_DI_BUILD_EXAMPLES}"
"Build documentation: ${_7BIT_DI_BUILD_DOCS}"
)
printInfo("${INFOS}" = 50 7 0)
8 changes: 4 additions & 4 deletions Docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_custom_target(GenerateDoc
${SHPHINX_RST_FILES}
)

include(GNUInstallDirs)

install(DIRECTORY ${SPHINX_BUILD}
DESTINATION doc)
if(_7BIT_DI_INSTALL)
install(DIRECTORY ${SPHINX_BUILD}
DESTINATION doc)
endif()
4 changes: 2 additions & 2 deletions Docs/conf.in.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def createIfNotExists(path):
os.makedirs(path)


project = "@SEVEN_BIT_DI_PROJECT_NAME@"
project = "@CMAKE_PROJECT_NAME@"
copyright = "2023, 7BitCoder Sylwester Dawida"
author = "Sylwester Dawida"
version = "@SEVEN_BIT_DI_VERSION@"
version = "@_7BIT_DI_VERSION@"

extensions = [
"sphinx.ext.autodoc",
Expand Down
2 changes: 1 addition & 1 deletion Docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Installation

#. Building library as Static/Shared
Download source code from the most recent release,
build the project using CMake_, set CMake cache var "SEVEN_BIT_DI_BUILD_SHARED" to build Shared library,
build the project using CMake_, set CMake cache var "_7BIT_DI_BUILD_SHARED" to build Shared library,
run install command

.. code-block:: sh
Expand Down
16 changes: 6 additions & 10 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ foreach(SOURCE ${SOURCES})
${SOURCE}
)

if(SEVEN_BIT_DI_BUILD_EXAMPLE_HO)
target_link_libraries(${FILE_NAME}
7BitDI_header_only
)
else()
target_link_libraries(${FILE_NAME}
7BitDI
)
endif()
target_link_libraries(${FILE_NAME}
7BitDI
)

install(TARGETS ${FILE_NAME})
if(_7BIT_DI_INSTALL)
install(TARGETS ${FILE_NAME})
endif()
endforeach()
1 change: 0 additions & 1 deletion Examples/Simple.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "SevenBit/DI/Version.hpp"
#include <SevenBit/DI.hpp>
#include <iostream>

Expand Down
27 changes: 27 additions & 0 deletions Include/SevenBit/DI/CmakeDef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

/* #undef _7BIT_DI_SHARED_LIB */
/* #undef _7BIT_DI_STATIC_LIB */
#define _7BIT_DI_HEADER_ONLY_LIB


#define _7BIT_DI_VERSION_MAJOR 1
/* #undef _7BIT_DI_VERSION_MINOR */
/* #undef _7BIT_DI_VERSION_PATCH */

#define _7BIT_DI_VERSION "1.0.0"

#ifndef _7BIT_DI_VERSION_MAJOR
#define _7BIT_DI_VERSION_MAJOR 0
#endif

#ifndef _7BIT_DI_VERSION_MINOR
#define _7BIT_DI_VERSION_MINOR 0
#endif

#ifndef _7BIT_DI_VERSION_PATCH
#define _7BIT_DI_VERSION_PATCH 0
#endif

#define _7BIT_DI_VERSION_AS_NUMBER \
(_7BIT_DI_VERSION_MAJOR * 10000 + _7BIT_DI_VERSION_MINOR * 100 + _7BIT_DI_VERSION_PATCH)
Loading