From c06929083beed934efbf185c7781a94cf2d2fd84 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 31 Mar 2021 18:31:29 +0200 Subject: [PATCH] Process the openMP flags before using as compile options --- cmake/SfizzDeps.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmake/SfizzDeps.cmake b/cmake/SfizzDeps.cmake index e6f07c1c..b167bcb5 100644 --- a/cmake/SfizzDeps.cmake +++ b/cmake/SfizzDeps.cmake @@ -6,9 +6,19 @@ find_package(OpenMP) if(OPENMP_FOUND) add_library(sfizz_openmp INTERFACE) add_library(sfizz::openmp ALIAS sfizz_openmp) + + # OpenMP flags are provided as a space-separated string, we need a list + if(CMAKE_HOST_WIN32) + separate_arguments(SFIZZ_OpenMP_C_OPTIONS WINDOWS_COMMAND "${OpenMP_C_FLAGS}") + separate_arguments(SFIZZ_OpenMP_CXX_OPTIONS WINDOWS_COMMAND "${OpenMP_CXX_FLAGS}") + else() + separate_arguments(SFIZZ_OpenMP_C_OPTIONS UNIX_COMMAND "${OpenMP_C_FLAGS}") + separate_arguments(SFIZZ_OpenMP_CXX_OPTIONS UNIX_COMMAND "${OpenMP_CXX_FLAGS}") + endif() + target_compile_options(sfizz_openmp INTERFACE - $<$:${OpenMP_C_FLAGS}> - $<$:${OpenMP_CXX_FLAGS}>) + $<$:${SFIZZ_OpenMP_C_OPTIONS}> + $<$:${SFIZZ_OpenMP_CXX_OPTIONS}>) endif() # Find macOS system libraries