Skip to content

Commit

Permalink
fix #2101
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Nov 1, 2019
1 parent e4936ad commit 5e3772c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,22 @@ if (STATIC)
set(LIBRARY_TYPE)
endif()

# Compiler specific environments
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CLANG 1)
endif()

if (WIN32)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
if (NOT CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG -pedantic -Og")
elseif(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
if (NOT CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
if(CLANG)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-command-line-argument")
endif()
set(LIB_Ws2_32 Ws2_32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Wall /bigobj")
elseif(CLANG)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-unused-command-line-argument")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG -pedantic -O0")
endif()

if (OPENMP_BUILD)
Expand All @@ -140,14 +140,15 @@ if (OPENMP_BUILD)
endif()
endif()


if (CYGWIN)
add_definitions(-D__CYGWIN__)
endif()

if (UNIX)
elseif(UNIX)
if (NOT ANDROID)
set(LIB_pthread pthread)
endif()
elseif(WIN32)
set(LIB_Ws2_32 Ws2_32)
endif()

###############################################################################
Expand Down
44 changes: 29 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ AC_INIT([tesseract],
[m4_esyscmd_s([test -d .git && git describe --abbrev=4 || cat VERSION])],
[https://github.com/tesseract-ocr/tesseract/issues],,
[https://github.com/tesseract-ocr/tesseract/])

# Store command like options for CXXFLAGS
OLD_CXXFLAGS=$CXXFLAGS
AC_PROG_CXX([g++ clang++])
# reset compiler flags to initial flags
AC_LANG([C++])
AC_LANG_COMPILER_REQUIRE
CXXFLAGS=${CXXFLAGS:-""}
Expand Down Expand Up @@ -284,17 +288,39 @@ AC_ARG_ENABLE([tessdata-prefix],
AC_MSG_RESULT([$tessdata_prefix])
AM_CONDITIONAL([NO_TESSDATA_PREFIX], [test "$tessdata_prefix" = "no"])
# Detect Clang compiler
AC_MSG_CHECKING([if compiling with clang])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[CLANG=yes], [CLANG=no])
AC_MSG_RESULT([$CLANG])
# Check whether to enable debugging
AC_MSG_CHECKING([whether to enable debugging])
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug], [turn on debugging [default=no]]))
AC_MSG_RESULT([$enable_debug])
if test x"$enable_debug" = x"yes"; then
AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -O0 -DDEBUG"
AM_CPPFLAGS="$AM_CPPFLAGS -g -Wall -DDEBUG"
CXXFLAGS=${CXXFLAGS:-"-O2"}
AM_CPPFLAGS="$AM_CPPFLAGS -g -Wall -DDEBUG -pedantic"
AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -DDEBUG -pedantic"
if test "x$CLANG" = "xyes"; then
# https://clang.llvm.org/docs/CommandGuide/clang.html
# clang treats -Og as -O1
AM_CPPFLAGS="$AM_CPPFLAGS -O0"
AM_CXXFLAGS="$AM_CXXFLAGS -O0"
else
AM_CPPFLAGS="$AM_CPPFLAGS -Og"
AM_CXXFLAGS="$AM_CXXFLAGS -Og"
fi
else
AM_CXXFLAGS="$AM_CXXFLAGS -O2 -DNDEBUG"
AM_CPPFLAGS="$AM_CPPFLAGS -DNDEBUG"
AM_CPPFLAGS="$AM_CPPFLAGS -O2 -DNDEBUG"
fi
#localedir='${prefix}/share/locale'
Expand Down Expand Up @@ -326,18 +352,6 @@ LT_INIT
# ----------------------------------------
# C++ related options
# ----------------------------------------
AC_MSG_CHECKING([if compiling with clang])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
not clang
#endif
]])],
[CLANG=yes], [CLANG=no])
AC_MSG_RESULT([$CLANG])
dnl **********************
dnl Turn on C++11 or newer
dnl **********************
Expand Down

0 comments on commit 5e3772c

Please sign in to comment.