mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-13 16:09:04 +08:00
cmake: fix clan openmp build on windows
This commit is contained in:
parent
710fa82fb0
commit
dadf1329e6
@ -149,10 +149,26 @@ if(CLANG) # clang all platforms
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (OPENMP_BUILD)
|
if (OPENMP_BUILD)
|
||||||
|
find_package(OpenMP QUIET)
|
||||||
|
if (OpenMP_FOUND)
|
||||||
|
message(">> ${OpenMP_FOUND} ${OpenMP_VERSION}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||||
|
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
|
||||||
|
endif()
|
||||||
|
# https://stackoverflow.com/questions/12399422/how-to-set-linker-flags-for-openmp-in-cmakes-try-compile-function
|
||||||
|
if (NOT OpenMP_FOUND AND CLANG AND WIN32)
|
||||||
|
# workaroung because find_package(OpenMP) does not work for clang-cl
|
||||||
|
# https://gitlab.kitware.com/cmake/cmake/issues/19404
|
||||||
|
check_include_file_cxx(omp.h HAVE_OMP_H_INCLUDE)
|
||||||
|
find_library(OpenMP_LIBRARY NAMES omp libomp.lib)
|
||||||
|
message(">> OpenMP_LIBRARY: ${OpenMP_LIBRARY}")
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
|
set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS} /openmp")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
|
set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS} -fopenmp")
|
||||||
|
endif()
|
||||||
|
set(OpenMP_FOUND 1)
|
||||||
|
add_definitions(-D_OPENMP=201107) # 3.1 version is supported from Clang 3.8.0
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -477,8 +493,7 @@ endif()
|
|||||||
if (WIN32 AND CLANG AND OPENMP_BUILD)
|
if (WIN32 AND CLANG AND OPENMP_BUILD)
|
||||||
# Workaround for "libomp.lib is not automatically added on Windows"
|
# Workaround for "libomp.lib is not automatically added on Windows"
|
||||||
# see: http://lists.llvm.org/pipermail/openmp-dev/2015-August/000857.html
|
# see: http://lists.llvm.org/pipermail/openmp-dev/2015-August/000857.html
|
||||||
# TODO: Find better way how to set Clang OpenMP library for linking on Windows
|
target_link_libraries (libtesseract PRIVATE ${OpenMP_LIBRARY})
|
||||||
target_link_libraries (libtesseract PRIVATE "c:\\Program Files\\LLVM\\lib\\libomp.lib")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
|
Loading…
Reference in New Issue
Block a user