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
2 changes: 1 addition & 1 deletion android/app/src/main/cpp/WorkerQueueAndroid.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <concurrency/WorkerQueue.h>
#include <workerqueue/WorkerQueue.h>
#include <cstdlib>
#include <filesystem>
#include <jni.h>
Expand Down
85 changes: 53 additions & 32 deletions concurrency/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -22,31 +23,15 @@ endif()

target_include_directories(${LIBRARY_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/concurrency>
$<INSTALL_INTERFACE:concurrency>
)

# 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
$<BUILD_INTERFACE:${PROJECT_ROOT_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
$<INSTALL_INTERFACE:include>
)

# 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"
)

Expand All @@ -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}
Expand All @@ -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
)
DESTINATION lib/cmake/workerqueue
)
3 changes: 2 additions & 1 deletion concurrency/WorkerQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstddef>
#include <functional>
#include <mutex>
#include <utility>
#include <workerqueue/WorkerQueue.h>

namespace sdk {
namespace concurrency {

WorkerQueue::WorkerQueue(std::size_t threadCnt) :
m_threadSize{ threadCnt == 0 ? 1 : threadCnt }
{
Expand Down
2 changes: 1 addition & 1 deletion examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <functional>
#include <iostream>
#include <thread>
#include <WorkerQueue.h>
#include <workerqueue/WorkerQueue.h>

using namespace sdk::concurrency;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#ifndef WORKER_QUEUE_H_
#define WORKER_QUEUE_H_

#include "WorkerQueueExport.h"
#include <condition_variable>
#include <cstdlib>
#include <functional>
Expand All @@ -39,6 +38,7 @@
#include <queue>
#include <thread>
#include <vector>
#include <workerqueue/WorkerQueueExport.h>

#if (__cplusplus >= 201703L)
#define NODISCARD [[nodiscard]]
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions msvc/WorkerQueue.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>../concurrency;$(IncludePath)</IncludePath>
<IncludePath>../include;$(IncludePath)</IncludePath>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>../concurrency;$(IncludePath)</IncludePath>
<IncludePath>../include;$(IncludePath)</IncludePath>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>../concurrency;$(IncludePath)</IncludePath>
<IncludePath>../include;$(IncludePath)</IncludePath>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>../concurrency;$(IncludePath)</IncludePath>
<IncludePath>../include;$(IncludePath)</IncludePath>
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down
2 changes: 1 addition & 1 deletion test/printDir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <iostream>
#include <string>
#include <thread>
#include <WorkerQueue.h>
#include <workerqueue/WorkerQueue.h>

using namespace sdk::concurrency;
using namespace std::chrono_literals;
Expand Down
Loading