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
20 changes: 18 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project(7bitDI LANGUAGES CXX VERSION ${_7BIT_DI_VERSION})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Cmake")

include(Setup)
include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -39,17 +40,32 @@ if(_7BIT_DI_BUILD_SINGLE_HEADER)
endif()

if(_7BIT_DI_INSTALL)
install(DIRECTORY ${_7BIT_DI_HEADERS_DIR}/ DESTINATION include)
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_CURRENT_BINARY_DIR}/7bitDIConfigVersion.cmake)
set(EXPORT_DEST_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/7bitDI)

install(DIRECTORY ${_7BIT_DI_HEADERS_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(
TARGETS 7bitDI
EXPORT 7bitDI
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

export(
TARGETS 7bitDI
NAMESPACE 7bitDI::
FILE ${CONFIG_TARGETS_FILE})
FILE ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_TARGETS_FILE})

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

include(CMakePackageConfigHelpers)
Expand Down
11 changes: 1 addition & 10 deletions Cmake/Setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ 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(_7BIT_DI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/Include")

set(_7BIT_DI_MAIN_HEADER "${_7BIT_DI_HEADERS_DIR}/SevenBit/DI.hpp")
Expand Down Expand Up @@ -69,16 +65,11 @@ else()
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 lib/cmake/7bitDI)

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

set(INFOS
"${CMAKE_PROJECT_NAME} version: ${_7BIT_DI_VERSION}"
"${CMAKE_PROJECT_NAME} build type: ${CMAKE_BUILD_TYPE} "
"${CMAKE_PROJECT_NAME} build as ${_7BIT_DI_BUILD_LIBRARY_TYPE} library"
"=================================================="
"Build tests: ${_7BIT_DI_BUILD_TESTS}"
Expand Down
5 changes: 0 additions & 5 deletions Docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,3 @@ add_custom_target(GenerateDoc
${SPHINX_INDEX_FILE}
${SHPHINX_RST_FILES}
)

if(_7BIT_DI_INSTALL)
install(DIRECTORY ${SPHINX_BUILD}
DESTINATION doc)
endif()
16 changes: 13 additions & 3 deletions Docs/advanced-guides/building-library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Using this command several cache variables can be set:
* _7BIT_DI_BUILD_TESTS: ["ON", "OFF"] ("OFF") - Turn on to build tests (requires Gtest_ to be installed, see `Build Library With Conan`_)
* _7BIT_DI_BUILD_EXAMPLES: ["ON", "OFF"] ("OFF") - Turn on to build examples
* _7BIT_DI_BUILD_SINGLE_HEADER: ["ON", "OFF"] ("OFF") - Turn on to build single header SevenBitDI.hpp (requires Quom_ to be installed)
* _7BIT_DI_INSTALL: ["ON", "OFF"] ("OFF") - Turn on to install the library (output is in build/publish)
* _7BIT_DI_INSTALL: ["ON", "OFF"] ("OFF") - Turn on to install the library

to set cache variable pass additional option: -D<variable cache name>=[value]
for example, this command will set the library type to Static and will force examples built

.. code-block:: sh

cmake .. -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_INSTALL=ON -D_7BIT_DI_LIBRARY_TYPE=Static -D_7BIT_DI_BUILD_EXAMPLES=true
cmake .. -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_LIBRARY_TYPE=Static -D_7BIT_DI_BUILD_EXAMPLES=true

Build the library using the command:

Expand Down Expand Up @@ -65,14 +65,24 @@ Configure the CMake project, and add also toolchain file as a CMAKE_TOOLCHAIN_FI

.. code-block:: sh

cmake .. -DCMAKE_TOOLCHAIN_FILE:PATH="./conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_BUILD_TESTS=ON -D_7BIT_DI_INSTALL=ON
cmake .. -DCMAKE_TOOLCHAIN_FILE:PATH="./conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_BUILD_TESTS=ON

Build the library using the command:

.. code-block:: sh

cmake --build .


Install Library
^^^^^^^^^^^^^^^^^^^^^^^^^

To install the library set additional cache variables _7BIT_DI_BUILD_TESTS=ON and specify installation dir with CMAKE_INSTALL_PREFIX, then run the command

.. code-block:: sh

cmake --build . --config Release --target install

.. _Cmake: https://cmake.org/
.. _`Cmake Installation`: https://cmake.org/download/
.. _Sphinx: https://www.sphinx-doc.org/en/master/
Expand Down
15 changes: 13 additions & 2 deletions Docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ Installation
**There are a few ways of installation:**

#. Using Conan.io package manager - Recommended
Info soon...
Download and install Conan_, and create conanfile.txt in the root of your project for example:

.. code-block:: Txt

[requires]
7bitdi/1.0.0

change the version to newer if available, then run the command:

.. code-block:: sh

conan install . --output-folder=build --build=missing

#. Header only
Download source code from the most recent release,
Expand All @@ -45,7 +56,6 @@ Installation

#. Building library as Static/Shared
Download source code from the most recent release, build or install the project using CMake_,
library files are located in the build/publish folder,
for more details see the `Building Library`_ guide.

Example Usage
Expand All @@ -63,6 +73,7 @@ The next chapters will in detail, step by step explain what is going on in this
actionA, actionB executed.


.. _Conan: https://conan.io/
.. _CMake: https://cmake.org/
.. _7bitDI: https://github.com/7bitcoder/7bitDI
.. _`Building Library`: advanced-guides/building-library.html
4 changes: 0 additions & 4 deletions Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ foreach(SOURCE ${SOURCES})
target_link_libraries(${FILE_NAME}
7bitDI
)

if(_7BIT_DI_INSTALL)
install(TARGETS ${FILE_NAME})
endif()
endforeach()
7 changes: 1 addition & 6 deletions SingleHeader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@ add_custom_target(GenerateSingleHeader
ALL DEPENDS
${_7BIT_DI_SINGLE_OUT}
${_7BIT_DI_MAIN_HEADER}
)

if(_7BIT_DI_INSTALL)
install(FILES ${_7BIT_DI_SINGLE_OUT}
DESTINATION single-header)
endif()
)
12 changes: 4 additions & 8 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ endif()

add_library(7bitDI::7bitDI ALIAS 7bitDI)

target_include_directories(7bitDI INTERFACE "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(
7bitDI INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

set_target_properties(7bitDI PROPERTIES VERSION ${_7BIT_DI_VERSION})
set_target_properties(7bitDI PROPERTIES DEBUG_POSTFIX d)

if(_7BIT_DI_INSTALL)
install(
TARGETS 7bitDI
EXPORT 7bitDI)
endif()
4 changes: 0 additions & 4 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ target_link_libraries(Tests PUBLIC
7bitDI
)

if(_7BIT_DI_INSTALL)
install(TARGETS Tests)
endif()

gtest_discover_tests(Tests
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
PROPERTIES TIMEOUT 10)