LeadTools common.mk as CMake

I am trying out the Lead Tools SDK for a Linux based OCR embedded project. In the demo for the OCR portion there is a make file and the project I am trying to integrate it with uses CMake. I wrote a CMake equivalent for integration:

# Get machine type
machine_type = $(shell /usr/bin/env bash -c "arch")
ifeq (${machine_type}, x86_64)
lib_arch=x64
else ifeq (${machine_type}, x64)
lib_arch=x64
else
lib_arch=x86
endif
LT_INCLUDE_DIR ?= ../../../../Include
LT_COMMON_DIR ?= ../Common
LT_LIB_DIR ?= ../../../../Bin/Lib/${lib_arch}
LT_LTVxx_CONFIG ?= LTV20_CONFIG
CC ?= gcc
CPPFLAGS += -DFOR_LINUX -D _GNU_SOURCE -D${LT_LTVxx_CONFIG} -I${LT_INCLUDE_DIR} -I${LT_COMMON_DIR}
CFLAGS += -L${LT_LIB_DIR}
LDFLAGS += -Wall -Wl,-rpath=$(abspath ${LT_LIB_DIR})
all: ${TARGET}
print:
@echo "Building ${TARGET} Demo"
${TARGET}: print
${CC} -g ${SOURCES} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -o ${LT_LIB_DIR}/$@
clean:
@rm -r bin 2> /dev/null || :

view raw
common.mk
hosted with ❤ by GitHub

if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(lib_arch x64)
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x64")
set(lib_arch x64)
elseif(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86")
set(lib_arch x86)
else()
message(FATAL_ERROR "System architecture is not supported")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/Lead/Include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/Lead/Bin/Lib/${lib_arch})
add_compile_definitions(LTV20_CONFIG FOR_LINUX _GNU_SOURCE)

view raw
LeadTools.cmake
hosted with ❤ by GitHub

One thought on “LeadTools common.mk as CMake

Leave a Reply