fix #2847 cmake with OPENMP_BUILD=ON

This commit is contained in:
zdenop 2020-01-05 22:33:24 +01:00
parent faf54e08f7
commit 8ba14a655d

View File

@ -151,8 +151,10 @@ if (OPENMP_BUILD)
if (OpenMP_FOUND)
message(">> ${OpenMP_FOUND} ${OpenMP_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
if(${CMAKE_VERSION} VERSION_LESS "3.9.0")
add_library(OpenMP::OpenMP_CXX IMPORTED INTERFACE)
endif()
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
@ -448,6 +450,9 @@ target_compile_definitions (libtesseract
set_target_properties (libtesseract PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS True)
endif()
target_link_libraries (libtesseract PRIVATE ${LIB_Ws2_32} ${LIB_pthread})
if(OpenMP_CXX_FOUND)
target_link_libraries(libtesseract PUBLIC OpenMP::OpenMP_CXX)
endif()
set_target_properties (libtesseract PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set_target_properties (libtesseract PROPERTIES SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
if (WIN32)