Skip to content

Commit b30e92f

Browse files
committed
turn off openmp build for cmake (issue #263)
1 parent 50f5662 commit b30e92f

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

CMakeLists.txt

+24-11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ set(GENERIC_MICRO_VERSION ${VERSION_PATCH})
5353

5454
set(MINIMUM_LEPTONICA_VERSION 1.74)
5555

56+
###############################################################################
57+
#
58+
# options
59+
#
60+
###############################################################################
61+
62+
option(CPPAN_BUILD "Build with cppan" ON)
63+
option(OPENMP_BUILD "Build with openmp support" OFF) # see issue #1662
64+
option(BUILD_TRAINING_TOOLS "Build training tools" ON)
65+
option(BUILD_TESTS "Build tests" OFF)
66+
67+
5668
###############################################################################
5769
#
5870
# compiler and linker
@@ -71,17 +83,23 @@ endif()
7183
if (WIN32)
7284
if (MSVC)
7385
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
74-
if (CLANG)
75-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp /utf-8")
76-
else()
86+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
87+
if (NOT CLANG)
7788
add_definitions(-DNOMINMAX)
78-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp /utf-8")
89+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
7990
endif()
8091
endif()
81-
8292
set(LIB_Ws2_32 Ws2_32)
8393
endif()
8494

95+
if (OPENMP_BUILD)
96+
if (CLANG)
97+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp")
98+
else(MSVC)
99+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
100+
endif()
101+
endif()
102+
85103
if (CYGWIN)
86104
add_definitions(-D__CYGWIN__)
87105
endif()
@@ -100,8 +118,6 @@ endif()
100118
#
101119
###############################################################################
102120

103-
option(CPPAN_BUILD "Build with cppan" ON)
104-
105121
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.cppan OR NOT CPPAN_BUILD)
106122
if (NOT Leptonica_DIR AND NOT MSVC)
107123
find_package(PkgConfig REQUIRED)
@@ -121,9 +137,6 @@ endif()
121137

122138
find_package(OpenCL QUIET)
123139

124-
option(BUILD_TRAINING_TOOLS "Build training tools" ON)
125-
option(BUILD_TESTS "Build tests" OFF)
126-
127140
###############################################################################
128141
#
129142
# configure
@@ -302,7 +315,7 @@ else()
302315
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
303316
endif()
304317

305-
if (WIN32 AND CLANG)
318+
if (WIN32 AND CLANG AND OPENMP_BUILD)
306319
# Workaround for "libomp.lib is not automatically added on Windows"
307320
# see: http://lists.llvm.org/pipermail/openmp-dev/2015-August/000857.html
308321
# TODO: Find better way how to set Clang OpenMP library for linking on Windows

0 commit comments

Comments
 (0)