Jackalope / jlib (public) (License: GPLv3 or later) (since 2019-11-18) (hash sha1)
jlib C++ template library
Used to replace std functionality without exception handling.
- data structures
- filesystem routines
- crossplatform threads interface (currently only pthreads implementation)
- thread pool
- crossplatform dynamic memory functions interface (allocate, reallocate, deallocate) with alignment support
- high percision timer routines based on timespec
List of commits:
Subject Hash Author Date (UTC)
CMake: build both shared and static with JLIB_SHARED and JLIB_STATIC options. When is subdirectory, select only one instead. Doxygen target renamed from documentation to jlib-doxygen. 20910577a262b43a373f5b8f4a9b444fcdaf56bb Jackalope 2020-05-31 21:37:04
Wide line fix. e6f02dfd80996cf18285fa2cc2e3cbffe3854d11 Jackalope 2020-05-31 18:43:06
fs::stream: discard input function, constructor from FILE. fbe72ec086b44821ea93a61dba7f869b043769e9 Jackalope 2020-05-31 18:42:12
Version 0.4.0 9e5059b4af323e37f4ad0f4f7eb20f562d07c857 Jackalope 2020-05-31 11:17:38
FS limits function fix. 813a0a8aaae122b7b4a4d158cf029aff1733308c Jackalope 2020-05-31 11:05:07
New option JLIB_ALLOCATE_DEBUG fa66e03cd2ea7102bab8a6de3415898c114a27e4 Jackalope 2020-05-31 10:44:49
Changed version config to match versioning compatibility. 393953edfa42b24e43ba027c5d52d7c2df6cf861 Jackalope 2020-05-31 10:43:09
Thread pool wrong doxygen tag fix. 8392eb800adc01d587d9f6ce962ad403f1e5c80c Jackalope 2020-05-29 16:51:33
jassert macro compatibility in if statement without braces. 5c749b8c1cb2cb51c8ddf6ccedef8d72554d6c68 Jackalope 2020-05-29 15:54:53
Version 0.3.0 616c945f21a8da901facc7363c3b204216776a1d Jackalope 2020-05-26 14:37:18
Removing deprecated threads and old thread pool. b2ce1a8eb5b4a1b9c5d6a19fe75e7a52738e6866 Jackalope 2020-05-26 14:31:57
Resolved issues and warnings with GCC. c9ee73408a660c723dd51b74311d572ec4ef2320 Jackalope 2020-05-26 14:19:43
Thread result can be only pointer now. 645f6ce75c773fd2fad543bfd542202d02925288 Jackalope 2020-05-26 14:19:11
Option JLIB_STATIC to select static or shared library. 08b3a60286a7487ce445f66852f0afdd0f99be69 Jackalope 2020-05-26 14:17:11
Add warning compilation flags. 071b3c83090367f7c2beea5394b926c14620dc66 Jackalope 2020-05-26 13:25:37
New thread pool implementation. 849910e5b45ab543231e24650368289a180452d6 Jackalope 2020-05-26 08:59:03
rarray::iterator_index function 7ee95c6b048973f209fc4e365af36a3dcdb06c4b Jackalope 2020-05-26 08:58:20
darray::remove_last_if_exist logic fix 1664bbfba9d4d8098542c8138a548e4377304aa6 Jackalope 2020-05-26 08:55:31
remove float convertion warning 1ea4783034b873f7711e2ecf840955818c07bcd0 Jackalope 2020-05-26 08:54:04
threads refactoring 9b03fd0beb928de9f3f3e492bb1d324356152de3 Jackalope 2020-05-26 08:52:26
Commit 20910577a262b43a373f5b8f4a9b444fcdaf56bb - CMake: build both shared and static with JLIB_SHARED and JLIB_STATIC options. When is subdirectory, select only one instead. Doxygen target renamed from documentation to jlib-doxygen.
Author: Jackalope
Author date (UTC): 2020-05-31 21:37
Committer name: Jackalope
Committer date (UTC): 2020-05-31 23:45
Parent(s): e6f02dfd80996cf18285fa2cc2e3cbffe3854d11
Signing key:
Tree: aeb1884ba2945cff777006c8c6d7a1e4b5cbf250
File Lines added Lines deleted
CMakeLists.txt 133 86
config.cmake.in 12 0
src/options.h.in 1 0
File CMakeLists.txt changed (mode: 100644) (index 0800f3b..23b4718)
14 14 # #
15 15 # You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
16 16 # along with this library. If not, see <https://www.gnu.org/licenses/> # along with this library. If not, see <https://www.gnu.org/licenses/>
17 #
18 cmake_minimum_required(VERSION 3.5)
17
18 cmake_minimum_required(VERSION 3.13)
19 19 project(JLIB project(JLIB
20 20 DESCRIPTION "Jackalope's C++ library" DESCRIPTION "Jackalope's C++ library"
21 21 VERSION 0.4.0 VERSION 0.4.0
 
... ... set(INCLUDE_FILES
52 52 ) )
53 53 list(TRANSFORM INCLUDE_FILES PREPEND jlib/) list(TRANSFORM INCLUDE_FILES PREPEND jlib/)
54 54
55 option(JLIB_ALLOCATE_DEBUG "Enable memory allocations debugging." OFF)
55 set(SOURCE_FILES
56 src/fs.cpp
57 src/threads.cpp
58 src/thread_pool.cpp
59 )
60
61 option(JLIB_ALLOCATE_DEBUG
62 "Enable memory allocations debugging." OFF
63 )
64 option(JLIB_THREAD_POOL_ATOMICS
65 "Use atomics for shared variables access outside of mutex scope" OFF
66 )
56 67 configure_file( configure_file(
57 68 ${CMAKE_CURRENT_SOURCE_DIR}/src/options.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/options.h.in
58 69 ${CMAKE_CURRENT_SOURCE_DIR}/include/jlib/options.h ${CMAKE_CURRENT_SOURCE_DIR}/include/jlib/options.h
59 70 ) )
60 71
61 set(EXPORT_NAME jlib-${PROJECT_VERSION})
62
63 option(JLIB_STATIC "Build static library instead of shared" OFF)
64 if (JLIB_STATIC)
65 set(JLIB_LIBRARY_TYPE STATIC)
72 if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
73 set(IS_TOP_LEVEL TRUE)
66 74 else() else()
67 set(JLIB_LIBRARY_TYPE SHARED)
75 set(IS_TOP_LEVEL FALSE)
68 76 endif() endif()
69 77
70 add_library(jlib ${JLIB_LIBRARY_TYPE}
71 src/fs.cpp
72 src/threads.cpp
73 src/thread_pool.cpp
74 )
75 target_include_directories(jlib PUBLIC
76 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
77 $<INSTALL_INTERFACE:include/${EXPORT_NAME}>
78 )
79 target_link_libraries(jlib PRIVATE pthread)
80 target_compile_features(jlib PUBLIC cxx_std_17)
78 if (IS_TOP_LEVEL)
79 option(JLIB_SHARED "Enable jlib shared library" ON)
80 option(JLIB_STATIC "Enable jlib static library" ON)
81 if (NOT JLIB_STATIC AND NOT JLIB_SHARED)
82 message(FATAL_ERROR "Neither JLIB_STATIC nor JLIB_SHARED is selected")
83 endif()
84 else()
85 option(JLIB_STATIC "Use jlib as static library instead of shared" ON)
86 if (JLIB_STATIC)
87 set(JLIB_SHARED OFF)
88 set(jlib_TARGETS jlib-static)
89 else()
90 set(JLIB_SHARED ON)
91 set(jlib_TARGETS jlib-shared)
92 endif()
93 endif()
81 94
82 target_compile_options(jlib PRIVATE
83 $<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>
84 $<$<CONFIG:RELEASE>:-O3>
85 $<$<CONFIG:RELWITHDEBINFO>:-O3;-g3;-ggdb>
86 )
95 if (JLIB_SHARED)
96 add_library(jlib-shared SHARED ${SOURCE_FILES})
97 list(APPEND JLIB_TARGETS jlib-shared)
98 endif()
99 if(JLIB_STATIC)
100 add_library(jlib-static STATIC ${SOURCE_FILES})
101 list(APPEND JLIB_TARGETS jlib-static)
102 endif()
87 103
88 104 option(JLIB_NATIVE "Enable non-portable compiling optimizations" ON) option(JLIB_NATIVE "Enable non-portable compiling optimizations" ON)
89 105 if (JLIB_NATIVE) if (JLIB_NATIVE)
90 target_compile_options(jlib PRIVATE -march=native)
91 106 message(NOTICE "JLIB_NATIVE is enabled, compiling for native arch.") message(NOTICE "JLIB_NATIVE is enabled, compiling for native arch.")
92 107 endif() endif()
93 108
94 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
95 OR
96 CMAKE_CXX_COMPILER_ID STREQUAL "GCC")
97 target_compile_options(jlib PRIVATE -fno-exceptions -fno-rtti -ffast-math)
98 endif()
109 set(EXPORT_NAME jlib-${PROJECT_VERSION})
99 110
100 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
101 target_compile_options(jlib PRIVATE
102 -Weverything
103 -Wno-c++98-compat-pedantic
104 -Wno-c++11-compat-pedantic
105 -Wno-c++14-compat-pedantic
106 -Wno-binary-literal
107 -Wno-padded
111 foreach(TARGET ${JLIB_TARGETS})
112 target_include_directories(${TARGET} PUBLIC
113 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
114 $<INSTALL_INTERFACE:include/${EXPORT_NAME}>
108 115 ) )
109 endif()
110 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
111 target_compile_options(jlib PRIVATE -Wall -Wextra)
112 endif()
116 target_link_libraries(${TARGET} PUBLIC pthread)
117 set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME jlib)
113 118
114 option(JLIB_THREAD_POOL_ATOMICS
115 "Use atomics for shared variables access outside of mutex scope" OFF)
116 if (JLIB_THREAD_POOL_ATOMICS)
117 target_compile_definitions(jlib PRIVATE JLIB_THREAD_POOL_ATOMICS=1)
118 else()
119 target_compile_definitions(jlib PRIVATE JLIB_THREAD_POOL_ATOMICS=0)
120 endif()
119 target_compile_options(${TARGET} PRIVATE
120 $<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>
121 $<$<CONFIG:RELEASE>:-O3>
122 $<$<CONFIG:RELWITHDEBINFO>:-O3;-g3;-ggdb>
123 )
124 target_compile_features(${TARGET} PUBLIC cxx_std_17)
125 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
126 target_compile_options(${TARGET} PRIVATE
127 -Weverything
128 -Wno-c++98-compat-pedantic
129 -Wno-c++11-compat-pedantic
130 -Wno-c++14-compat-pedantic
131 -Wno-binary-literal
132 -Wno-padded
133 )
134 endif()
135 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
136 target_compile_options(${TARGET} PRIVATE -Wall -Wextra)
137 endif()
138 if (JLIB_NATIVE)
139 target_compile_options(${TARGET} PRIVATE -march=native)
140 endif()
141 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
142 OR
143 CMAKE_CXX_COMPILER_ID STREQUAL "GCC")
144 target_compile_options(${TARGET}
145 PRIVATE -fno-exceptions -fno-rtti -ffast-math
146 )
147 endif()
121 148
122 set(INSTALL_DIR include/${EXPORT_NAME})
123 foreach(FILE ${INCLUDE_FILES})
124 get_filename_component(DIR_PATH ${FILE} DIRECTORY)
125 install(FILES include/${FILE} DESTINATION ${INSTALL_DIR}/${DIR_PATH} )
149 if (IS_TOP_LEVEL)
150 install(TARGETS ${TARGET}
151 DESTINATION lib
152 EXPORT ${TARGET}
153 PUBLIC_HEADER DESTINATION include/${EXPORT_NAME}
154 )
155 install(EXPORT ${TARGET} DESTINATION cmake/${EXPORT_NAME})
156 endif()
126 157 endforeach() endforeach()
127 158
128 configure_file(version.cmake.in
129 ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
130 @ONLY
131 )
159 if (NOT IS_TOP_LEVEL)
160 add_library(jlib INTERFACE)
161 target_link_libraries(jlib INTERFACE ${JLIB_TARGETS})
162 else()
163 if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
164 set(CMAKE_DEBUG_POSTFIX d)
165 endif()
132 166
133 if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
134 set(CMAKE_DEBUG_POSTFIX d)
135 endif()
136 set_target_properties(jlib PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
167 if (JLIB_SHARED)
168 set_target_properties(jlib-shared PROPERTIES
169 DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
170 SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}.${PROJECT_VERSION}
171 PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}
172 )
173 endif()
174 if (JLIB_STATIC)
175 set_target_properties(jlib-static PROPERTIES
176 DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
177 SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}.${PROJECT_VERSION}
178 PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}
179 )
180 endif()
181
182 set(INSTALL_DIR include/${EXPORT_NAME})
183 foreach(FILE ${INCLUDE_FILES})
184 get_filename_component(DIR_PATH ${FILE} DIRECTORY)
185 install(FILES include/${FILE} DESTINATION ${INSTALL_DIR}/${DIR_PATH} )
186 endforeach()
137 187
138 if (JLIB_STATIC)
139 set_target_properties(jlib PROPERTIES
140 SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}.${PROJECT_VERSION}
141 PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}
188 configure_file(version.cmake.in
189 ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
190 @ONLY
142 191 ) )
143 else()
144 set_target_properties(jlib PROPERTIES
145 SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}.${PROJECT_VERSION}
146 PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}
192 set(CONFIG_TARGET jlib)
193 configure_file(config.cmake.in
194 ${CMAKE_CURRENT_BINARY_DIR}/config.cmake
195 @ONLY
196 )
197 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
198 DESTINATION cmake/${EXPORT_NAME}
199 RENAME jlib-config-version.cmake
200 )
201 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.cmake
202 DESTINATION cmake/${EXPORT_NAME}
203 RENAME jlib-config.cmake
147 204 ) )
148 205 endif() endif()
149 206
150 install(TARGETS jlib
151 DESTINATION lib
152 EXPORT jlib-config
153 PUBLIC_HEADER DESTINATION include/${EXPORT_NAME}
154 )
155 install(EXPORT jlib-config
156 DESTINATION cmake/${EXPORT_NAME}
157 )
158 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.cmake
159 DESTINATION cmake/${EXPORT_NAME}
160 RENAME jlib-config-version.cmake
161 )
162
163 207 function(yes_or_no OPT) function(yes_or_no OPT)
164 208 if(${OPT}) if(${OPT})
165 209 message(STATUS "${OPT} is set to yes") message(STATUS "${OPT} is set to yes")
 
