Skip to content

Commit

Permalink
Merge pull request #2037 from joelgallant/cmake-fixes
Browse files Browse the repository at this point in the history
Uses CMAKE_CURRENT_ variables instead of CMAKE_ variables
  • Loading branch information
egorpugin authored Oct 30, 2018
2 parents 3ac33d5 + 422d1ca commit c8404d6
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cmake_minimum_required(VERSION 2.8.11)

# In-source builds are disabled.
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(FATAL_ERROR
"CMake generation is not possible within the source directory!"
"\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
Expand All @@ -23,7 +23,7 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
)
endif()

set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}")
Expand Down Expand Up @@ -91,7 +91,7 @@ endif()
#
###############################################################################

if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.cppan)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.cppan)
if (NOT Leptonica_DIR AND NOT MSVC)
find_package(PkgConfig REQUIRED)
pkg_check_modules(Leptonica REQUIRED lept>=${MINIMUM_LEPTONICA_VERSION})
Expand Down Expand Up @@ -119,8 +119,8 @@ option(BUILD_TESTS "Build tests" OFF)
#
###############################################################################

set(AUTOCONFIG_SRC ${CMAKE_BINARY_DIR}/config_auto.h.in)
set(AUTOCONFIG ${CMAKE_BINARY_DIR}/config_auto.h)
set(AUTOCONFIG_SRC ${CMAKE_CURRENT_BINARY_DIR}/config_auto.h.in)
set(AUTOCONFIG ${CMAKE_CURRENT_BINARY_DIR}/config_auto.h)

include(Configure)

Expand All @@ -129,20 +129,20 @@ configure_file(${AUTOCONFIG_SRC} ${AUTOCONFIG} @ONLY)
set(INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" "${CMAKE_INSTALL_PREFIX}/include/tesseract")

configure_file(
${CMAKE_SOURCE_DIR}/src/api/tess_version.h.in
${CMAKE_BINARY_DIR}/api/tess_version.h @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/src/api/tess_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/api/tess_version.h @ONLY)
configure_file(
${CMAKE_SOURCE_DIR}/src/vs2010/tesseract/tesseract.rc.in
${CMAKE_BINARY_DIR}/vs2010/tesseract/tesseract.rc @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/tesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/tesseract.rc @ONLY)
configure_file(
${CMAKE_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in
${CMAKE_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/libtesseract.rc.in
${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc @ONLY)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in
${CMAKE_BINARY_DIR}/TesseractConfig-version.cmake @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig-version.cmake @ONLY)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in
${CMAKE_BINARY_DIR}/TesseractConfig.cmake @ONLY)
${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/TesseractConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig.cmake @ONLY)

###############################################################################
#
Expand All @@ -159,10 +159,10 @@ add_definitions(-DWINDLLNAME="libtesseract${VERSION_MAJOR}${VERSION_MINOR}.dll")

include_directories(${Leptonica_INCLUDE_DIRS})

include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

include_directories(src/api)
include_directories(${CMAKE_BINARY_DIR}/api)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/api)
include_directories(src/arch)
include_directories(src/ccmain)
include_directories(src/ccstruct)
Expand Down Expand Up @@ -230,7 +230,7 @@ if (WIN32)
set(tesseract_hdr
${tesseract_hdr}
${CMAKE_CURRENT_SOURCE_DIR}/src/vs2010/tesseract/resource.h)
set(tesseract_rsc ${CMAKE_BINARY_DIR}/vs2010/tesseract/libtesseract.rc)
set(tesseract_rsc ${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/libtesseract.rc)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/src/arch/dotproductsse.cpp
PROPERTIES COMPILE_DEFINITIONS __SSE4_1__)
Expand Down Expand Up @@ -281,11 +281,11 @@ endif()

if (NOT CPPAN_BUILD)
target_link_libraries (libtesseract ${Leptonica_LIBRARIES})
export(TARGETS libtesseract FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake)
export(TARGETS libtesseract FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
else()
target_link_libraries (libtesseract pvt.cppan.demo.danbloomberg.leptonica)
file(WRITE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_BINARY_DIR}/cppan.cmake)\n")
export(TARGETS libtesseract APPEND FILE ${CMAKE_BINARY_DIR}/TesseractTargets.cmake)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake "include(${CMAKE_CURRENT_BINARY_DIR}/cppan.cmake)\n")
export(TARGETS libtesseract APPEND FILE ${CMAKE_CURRENT_BINARY_DIR}/TesseractTargets.cmake)
endif()

########################################
Expand All @@ -294,15 +294,15 @@ endif()

set(tesseractmain_src src/api/tesseractmain.cpp)
if (MSVC)
set(tesseractmain_rsc ${CMAKE_BINARY_DIR}/vs2010/tesseract/tesseract.rc)
set(tesseractmain_rsc ${CMAKE_CURRENT_BINARY_DIR}/vs2010/tesseract/tesseract.rc)
endif()

add_executable (tesseract ${tesseractmain_src} ${tesseractmain_rsc})
target_link_libraries (tesseract libtesseract)

########################################

if (BUILD_TESTS AND EXISTS ${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt)
if (BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest/CMakeLists.txt)
add_subdirectory(googletest)
add_executable(tesseract_tests tests/tesseracttests.cpp)
target_link_libraries(tesseract_tests gtest_main)
Expand All @@ -321,8 +321,8 @@ install(TARGETS tesseract RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIV
install(TARGETS libtesseract EXPORT TesseractTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(EXPORT TesseractTargets DESTINATION cmake)
install(FILES
${CMAKE_BINARY_DIR}/TesseractConfig.cmake
${CMAKE_BINARY_DIR}/TesseractConfig-version.cmake
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/TesseractConfig-version.cmake
DESTINATION cmake)

install(FILES
Expand Down Expand Up @@ -394,7 +394,7 @@ install(FILES
src/lstm/tfnetwork.h
src/lstm/weightmatrix.h

#${CMAKE_BINARY_DIR}/src/endianness.h
#${CMAKE_CURRENT_BINARY_DIR}/src/endianness.h
DESTINATION include/tesseract)


Expand Down

0 comments on commit c8404d6

Please sign in to comment.