File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ OPTION( ATOMIC_QUEUE_BUILD_EXAMPLES
1212 OFF
1313)
1414
15+ OPTION ( ATOMIC_QUEUE_ENABLE_INSTALL
16+ "If the install target should be enabled."
17+ OFF
18+ )
19+
1520if ( PROJECT_IS_TOP_LEVEL )
1621 set (CMAKE_CXX_STANDARD 14)
1722 set (CMAKE_CXX_STANDARD_REQUIRED )
@@ -26,5 +31,3 @@ endif()
2631if ( ATOMIC_QUEUE_BUILD_TESTS OR ATOMIC_QUEUE_BUILD_EXAMPLES)
2732 add_subdirectory ( src )
2833endif ()
29-
30- add_library (max0x7ba::atomic_queue ALIAS atomic_queue )
Original file line number Diff line number Diff line change @@ -70,11 +70,21 @@ git clone https://github.com/max0x7ba/atomic_queue.git
7070```
71712 . Add ` atomic_queue/include ` directory (use full path) to the include paths of your build system.
72723 . ` #include <atomic_queue/atomic_queue.h> ` in your C++ source.
73+ If you use CMake, these can be simplified as follows:
74+ ``` cmake
75+ add_subdirectory(atomic_queue)
76+ target_link_libraries(main PRIVATE atomic_queue::atomic_queue)
77+ ```
7378
7479## Install using vcpkg
7580```
7681vcpkg install atomic-queue
7782```
83+ It provides CMake targets:
84+ ``` cmake
85+ find_package(atomic_queue CONFIG REQUIRED)
86+ target_link_libraries(main PRIVATE atomic_queue::atomic_queue)
87+ ```
7888
7989## Install using conan
8090Follow the official tutorial on [ how to consume conan packages] ( https://docs.conan.io/2/tutorial/consuming_packages.html ) .
Original file line number Diff line number Diff line change 11CMAKE_MINIMUM_REQUIRED ( VERSION 3.25 )
22
3- add_library (
4- atomic_queue
5- INTERFACE
6- ${CMAKE_CURRENT_SOURCE_DIR} /atomic_queue/atomic_queue.h
7- ${CMAKE_CURRENT_SOURCE_DIR} /atomic_queue/atomic_queue_mutex.h
8- ${CMAKE_CURRENT_SOURCE_DIR} /atomic_queue/barrier.h
9- ${CMAKE_CURRENT_SOURCE_DIR} /atomic_queue/defs.h
10- ${CMAKE_CURRENT_SOURCE_DIR} /atomic_queue/spinlock.h
3+ include (GNUInstallDirs )
4+
5+ add_library (atomic_queue INTERFACE )
6+ target_include_directories (atomic_queue INTERFACE
7+ "$<BUILD_INTERFACE :${CMAKE_CURRENT_LIST_DIR} >"
8+ "$<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >"
119)
1210
13- target_include_directories (
14- atomic_queue
15- INTERFACE
16- ${CMAKE_CURRENT_SOURCE_DIR}
17- )
11+ add_library (atomic_queue::atomic_queue ALIAS atomic_queue )
12+
13+ if ( ATOMIC_QUEUE_ENABLE_INSTALL )
14+ install (TARGETS atomic_queue EXPORT atomic_queue)
15+ install (
16+ DIRECTORY "${CMAKE_CURRENT_LIST_DIR} /atomic_queue"
17+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} "
18+ )
19+ install (
20+ EXPORT atomic_queue
21+ FILE atomic_queue-config.cmake
22+ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR} /atomic_queue"
23+ NAMESPACE atomic_queue::
24+ )
25+ endif ()
You can’t perform that action at this time.
0 commit comments