Commit 3cb3efd1 authored by Wolfgang Merkt's avatar Wolfgang Merkt
Browse files

[cmake] Fix multi-threading logic

Allows to specify the number of threads externally
parent 9efa0d2c
......@@ -73,19 +73,21 @@ OPTION(BUILD_WITH_CODEGEN_SUPPORT "Build the library with the Code Generation su
OPTION(BUILD_WITH_MULTITHREADS "Build the library with the Multithreading support (required OpenMP)" OFF)
IF(BUILD_WITH_MULTITHREADS)
INCLUDE(ProcessorCount)
ProcessorCount(NPROCESSOR)
IF(NOT NPROCESSOR EQUAL 0)
MATH(EXPR NPROCESSOR ${NPROCESSOR}/2)
SET(BUILD_WITH_NTHREADS ${NPROCESSOR} CACHE STRING "Number of threads")
ELSE()
SET(BUILD_WITH_NTHREADS "4" CACHE STRING "Number of threads") # Default setting
# If BUILD_WITH_NTHREADS defined, use the value - otherwise detect
IF(NOT DEFINED BUILD_WITH_NTHREADS)
INCLUDE(ProcessorCount)
ProcessorCount(NPROCESSOR)
IF(NOT NPROCESSOR EQUAL 0)
MATH(EXPR NPROCESSOR ${NPROCESSOR}/2)
SET(BUILD_WITH_NTHREADS ${NPROCESSOR} CACHE STRING "Number of threads")
ELSE()
SET(BUILD_WITH_NTHREADS "4" CACHE STRING "Number of threads") # Default setting
ENDIF()
ENDIF()
string(REGEX MATCH "^[0-9]+$" BUILD_WITH_NTHREADS ${BUILD_WITH_NTHREADS})
IF(NOT BUILD_WITH_NTHREADS MATCHES "^[0-9]+$")
SET(BUILD_WITH_NTHREADS 4) # Default setting 4.
MESSAGE(WARNING "the number of threads have to be an interger value, set to ${BUILD_WITH_NTHREADS}")
MESSAGE(WARNING "The number of threads has to be an integer value, set to ${BUILD_WITH_NTHREADS}")
ENDIF()
ENDIF()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment