CMakeLists.txt. Add compat option 'OATPP_COMPAT_BUILD_NO_SET_AFFINITY'

This commit is contained in:
lganzzzo 2020-06-05 00:49:07 +03:00
parent cc9a6e6ca3
commit 24c18ad166
4 changed files with 8 additions and 7 deletions

View File

@ -33,6 +33,7 @@ set(OATPP_THREAD_HARDWARE_CONCURRENCY "AUTO" CACHE STRING "Predefined value for
set(OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT "10" CACHE STRING "Number of shards of ThreadDistributedMemoryPool")
option(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL "Disable 'thread_local' feature" OFF)
option(OATPP_COMPAT_BUILD_NO_SET_AFFINITY "No 'pthread_setaffinity_np' method" OFF)
option(OATPP_DISABLE_LOGV "DISABLE logs priority V" OFF)
option(OATPP_DISABLE_LOGD "DISABLE logs priority D" OFF)
@ -68,13 +69,17 @@ if(NOT OATPP_THREAD_HARDWARE_CONCURRENCY STREQUAL AUTO_VALUE)
endif()
add_definitions (
-DOATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=${OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT}
-DOATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT=${OATPP_THREAD_DISTRIBUTED_MEM_POOL_SHARDS_COUNT}
)
if(OATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
add_definitions(-DOATPP_COMPAT_BUILD_NO_THREAD_LOCAL)
endif()
if(OATPP_COMPAT_BUILD_NO_SET_AFFINITY)
add_definitions(-DOATPP_COMPAT_BUILD_NO_SET_AFFINITY)
endif()
if(OATPP_DISABLE_LOGV)
add_definitions(-DOATPP_DISABLE_LOGV)
endif()

View File

@ -45,7 +45,7 @@ v_int32 setThreadAffinityToCpuRange(std::thread::native_handle_type nativeHandle
// The below line compiles on Android but has not been tested.
//result = sched_setaffinity(nativeHandle, sizeof(cpu_set_t), &cpuset);
#if !defined(__ANDROID__) && !defined(OATPP_HAS_NO_SETAFFINITY_NP)
#if !defined(__ANDROID__) && !defined(OATPP_COMPAT_BUILD_NO_SET_AFFINITY)
cpu_set_t cpuset;
CPU_ZERO(&cpuset);

View File

@ -109,7 +109,4 @@ set_target_properties(oatppAllTests PROPERTIES
target_include_directories(oatppAllTests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(oatppAllTests
PRIVATE OATPP_ENABLE_ALL_TESTS_MAIN
)
add_test(oatppAllTests oatppAllTests)

View File

@ -67,7 +67,6 @@
#include <iostream>
#include <mutex>
#ifdef OATPP_ENABLE_ALL_TESTS_MAIN
namespace {
void runTests() {
@ -219,4 +218,4 @@ int main() {
return 0;
}
#endif