@@ -300,10 +300,11 @@ option(LIBCXX_HAS_EXTERNAL_THREAD_API
300
300
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF )
301
301
302
302
if (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" )
304
304
else ()
305
- set (LIBCXX_PSTL_BACKEND "serial" CACHE STRING "Which PSTL backend to use " )
305
+ set (LIBCXX_PSTL_BACKEND_DEFAULT "serial" )
306
306
endif ()
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} " )
307
308
308
309
# Misc options ----------------------------------------------------------------
309
310
# FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -552,6 +553,11 @@ function(cxx_add_basic_build_flags target)
552
553
endif ()
553
554
endif ()
554
555
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 ()
555
561
endfunction ()
556
562
557
563
# Exception flags =============================================================
@@ -784,6 +790,8 @@ elseif(LIBCXX_PSTL_BACKEND STREQUAL "std_thread")
784
790
config_define(1 _LIBCPP_PSTL_BACKEND_STD_THREAD)
785
791
elseif (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch" )
786
792
config_define(1 _LIBCPP_PSTL_BACKEND_LIBDISPATCH)
793
+ elseif (LIBCXX_PSTL_BACKEND STREQUAL "openmp" )
794
+ config_define(1 _LIBCPP_PSTL_BACKEND_OPENMP)
787
795
else ()
788
796
message (FATAL_ERROR "LIBCXX_PSTL_BACKEND is set to ${LIBCXX_PSTL_BACKEND} , which is not a valid backend.
789
797
Valid backends are: serial, std_thread and libdispatch" )
0 commit comments