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
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ OPTION( ATOMIC_QUEUE_BUILD_EXAMPLES
OFF
)

OPTION( ATOMIC_QUEUE_ENABLE_INSTALL
"If the install target should be enabled."
OFF
)

if ( PROJECT_IS_TOP_LEVEL )
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED)
Expand All @@ -26,5 +31,3 @@ endif()
if ( ATOMIC_QUEUE_BUILD_TESTS OR ATOMIC_QUEUE_BUILD_EXAMPLES)
add_subdirectory( src )
endif()

add_library(max0x7ba::atomic_queue ALIAS atomic_queue)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,21 @@ git clone https://github.com/max0x7ba/atomic_queue.git
```
2. Add `atomic_queue/include` directory (use full path) to the include paths of your build system.
3. `#include <atomic_queue/atomic_queue.h>` in your C++ source.
If you use CMake, these can be simplified as follows:
```cmake
add_subdirectory(atomic_queue)
target_link_libraries(main PRIVATE atomic_queue::atomic_queue)
```

## Install using vcpkg
```
vcpkg install atomic-queue
```
It provides CMake targets:
```cmake
find_package(atomic_queue CONFIG REQUIRED)
target_link_libraries(main PRIVATE atomic_queue::atomic_queue)
```

## Install using conan
Follow the official tutorial on [how to consume conan packages](https://docs.conan.io/2/tutorial/consuming_packages.html).
Expand Down
34 changes: 21 additions & 13 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
CMAKE_MINIMUM_REQUIRED( VERSION 3.25 )

add_library(
atomic_queue
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/atomic_queue/atomic_queue.h
${CMAKE_CURRENT_SOURCE_DIR}/atomic_queue/atomic_queue_mutex.h
${CMAKE_CURRENT_SOURCE_DIR}/atomic_queue/barrier.h
${CMAKE_CURRENT_SOURCE_DIR}/atomic_queue/defs.h
${CMAKE_CURRENT_SOURCE_DIR}/atomic_queue/spinlock.h
include(GNUInstallDirs)

add_library(atomic_queue INTERFACE)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is very generic and might potentially conflict with some other package in the vcpkg ecosystem, perhaps it might be a good time to change this internal library name from atomic_queue to something like max0x7ba_atomic_queue and then alias that to either max0x7ba::atomic_queue or atomic_queue::atomic_queue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO changing the port name of vcpkg is not a good idea, as it would break downstream. As for naming conflicts, that is an issue future ports should consider, I would like to keep the current port name.

target_include_directories(atomic_queue INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

target_include_directories(
atomic_queue
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
add_library(atomic_queue::atomic_queue ALIAS atomic_queue)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@max0x7ba
Changing the name from max0x7ba::atomic_queue to atomic_queue::atomic_queue is somewhat of a breaking change. Perhaps it would be sensible to make a new release because of that?

Copy link
Copy Markdown
Contributor Author

@xiaozhuai xiaozhuai Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we need make a new release after merge this.
I changed the namespace because namespaces sharing the same name as the project are more common.
For example glm::glm, nanobench::nanobench, minifb::minifb, yoga::yogacore and etc.
Since this project previously did not export CMake config, this is an ideal opportunity to change the namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, after make a new release, I will submit a new pr to add cmake usage about FetchContent.


if ( ATOMIC_QUEUE_ENABLE_INSTALL )
install(TARGETS atomic_queue EXPORT atomic_queue)
install(
DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/atomic_queue"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
EXPORT atomic_queue
FILE atomic_queue-config.cmake
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/atomic_queue"
NAMESPACE atomic_queue::
)
endif ()
Loading