Skip to content

Commit 8622817

Browse files
authored
Merge pull request #14 from 7bitcoder/dev
Fix install dirs
2 parents 6e4abfc + 1ba55b8 commit 8622817

File tree

9 files changed

+50
-44
lines changed

9 files changed

+50
-44
lines changed

CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ project(7bitDI LANGUAGES CXX VERSION ${_7BIT_DI_VERSION})
1111
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Cmake")
1212

1313
include(Setup)
14+
include(GNUInstallDirs)
1415

1516
set(CMAKE_CXX_STANDARD 17)
1617
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -39,17 +40,32 @@ if(_7BIT_DI_BUILD_SINGLE_HEADER)
3940
endif()
4041

4142
if(_7BIT_DI_INSTALL)
42-
install(DIRECTORY ${_7BIT_DI_HEADERS_DIR}/ DESTINATION include)
43+
set(PROJECT_CONFIG_IN ${CMAKE_SOURCE_DIR}/Cmake/7bitDIConfig.cmake.in)
44+
set(PROJECT_CONFIG_OUT ${CMAKE_BINARY_DIR}/7bitDIConfig.cmake)
45+
set(CONFIG_TARGETS_FILE 7bitDIConfigTargets.cmake)
46+
set(VERSIONS_CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/7bitDIConfigVersion.cmake)
47+
set(EXPORT_DEST_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/7bitDI)
48+
49+
install(DIRECTORY ${_7BIT_DI_HEADERS_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
50+
51+
install(
52+
TARGETS 7bitDI
53+
EXPORT 7bitDI
54+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
55+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
56+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
4357

4458
export(
4559
TARGETS 7bitDI
4660
NAMESPACE 7bitDI::
47-
FILE ${CONFIG_TARGETS_FILE})
61+
FILE ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_TARGETS_FILE})
4862

4963
install(
64+
EXPORT 7bitDI
5065
EXPORT 7bitDI
5166
DESTINATION ${EXPORT_DEST_DIR}
5267
NAMESPACE 7bitDI::
68+
NAMESPACE 7bitDI::
5369
FILE ${CONFIG_TARGETS_FILE})
5470

5571
include(CMakePackageConfigHelpers)

Cmake/Setup.cmake

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
2626
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
2727
set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
2828

29-
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/publish)
30-
31-
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:\$ORIGIN/../bin:\$ORIGIN)
32-
3329
set(_7BIT_DI_HEADERS_DIR "${CMAKE_SOURCE_DIR}/Include")
3430

3531
set(_7BIT_DI_MAIN_HEADER "${_7BIT_DI_HEADERS_DIR}/SevenBit/DI.hpp")
@@ -69,16 +65,11 @@ else()
6965
set(_7BIT_DI_STATIC_LIB true)
7066
endif()
7167

