diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 91d802cbe73..b3a7324051f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -40,6 +40,12 @@ if(WITH_TBB) list(INSERT LIB 0 bf_blenkernel) endif() +if(WITH_OPENMP AND WITH_OPENMP_STATIC) + list(APPEND LIB + ${OpenMP_LIBRARIES} + ) +endif() + if(WIN32) list(APPEND INC ../../intern/utfconv) endif() diff --git a/source/creator/creator.cc b/source/creator/creator.cc index 310e2cbfc48..2366060622e 100644 --- a/source/creator/creator.cc +++ b/source/creator/creator.cc @@ -82,6 +82,10 @@ # include #endif +#ifdef _OPENMP +# include +#endif + #ifdef WITH_BINRELOC # include "binreloc.h" #endif @@ -300,12 +304,19 @@ int main(int argc, setvbuf(stdout, nullptr, _IONBF, 0); #endif -#ifdef WIN32 -/* We delay loading of OPENMP so we can set the policy here. */ -# if defined(_MSC_VER) +#ifdef _OPENMP +# if defined(WIN32) && defined(_MSC_VER) + /* We delay loading of OPENMP so we can set the policy here. */ _putenv_s("OMP_WAIT_POLICY", "PASSIVE"); # endif + /* Ensure the OpenMP runtime is initialized as soon as possible to make sure duplicate + * libomp/libiomp5 runtime conflicts are detected as soon as a second runtime is initialized. + * Initialization must be done after setting any relevant environment variables, but before + * installing signal handlers. */ + omp_get_max_threads(); +#endif +#ifdef WIN32 # ifdef USE_WIN32_UNICODE_ARGS /* Win32 Unicode Arguments. */ {