readerwriterqueue icon indicating copy to clipboard operation
readerwriterqueue copied to clipboard

Add CMake option for install into moodycamel

Open Chardrazle opened this issue 4 months ago • 2 comments

Hi, I tend to use your excellent queues in various placements.

I recently noticed that the concurrentqueue cmake build installs with the ".../moodycamel/" sub-directory. However, this readerwriterqueue build does not have the moodycamel part.

I tend to root the include directories to work as: #include <moodycamel/concurrentqueue.h>

As you wouldn't want to break existing code, any chance of a cmake option that would add the "moodycamel/" part into the readerwriterqueue install location?

Chardrazle avatar Sep 19 '25 11:09 Chardrazle

Unfortunately, the CMake support is broken on the concurrentqueue side too. Not sure of the best way to untangle this mess yet, and I don't have time to dig in at the moment. Will defer this for now until I can figure out the best way forward with both repositories. Sorry.

cameron314 avatar Sep 20 '25 20:09 cameron314

I didn't experience anything broken with the concurrentqueue cmake build.
I see the cmake deprecation warning, but that's part-and-parcel with cmake's policy of deprecate-then-remove very old version support.

But, nevertheless, it's trivial for us to patch in various manners.

The change isn't too onerous; something akin to:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,11 @@ project(readerwriterqueue VERSION 1.0.7)
 include(GNUInstallDirs)
 include(CMakePackageConfigHelpers)
 
+option(ADD_MOODYCAMEL_INSTALL_SUBDIR OFF)
+if(ADD_MOODYCAMEL_INSTALL_SUBDIR)
+    set(moodyCamelInstallSubdir "/moodycamel")
+endif()
+
 add_library(${PROJECT_NAME} INTERFACE)
 
 target_include_directories(readerwriterqueue INTERFACE
@@ -15,7 +20,7 @@ target_include_directories(readerwriterqueue INTERFACE
 )
 
 install(FILES atomicops.h readerwriterqueue.h readerwritercircularbuffer.h LICENSE.md
-        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}${moodyCamelInstallSubdir})
 
 install(TARGETS ${PROJECT_NAME}
     EXPORT ${PROJECT_NAME}Targets

Chardrazle avatar Sep 21 '25 10:09 Chardrazle