72-
set(PROJECT_CONFIG_IN ${CMAKE_SOURCE_DIR}/Cmake/7bitDIConfig.cmake.in)
73-
set(PROJECT_CONFIG_OUT ${CMAKE_BINARY_DIR}/7bitDIConfig.cmake)
74-
set(CONFIG_TARGETS_FILE 7bitDIConfigTargets.cmake)
75-
set(VERSIONS_CONFIG_FILE ${CMAKE_BINARY_DIR}/7bitDIConfigVersion.cmake)
76-
set(EXPORT_DEST_DIR lib/cmake/7bitDI)
77-
7868
configure_file(${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/CmakeDef.hpp.input ${CMAKE_SOURCE_DIR}/Include/SevenBit/DI/CmakeDef.hpp)
7969

8070
set(INFOS
8171
"${CMAKE_PROJECT_NAME} version: ${_7BIT_DI_VERSION}"
72+
"${CMAKE_PROJECT_NAME} build type: ${CMAKE_BUILD_TYPE} "
8273
"${CMAKE_PROJECT_NAME} build as ${_7BIT_DI_BUILD_LIBRARY_TYPE} library"
8374
"=================================================="
8475
"Build tests: ${_7BIT_DI_BUILD_TESTS}"

Docs/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,3 @@ add_custom_target(GenerateDoc
2828
${SPHINX_INDEX_FILE}
2929
${SHPHINX_RST_FILES}
3030
)
31-
32-
if(_7BIT_DI_INSTALL)
33-
install(DIRECTORY ${SPHINX_BUILD}
34-
DESTINATION doc)
35-
endif()

Docs/advanced-guides/building-library.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Using this command several cache variables can be set:
2323
* _7BIT_DI_BUILD_TESTS: ["ON", "OFF"] ("OFF") - Turn on to build tests (requires Gtest_ to be installed, see `Build Library With Conan`_)
2424
* _7BIT_DI_BUILD_EXAMPLES: ["ON", "OFF"] ("OFF") - Turn on to build examples
2525
* _7BIT_DI_BUILD_SINGLE_HEADER: ["ON", "OFF"] ("OFF") - Turn on to build single header SevenBitDI.hpp (requires Quom_ to be installed)
26-
* _7BIT_DI_INSTALL: ["ON", "OFF"] ("OFF") - Turn on to install the library (output is in build/publish)
26+
* _7BIT_DI_INSTALL: ["ON", "OFF"] ("OFF") - Turn on to install the library
2727

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

3131
.. code-block:: sh
3232
33-
cmake .. -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_INSTALL=ON -D_7BIT_DI_LIBRARY_TYPE=Static -D_7BIT_DI_BUILD_EXAMPLES=true
33+
cmake .. -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_LIBRARY_TYPE=Static -D_7BIT_DI_BUILD_EXAMPLES=true
3434
3535
Build the library using the command:
3636

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

6666
.. code-block:: sh
6767
68-
cmake .. -DCMAKE_TOOLCHAIN_FILE:PATH="./conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_BUILD_TESTS=ON -D_7BIT_DI_INSTALL=ON
68+
cmake .. -DCMAKE_TOOLCHAIN_FILE:PATH="./conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -D_7BIT_DI_BUILD_TESTS=ON
6969
7070
Build the library using the command:
7171

7272
.. code-block:: sh
7373
7474
cmake --build .
7575
76+
77+
Install Library
78+
^^^^^^^^^^^^^^^^^^^^^^^^^
79+
80+
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
81+
82+
.. code-block:: sh
83+
84+
cmake --build . --config Release --target install
85+
7686
.. _Cmake: https://cmake.org/
7787
.. _`Cmake Installation`: https://cmake.org/download/
7888
.. _Sphinx: https://www.sphinx-doc.org/en/master/

Docs/getting-started.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@ Installation
2727
**There are a few ways of installation:**
2828

2929
#. Using Conan.io package manager - Recommended
30-
Info soon...
30+
Download and install Conan_, and create conanfile.txt in the root of your project for example:
31+
32+
.. code-block:: Txt
33+
34+
[requires]
35+
7bitdi/1.0.0
36+
37+
change the version to newer if available, then run the command:
38+
39+
.. code-block:: sh
40+
41+
conan install . --output-folder=build --build=missing
3142
3243
#. Header only
3344
Download source code from the most recent release,
@@ -45,7 +56,6 @@ Installation
4556

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

5161
Example Usage
@@ -63,6 +73,7 @@ The next chapters will in detail, step by step explain what is going on in this
6373
actionA, actionB executed.
6474
6575
76+
.. _Conan: https://conan.io/
6677
.. _CMake: https://cmake.org/
6778
.. _7bitDI: https://github.com/7bitcoder/7bitDI
6879
.. _`Building Library`: advanced-guides/building-library.html

Examples/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ foreach(SOURCE ${SOURCES})
1111
target_link_libraries(${FILE_NAME}
1212
7bitDI
1313
)
14-
15-
if(_7BIT_DI_INSTALL)
16-
install(TARGETS ${FILE_NAME})
17-
endif()
1814
endforeach()

SingleHeader/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ add_custom_target(GenerateSingleHeader
1414
ALL DEPENDS
1515
${_7BIT_DI_SINGLE_OUT}
1616
${_7BIT_DI_MAIN_HEADER}
17-
)
18-
19-
if(_7BIT_DI_INSTALL)
20-
install(FILES ${_7BIT_DI_SINGLE_OUT}
21-
DESTINATION single-header)
22-
endif()
17+
)

Source/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ endif()
1515

1616
add_library(7bitDI::7bitDI ALIAS 7bitDI)
1717

18-
target_include_directories(7bitDI INTERFACE "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Include>"
19-
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
18+
target_include_directories(
19+
7bitDI INTERFACE
20+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/Include>
21+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
2022

2123
set_target_properties(7bitDI PROPERTIES VERSION ${_7BIT_DI_VERSION})
2224
set_target_properties(7bitDI PROPERTIES DEBUG_POSTFIX d)
23-
24-
if(_7BIT_DI_INSTALL)
25-
install(
26-
TARGETS 7bitDI
27-
EXPORT 7bitDI)
28-
endif()

Tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ target_link_libraries(Tests PUBLIC
1515
7bitDI
1616
)
1717

18-
if(_7BIT_DI_INSTALL)
19-
install(TARGETS Tests)
20-
endif()
21-
2218
gtest_discover_tests(Tests
2319
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
2420
PROPERTIES TIMEOUT 10)

0 commit comments

Comments
 (0)