... ... function(yes_or_no OPT)
170 214 endif() endif()
171 215 endfunction() endfunction()
172 216
173 option(JLIB_DOXYGEN_HTML "Generate HTML Doxygen documentation")
174 option(JLIB_DOXYGEN_LATEX "Generate LATEX Doxygen documentation")
217 option(JLIB_DOXYGEN_HTML "Enable HTML for jlib-doxygen")
218 option(JLIB_DOXYGEN_LATEX "Enable LaTeX for jlib-doxygen")
175 219
176 220 if(JLIB_DOXYGEN_HTML OR JLIB_DOXYGEN_LATEX) if(JLIB_DOXYGEN_HTML OR JLIB_DOXYGEN_LATEX)
177 221 find_package(Doxygen) find_package(Doxygen)
178 222 if (DOXYGEN_FOUND) if (DOXYGEN_FOUND)
179 223 set(DOXYGEN_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/jlib) set(DOXYGEN_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/jlib)
180 224 set(DOXYGEN_OUTPUT ${CMAKE_BINARY_DIR}/doc) set(DOXYGEN_OUTPUT ${CMAKE_BINARY_DIR}/doc)
225 if (NOT IS_TOP_LEVEL)
226 set(DOXYGEN_OUTPUT ${DOXYGEN_OUTPUT}/jlib)
227 endif()
181 228 set(DOXYGEN_CONFIG ${CMAKE_BINARY_DIR}/doc/Doxyfile) set(DOXYGEN_CONFIG ${CMAKE_BINARY_DIR}/doc/Doxyfile)
182 229 yes_or_no(JLIB_DOXYGEN_HTML) yes_or_no(JLIB_DOXYGEN_HTML)
183 230 yes_or_no(JLIB_DOXYGEN_LATEX) yes_or_no(JLIB_DOXYGEN_LATEX)
184 231 message(STATUS "Configuring ${DOXYGEN_CONFIG}") message(STATUS "Configuring ${DOXYGEN_CONFIG}")
185 232 configure_file(Doxyfile.in ${DOXYGEN_CONFIG}) configure_file(Doxyfile.in ${DOXYGEN_CONFIG})
186 add_custom_target(documentation
233 add_custom_target(jlib-doxygen
187 234 COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIG} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONFIG}
188 235 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
189 236 COMMENT "Generating Doxygen documentation" COMMENT "Generating Doxygen documentation"
File config.cmake.in added (mode: 100644) (index 0000000..e93afea)
1 option(@PROJECT_NAME@_STATIC
2 "Use static @CONFIG_TARGET@ instead of dynamic." OFF
3 )
4 if (@PROJECT_NAME@_STATIC)
5 include(${CMAKE_CURRENT_LIST_DIR}/@CONFIG_TARGET@-static.cmake)
6 add_library(@CONFIG_TARGET@ INTERFACE)
7 target_link_libraries(@CONFIG_TARGET@ INTERFACE @CONFIG_TARGET@-static)
8 else()
9 include(${CMAKE_CURRENT_LIST_DIR}/@CONFIG_TARGET@-shared.cmake)
10 add_library(@CONFIG_TARGET@ INTERFACE)
11 target_link_libraries(@CONFIG_TARGET@ INTERFACE @CONFIG_TARGET@-shared)
12 endif()
File src/options.h.in changed (mode: 100644) (index 02eab1c..583a3c6)
1 1 #pragma once #pragma once
2 2 #cmakedefine01 JLIB_ALLOCATE_DEBUG #cmakedefine01 JLIB_ALLOCATE_DEBUG
3 #cmakedefine01 JLIB_THREAD_POOL_ATOMICS
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/Jackalope/jlib

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/Jackalope/jlib

Clone this repository using git:
git clone git://git.rocketgit.com/user/Jackalope/jlib

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main