diff --git a/CMakeLists.txt b/CMakeLists.txt index a8b8c653..c7f284e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,9 @@ if (OPENMP_BUILD) 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) + 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) @@ -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)