diff options
Diffstat (limited to 'build_files/cmake/platform/platform_apple.cmake')
-rw-r--r-- | build_files/cmake/platform/platform_apple.cmake | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 55642b534c2..758c746625e 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -385,13 +385,22 @@ if(WITH_CYCLES_EMBREE) set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -stack_size -Xlinker 0x100000") endif() +# CMake FindOpenMP doesn't know about AppleClang before 3.12, so provide custom flags. if(WITH_OPENMP) - execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR) - string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output - if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang - set(WITH_OPENMP OFF) - else() # vanilla gcc or clang_omp support OpenMP - message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc + if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0") + # Use OpenMP from our precompiled libraries. + message(STATUS "Using ${LIBDIR}/openmp for OpenMP") + set(OPENMP_CUSTOM ON) + set(OPENMP_FOUND ON) + set(OpenMP_C_FLAGS "-Xclang -fopenmp -I${LIBDIR}/openmp/include") + set(OpenMP_CXX_FLAGS "-Xclang -fopenmp -I${LIBDIR}/openmp/include") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${LIBDIR}/openmp/lib -lomp") + + # Copy libomp.dylib to allow executables like datatoc to work. + execute_process( + COMMAND mkdir -p ${CMAKE_BINARY_DIR}/Resources/lib + COMMAND cp -p ${LIBDIR}/openmp/lib/libomp.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libomp.dylib + ) endif() endif() |