@@ -300,10 +300,11 @@ option(LIBCXX_HAS_EXTERNAL_THREAD_API
300300 This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF )
301301
302302if (LIBCXX_ENABLE_THREADS)
303- set (LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use " )
303+ set (LIBCXX_PSTL_BACKEND_DEFAULT "std_thread" )
304304else ()
305- set (LIBCXX_PSTL_BACKEND "serial" CACHE STRING "Which PSTL backend to use " )
305+ set (LIBCXX_PSTL_BACKEND_DEFAULT "serial" )
306306endif ()
307+ set (LIBCXX_PSTL_BACKEND "${LIBCXX_PSTL_BACKEND_DEFAULT} " CACHE STRING "Select the PSTL backend to use. Valid values are serial, std-thread, libdispatch, openmp. Default: ${LIBCXX_PSTL_BACKEND_DEFAULT} " )
307308
308309# Misc options ----------------------------------------------------------------
309310# FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -552,6 +553,11 @@ function(cxx_add_basic_build_flags target)
552553 endif ()
553554 endif ()
554555 target_compile_options (${target} PUBLIC "${LIBCXX_ADDITIONAL_COMPILE_FLAGS} " )
556+
557+ # If the PSTL backend depends on OpenMP, we must enable the OpenMP tool chain
558+ if (LIBCXX_PSTL_BACKEND STREQUAL "openmp" )
559+ target_add_compile_flags_if_supported(${target} PUBLIC -fopenmp)
560+ endif ()
555561endfunction ()
556562
557563# Exception flags =============================================================
@@ -784,6 +790,8 @@ elseif(LIBCXX_PSTL_BACKEND STREQUAL "std_thread")
784790 config_define(1 _LIBCPP_PSTL_BACKEND_STD_THREAD)
785791elseif (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch" )
786792 config_define(1 _LIBCPP_PSTL_BACKEND_LIBDISPATCH)
793+ elseif (LIBCXX_PSTL_BACKEND STREQUAL "openmp" )
794+ config_define(1 _LIBCPP_PSTL_BACKEND_OPENMP)
787795else ()
788796 message (FATAL_ERROR "LIBCXX_PSTL_BACKEND is set to ${LIBCXX_PSTL_BACKEND} , which is not a valid backend.
789797 Valid backends are: serial, std_thread and libdispatch" )
0 commit comments