Skip to content

Commit

Permalink
turn off openmp build for cmake (issue #263)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Jan 24, 2019
1 parent 50f5662 commit b30e92f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions CMakeLists.txt
Expand Up @@ -53,6 +53,18 @@ set(GENERIC_MICRO_VERSION ${VERSION_PATCH})

set(MINIMUM_LEPTONICA_VERSION 1.74)

###############################################################################
#
# options
#
###############################################################################

option(CPPAN_BUILD "Build with cppan" ON)
option(OPENMP_BUILD "Build with openmp support" OFF) # see issue #1662
option(BUILD_TRAINING_TOOLS "Build training tools" ON)
option(BUILD_TESTS "Build tests" OFF)


###############################################################################
#
# compiler and linker
Expand All @@ -71,17 +83,23 @@ endif()
if (WIN32)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if (CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp /utf-8")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
if (NOT CLANG)
add_definitions(-DNOMINMAX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp /utf-8")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
endif()

set(LIB_Ws2_32 Ws2_32)
endif()

if (OPENMP_BUILD)
if (CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp")
else(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
endif()
endif()

if (CYGWIN)
add_definitions(-D__CYGWIN__)
endif()
Expand All @@ -100,8 +118,6 @@ endif()
#
###############################################################################

option(CPPAN_BUILD "Build with cppan" ON)

if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.cppan OR NOT CPPAN_BUILD)
if (NOT Leptonica_DIR AND NOT MSVC)
find_package(PkgConfig REQUIRED)
Expand All @@ -121,9 +137,6 @@ endif()

find_package(OpenCL QUIET)

option(BUILD_TRAINING_TOOLS "Build training tools" ON)
option(BUILD_TESTS "Build tests" OFF)

###############################################################################
#
# configure
Expand Down Expand Up @@ -302,7 +315,7 @@ else()
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
endif()

if (WIN32 AND CLANG)
if (WIN32 AND CLANG AND OPENMP_BUILD)
# Workaround for "libomp.lib is not automatically added on Windows"
# 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
Expand Down

0 comments on commit b30e92f

Please sign in to comment.