Merge pull request #2037 from joelgallant/cmake-fixes

Uses CMAKE_CURRENT_ variables instead of CMAKE_ variables
This commit is contained in:
Egor Pugin 2018-10-31 01:41:50 +03:00 committed by GitHub
commit c8404d63cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.:"
@ -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}")
@ -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})
@ -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)
@ -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)
###############################################################################
#
@ -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)
@ -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__)
@ -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()
########################################
@ -294,7 +294,7 @@ 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})
@ -302,7 +302,7 @@ 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)
@ -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
@ -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)