From 7aa6e86b4b0bad052449afa889469ea745681642 Mon Sep 17 00:00:00 2001 From: Kadir Date: Mon, 16 Feb 2026 12:41:59 +0300 Subject: [PATCH 1/3] Redesign CMake interface --- concurrency/CMakeLists.txt | 85 ++++++++++++------- concurrency/WorkerQueue.cpp | 3 +- examples/main.cpp | 2 +- .../workerqueue}/WorkerQueue.h | 2 +- .../workerqueue}/WorkerQueueExport.h | 0 .../workerqueue}/version.h.in | 0 test/printDir.cpp | 2 +- 7 files changed, 58 insertions(+), 36 deletions(-) rename {concurrency => include/workerqueue}/WorkerQueue.h (99%) rename {concurrency => include/workerqueue}/WorkerQueueExport.h (100%) rename {concurrency => include/workerqueue}/version.h.in (100%) diff --git a/concurrency/CMakeLists.txt b/concurrency/CMakeLists.txt index 10f67f9..b3bbed2 100644 --- a/concurrency/CMakeLists.txt +++ b/concurrency/CMakeLists.txt @@ -6,6 +6,7 @@ if (NOT CMAKE_CXX_STANDARD) endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) # Enforce C++11 standard +set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) set(PROJECT_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/WorkerQueue.cpp) add_library(${LIBRARY_NAME} ${PROJECT_SOURCES}) @@ -22,31 +23,15 @@ endif() target_include_directories(${LIBRARY_NAME} PUBLIC - $ - $ -) - -# Set the library version properties -set_target_properties(${LIBRARY_NAME} PROPERTIES - VERSION ${PROJECT_VERSION} - SOVERSION 1 -) - -# configure header template -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/generated/version.h" -) - -# add include dir for generated headers -target_include_directories(${LIBRARY_NAME} PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/generated + $ + $ + $ ) # Custom target to copy the Changelog.md file to the build directory add_custom_target(copy_changelog ALL - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../Changelog.md ${CMAKE_BINARY_DIR}/Changelog.md - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../Changelog.md + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_ROOT_DIR}/Changelog.md ${CMAKE_BINARY_DIR}/Changelog.md + DEPENDS ${PROJECT_ROOT_DIR}/Changelog.md COMMENT "Copying Changelog.md to the build directory" ) @@ -58,17 +43,49 @@ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_DESCRIPTION "Cross platform asynchronous worker queue based on modern C++") set(CPACK_PACKAGE_MAINTAINER "kadirlua") -# Use file(GLOB ...) to match specific header files -file(GLOB HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +# ========================================================= +# Version header generation +# ========================================================= + +# configure header template +configure_file( + "${PROJECT_ROOT_DIR}/include/workerqueue/version.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/generated/workerqueue/version.h" + @ONLY +) + +# ========================================================= +# Library version +# ========================================================= + +# Set the library version properties +set_target_properties(${LIBRARY_NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + +# ========================================================= +# Install headers +# ========================================================= # Install the matched header files -install(FILES ${HEADER_FILES} DESTINATION include) +install(DIRECTORY "${PROJECT_INCLUDE_DIR}" + DESTINATION include + FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" +) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/version.h" DESTINATION include) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/generated/workerqueue/version.h" + DESTINATION include/workerqueue +) # Include the CHANGELOG.md and LICENSE files in the package -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../Changelog.md DESTINATION .) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE DESTINATION .) +install(FILES ${PROJECT_ROOT_DIR}/Changelog.md DESTINATION .) +install(FILES ${PROJECT_ROOT_DIR}/LICENSE DESTINATION .) + +# ========================================================= +# Install library +# ========================================================= # Include other necessary files and targets install(TARGETS ${LIBRARY_NAME} @@ -79,27 +96,31 @@ install(TARGETS ${LIBRARY_NAME} INCLUDES DESTINATION include ) +# ========================================================= +# Export package config +# ========================================================= + # Export the targets for other projects to find install(EXPORT WorkerQueueTargets FILE WorkerQueueTargets.cmake NAMESPACE WorkerQueue:: - DESTINATION lib/cmake/WorkerQueue) + DESTINATION lib/cmake/workerqueue) # Create a config file for find_package include(CMakePackageConfigHelpers) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/WorkerQueueConfigVersion.cmake" VERSION ${PROJECT_VERSION} - COMPATIBILITY AnyNewerVersion + COMPATIBILITY SameMajorVersion ) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/../Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/WorkerQueueConfig.cmake" - INSTALL_DESTINATION lib/cmake/WorkerQueue + INSTALL_DESTINATION lib/cmake/workerqueue ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/WorkerQueueConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/WorkerQueueConfigVersion.cmake" - DESTINATION lib/cmake/WorkerQueue -) \ No newline at end of file + DESTINATION lib/cmake/workerqueue +) diff --git a/concurrency/WorkerQueue.cpp b/concurrency/WorkerQueue.cpp index a6ed708..4297afc 100644 --- a/concurrency/WorkerQueue.cpp +++ b/concurrency/WorkerQueue.cpp @@ -20,14 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include "WorkerQueue.h" #include #include #include #include +#include namespace sdk { namespace concurrency { + WorkerQueue::WorkerQueue(std::size_t threadCnt) : m_threadSize{ threadCnt == 0 ? 1 : threadCnt } { diff --git a/examples/main.cpp b/examples/main.cpp index 25b5990..19732dd 100644 --- a/examples/main.cpp +++ b/examples/main.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include using namespace sdk::concurrency; diff --git a/concurrency/WorkerQueue.h b/include/workerqueue/WorkerQueue.h similarity index 99% rename from concurrency/WorkerQueue.h rename to include/workerqueue/WorkerQueue.h index b85a6cf..5348356 100644 --- a/concurrency/WorkerQueue.h +++ b/include/workerqueue/WorkerQueue.h @@ -30,7 +30,6 @@ #ifndef WORKER_QUEUE_H_ #define WORKER_QUEUE_H_ -#include "WorkerQueueExport.h" #include #include #include @@ -39,6 +38,7 @@ #include #include #include +#include #if (__cplusplus >= 201703L) #define NODISCARD [[nodiscard]] diff --git a/concurrency/WorkerQueueExport.h b/include/workerqueue/WorkerQueueExport.h similarity index 100% rename from concurrency/WorkerQueueExport.h rename to include/workerqueue/WorkerQueueExport.h diff --git a/concurrency/version.h.in b/include/workerqueue/version.h.in similarity index 100% rename from concurrency/version.h.in rename to include/workerqueue/version.h.in diff --git a/test/printDir.cpp b/test/printDir.cpp index 929fba3..15e6834 100644 --- a/test/printDir.cpp +++ b/test/printDir.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include using namespace sdk::concurrency; using namespace std::chrono_literals; From b07fc6c8b376d331202ab50857883788637f8954 Mon Sep 17 00:00:00 2001 From: Kadir Date: Mon, 16 Feb 2026 12:47:10 +0300 Subject: [PATCH 2/3] Fix include directory on msvc --- msvc/WorkerQueue.vcxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msvc/WorkerQueue.vcxproj b/msvc/WorkerQueue.vcxproj index 5021475..e53fd74 100644 --- a/msvc/WorkerQueue.vcxproj +++ b/msvc/WorkerQueue.vcxproj @@ -79,19 +79,19 @@ - ../concurrency;$(IncludePath) + ../include;$(IncludePath) true - ../concurrency;$(IncludePath) + ../include;$(IncludePath) true - ../concurrency;$(IncludePath) + ../include;$(IncludePath) true - ../concurrency;$(IncludePath) + ../include;$(IncludePath) true From 2d26ac6759a88db386856616212c8094dea35efd Mon Sep 17 00:00:00 2001 From: Kadir Date: Mon, 16 Feb 2026 12:47:42 +0300 Subject: [PATCH 3/3] Fix wrong include path on Android --- android/app/src/main/cpp/WorkerQueueAndroid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/cpp/WorkerQueueAndroid.cpp b/android/app/src/main/cpp/WorkerQueueAndroid.cpp index cf0e076..eb2665a 100644 --- a/android/app/src/main/cpp/WorkerQueueAndroid.cpp +++ b/android/app/src/main/cpp/WorkerQueueAndroid.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include