OpenMP and POSIX threads: do not allow both to be specified

This commit is contained in:
Shahram Najm 2016-01-07 11:31:42 +00:00
parent 5c7761d936
commit 87fc993748
1 changed files with 13 additions and 10 deletions

View File

@ -159,27 +159,30 @@ find_package(Threads REQUIRED)
# debug
message(STATUS " CMAKE_THREAD_LIBS_INIT=${CMAKE_THREAD_LIBS_INIT}")
message(STATUS " CMAKE_USE_PTHREADS_INIT=${CMAKE_USE_PTHREADS_INIT}")
message(STATUS " ECCODES_THREADS=${ECCODES_THREADS}, HAVE_ECCODES_THREADS=${HAVE_ECCODES_THREADS}")
if( NOT ${CMAKE_USE_PTHREADS_INIT} )
message( FATAL_ERROR "Only pthreads supported - thread library found is [${CMAKE_THREAD_LIBS_INIT}]" )
endif()
message(STATUS " HAVE_ECCODES_THREADS=${HAVE_ECCODES_THREADS}")
set( GRIB_PTHREADS 0 )
set( GRIB_OMP_THREADS 0 )
set( GRIB_LINUX_PTHREADS 0 )
#if( HAVE_ECCODES_THREADS AND CMAKE_THREAD_LIBS_INIT )
if( HAVE_ECCODES_THREADS )
if( CMAKE_USE_PTHREADS_INIT )
set( GRIB_PTHREADS 1 )
if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
set( GRIB_LINUX_PTHREADS 1 )
endif()
if( NOT ${CMAKE_USE_PTHREADS_INIT} )
message( FATAL_ERROR "Pthreads is not supported on your system: thread library found=[${CMAKE_THREAD_LIBS_INIT}]" )
endif()
set( GRIB_PTHREADS 1 )
if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
set( GRIB_LINUX_PTHREADS 1 )
endif()
elseif(HAVE_ECCODES_OMP_THREADS)
ecbuild_enable_omp()
set( GRIB_OMP_THREADS 1 )
endif()
# Cannot have both options
if( HAVE_ECCODES_THREADS AND HAVE_ECCODES_OMP_THREADS )
message( FATAL_ERROR "Cannot enable both POSIX threads and OMP! Please specify just one option" )
endif()
message(STATUS " GRIB_PTHREADS=${GRIB_PTHREADS}")
message(STATUS " GRIB_OMP_THREADS=${GRIB_OMP_THREADS}")