11cmake_minimum_required (VERSION 3.23.0)
22project (easyqueue
3- DESCRIPTION "A simple queue implementation intended to support flexible applicability with an easy-to-use interface."
4- HOMEPAGE_URL "https://github.com/null-default/easyqueue"
5- LANGUAGES C)
3+ DESCRIPTION "A simple queue implementation intended to support flexible applicability with an easy-to-use interface."
4+ HOMEPAGE_URL "https://github.com/null-default/easyqueue"
5+ LANGUAGES C)
66
77# Semantic Versioning, for the API version.
88set (EASYQUEUE_MAJOR_VERSION 1) # increment for incompatible API changes
9- set (EASYQUEUE_MINOR_VERSION 0 ) # increment with new backwards-compatible functionality
9+ set (EASYQUEUE_MINOR_VERSION 1 ) # increment with new backwards-compatible functionality
1010set (EASYQUEUE_PATCH_VERSION 0) # increment with backwards-compatible bugfixes
1111set (EASYQUEUE_APIVERSION ${EASYQUEUE_MAJOR_VERSION} .${EASYQUEUE_MINOR_VERSION} )
1212
1313# Shared Object Versioning compatible with libtool's -version-info, for the ABI version.
1414# Ref: https://autotools.io/libtool/version.html
1515set (EASYQUEUE_CURRENT_VERSION 1) # increment whenever an interface has been added, removed, or changed
16- set (EASYQUEUE_REVISION_VERSION 0 ) # always increment regardless of changes
16+ set (EASYQUEUE_REVISION_VERSION 1 ) # always increment regardless of changes
1717set (EASYQUEUE_AGE_VERSION 0) # only increment if ABI changes are backwards-compatible
1818math (EXPR EASYQUEUE_SOVERSION "${EASYQUEUE_CURRENT_VERSION} - ${EASYQUEUE_AGE_VERSION} " )
1919set (EASYQUEUE_VERSION ${EASYQUEUE_SOVERSION} .${EASYQUEUE_AGE_VERSION} .${EASYQUEUE_REVISION_VERSION} )
2020
2121# Define any boolean options that will tune the build.
2222option (EASYQUEUE_BUILD_32 "Build 32-bit binaries instead of 64-bit." OFF )
23+ option (EASYQUEUE_BUILD_UNIT_TESTS "Build unit tests included in the repository. Unit tests use the Unity framework, which must be installed on the system." OFF )
2324
2425# Allow the fixed-size buffer's capacity to be configured.
2526set (EASYQUEUE_DEFAULT_FIXED_BUFFER_CAPACITY 32)
@@ -30,53 +31,61 @@ endif()
3031# Build a shared object.
3132add_library (${PROJECT_NAME} SHARED)
3233target_compile_definitions (${PROJECT_NAME}
33- PUBLIC EZQ_FIXED_BUFFER_CAPACITY=${EASYQUEUE_FIXED_BUFFER_CAPACITY} )
34+ PUBLIC EZQ_FIXED_BUFFER_CAPACITY=${EASYQUEUE_FIXED_BUFFER_CAPACITY} )
3435set_target_properties (${PROJECT_NAME}
35- PROPERTIES C_STANDARD 90
36- C_STANDARD_REQUIRED ON
37- C_EXTENSIONS OFF
38- POSITION_INDEPENDENT_CODE ON )
36+ PROPERTIES
37+ C_STANDARD 90
38+ C_STANDARD_REQUIRED ON
39+ C_EXTENSIONS OFF
40+ POSITION_INDEPENDENT_CODE ON )
3941target_compile_options (${PROJECT_NAME}
40- PRIVATE -Wall -Werror -Wextra -Wpedantic)
42+ PRIVATE -Wall -Werror -Wextra -Wpedantic)
4143target_sources (${PROJECT_NAME}
42- PRIVATE src/easyqueue.c
43- PUBLIC FILE_SET easyqueue_headers
44- TYPE HEADERS
45- BASE_DIRS include
46- FILES include /easyqueue.h)
44+ PRIVATE src/easyqueue.c
45+ PUBLIC
46+ FILE_SET easyqueue_headers
47+ TYPE HEADERS
48+ BASE_DIRS include
49+ FILES include /easyqueue.h)
4750target_link_options (${PROJECT_NAME} PRIVATE -nostdlib)
4851
4952# Build a static archive.
5053add_library (${PROJECT_NAME} _static STATIC )
5154target_compile_definitions (${PROJECT_NAME} _static
52- PUBLIC EZQ_FIXED_BUFFER_CAPACITY=${EASYQUEUE_FIXED_BUFFER_CAPACITY} )
55+ PUBLIC EZQ_FIXED_BUFFER_CAPACITY=${EASYQUEUE_FIXED_BUFFER_CAPACITY} )
5356set_target_properties (${PROJECT_NAME} _static
54- PROPERTIES C_STANDARD 90
55- C_STANDARD_REQUIRED ON
56- C_EXTENSIONS OFF
57- POSITION_INDEPENDENT_CODE ON )
57+ PROPERTIES
58+ C_STANDARD 90
59+ C_STANDARD_REQUIRED ON
60+ C_EXTENSIONS OFF
61+ POSITION_INDEPENDENT_CODE ON )
5862target_compile_options (${PROJECT_NAME} _static
59- PRIVATE -Wall -Werror -Wextra -Wpedantic)
63+ PRIVATE -Wall -Werror -Wextra -Wpedantic)
6064target_sources (${PROJECT_NAME} _static
61- PRIVATE src/easyqueue.c
62- PUBLIC FILE_SET easyqueue_headers
63- TYPE HEADERS
64- BASE_DIRS include
65- FILES include /easyqueue.h)
65+ PRIVATE src/easyqueue.c
66+ PUBLIC
67+ FILE_SET easyqueue_headers
68+ TYPE HEADERS
69+ BASE_DIRS include
70+ FILES include /easyqueue.h)
6671
6772# Set additional flags for 32-bit builds.
6873if (EASYQUEUE_BUILD_32)
6974 set_target_properties (${PROJECT_NAME}
70- PROPERTIES COMPILE_FLAGS "-m32"
71- LINK_FLAGS "-m32" )
75+ PROPERTIES
76+ COMPILE_FLAGS "-m32"
77+ LINK_FLAGS "-m32" )
7278 target_compile_options (${PROJECT_NAME}
73- PRIVATE -fno-stack-protector) # is this the best option..?
79+ PRIVATE
80+ -fno-stack-protector) # is this the best option..?
7481
7582 set_target_properties (${PROJECT_NAME} _static
76- PROPERTIES COMPILE_FLAGS "-m32"
77- LINK_FLAGS "-m32" )
83+ PROPERTIES
84+ COMPILE_FLAGS "-m32"
85+ LINK_FLAGS "-m32" )
7886 target_compile_options (${PROJECT_NAME} _static
79- PRIVATE -fno-stack-protector)
87+ PRIVATE
88+ -fno-stack-protector)
8089endif ()
8190
8291# Example executables that demonstrate usage of the library can be compiled if
@@ -85,9 +94,24 @@ if(EASYQUEUE_BUILD_EXAMPLES)
8594 add_subdirectory (examples)
8695endif ()
8796
97+ # If unit test building is specified, include CTest.
98+ # NOTE: 32-bit builds of unit tests are not currently supported.
99+ if (EASYQUEUE_BUILD_UNIT_TESTS)
100+ find_library (UNITY_TESTS
101+ NAMES unity)
102+ include (CTest)
103+ add_executable (easyqueue_unit_tests src/easyqueue.tests.c)
104+ target_link_libraries (easyqueue_unit_tests
105+ PRIVATE
106+ ${PROJECT_NAME} _static
107+ ${UNITY_TESTS} )
108+ add_test (NAME easyqueue_unit_tests
109+ COMMAND easyqueue_unit_tests)
110+ endif ()
111+
88112# Set installation rules
89113install (TARGETS ${PROJECT_NAME} ${PROJECT_NAME} _static
90- RUNTIME DESTINATION bin
91- LIBRARY DESTINATION lib
92- ARCHIVE DESTINATION lib
93- FILE_SET easyqueue_headers)
114+ RUNTIME DESTINATION bin
115+ LIBRARY DESTINATION lib
116+ ARCHIVE DESTINATION lib
117+ FILE_SET easyqueue_headers)
0 commit comments