Skip to content

Commit c6787cf

Browse files
committed
updated cmakelist
1 parent 1d5fd7f commit c6787cf

2 files changed

Lines changed: 39 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ Cpp-Taskflow currently supports the following compilers:\n\
3737
")
3838
endif()
3939

40+
# defult release build
41+
set(TF_DEFAULT_BUILD_TYPE "Release")
42+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
43+
message(STATUS "Setting build type to '${TF_DEFAULT_BUILD_TYPE}'")
44+
set(
45+
CMAKE_BUILD_TYPE "${TF_DEFAULT_BUILD_TYPE}"
46+
CACHE
47+
STRING "Choose the type of build."
48+
FORCE
49+
)
50+
# Set the possible values of build type for cmake-gui
51+
set_property(
52+
CACHE
53+
CMAKE_BUILD_TYPE
54+
PROPERTY STRINGS
55+
"Debug" "Release" "MinSizeRel" "RelWithDebInfo"
56+
)
57+
endif()
58+
59+
4060
# error setting
4161
add_library(error_settings INTERFACE)
4262
add_library(tf::error_settings ALIAS error_settings)
@@ -46,7 +66,7 @@ target_compile_options(
4666
INTERFACE
4767
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -Wfatal-errors>
4868
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wfatal-errors>
49-
$<$<CXX_COMPILER_ID:MSVC>:/W3>
69+
$<$<CXX_COMPILER_ID:MSVC>:/W3 /permissive->
5070
)
5171

5272
# additional features
@@ -74,15 +94,12 @@ add_library(tf::optimize_settings ALIAS optimize_settings)
7494

7595
target_compile_options(
7696
optimize_settings INTERFACE
77-
#$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>>:-O2 -march=native>
78-
#$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU>>:-O2 -march=native>
79-
#$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2 -DNDEBUG /MP>
80-
#$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>>:-O0 -g>
81-
#$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>>:-O0 -g>
82-
#$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Zi /FS /DEBUG /Od /MP /MDd /Oy->
83-
$<$<CXX_COMPILER_ID:Clang>:-O2 -march=native>
84-
$<$<CXX_COMPILER_ID:GNU>:-O2 -march=native>
85-
$<$<CXX_COMPILER_ID:MSVC>:/O2 -DNDEBUG /MP>
97+
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>>:-O2 -march=native>
98+
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:GNU>>:-O2 -march=native>
99+
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2 -DNDEBUG /MP>
100+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU>>:-O0 -g>
101+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>>:-O0 -g>
102+
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Zi /FS /DEBUG /Od /MP /MDd /Oy->
86103
)
87104

88105
add_library(default_settings INTERFACE)

taskflow/utility/singular_allocator.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,24 @@ void SingularAllocator<T>::destroy(T* ptr) {
219219
// Allocate a memory piece of type T from the memory pool and return the T* to that memory.
220220
template <typename T>
221221
T* SingularAllocator<T>::allocate(size_t n) {
222-
assert(n == 1);
223-
return get_singular_mempool_manager<T>().get_per_thread_mempool()->allocate();
222+
if(n == 1) {
223+
return get_singular_mempool_manager<T>().get_per_thread_mempool()->allocate();
224+
}
225+
else {
226+
throw std::runtime_error("can only allocate one object");
227+
}
224228
}
225229

226230
// Function: deallocate
227231
// Deallocate given memory piece of type T.
228232
template <typename T>
229233
void SingularAllocator<T>::deallocate(T* ptr, size_t n) {
230-
assert(n == 1);
231-
get_singular_mempool_manager<T>().get_per_thread_mempool()->deallocate(ptr);
234+
if(n == 1) {
235+
get_singular_mempool_manager<T>().get_per_thread_mempool()->deallocate(ptr);
236+
}
237+
else {
238+
throw std::runtime_error("can only deallocate one object");
239+
}
232240
}
233241

234242
} // End of namespace tf. ----------------------------------------------------

0 commit comments

Comments
 (0)