-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an example of reading barcodes from image files.
- Loading branch information
Showing
4 changed files
with
577 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
cmake_minimum_required (VERSION 3.8) | ||
project (main) | ||
MESSAGE( STATUS "PROJECT_NAME: " ${PROJECT_NAME} ) | ||
find_package(OpenCV REQUIRED) | ||
option(ARM32_BUILD "Build for ARM32" OFF) | ||
|
||
# Check ../../../platforms | ||
if (CMAKE_HOST_WIN32) | ||
set(WINDOWS 1) | ||
elseif(CMAKE_HOST_APPLE) | ||
set(MACOS 1) | ||
elseif(CMAKE_HOST_UNIX) | ||
set(LINUX 1) | ||
endif() | ||
|
||
# Check compiler architecture | ||
if(CMAKE_CL_64) | ||
MESSAGE( STATUS ">>>>>>>> 64-bit") | ||
else() | ||
MESSAGE( STATUS ">>>>>>>> 32-bit") | ||
endif() | ||
|
||
# Check compilers | ||
MESSAGE( STATUS ">>>>>>>> ${CMAKE_CXX_COMPILER_ID}") | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
MESSAGE( STATUS "Using Clang" ) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
MESSAGE( STATUS "Using GNU" ) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") | ||
MESSAGE( STATUS "Using Intel" ) | ||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
MESSAGE( STATUS "Using MSVC" ) | ||
endif() | ||
|
||
# Set RPATH | ||
if(CMAKE_HOST_UNIX) | ||
if(CMAKE_HOST_APPLE) | ||
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wl,-rpath,@loader_path") | ||
SET(CMAKE_INSTALL_RPATH "@loader_path") | ||
else() | ||
SET(CMAKE_CXX_FLAGS "-std=c++11 -O3 -Wl,-rpath=$ORIGIN") | ||
SET(CMAKE_INSTALL_RPATH "$ORIGIN") | ||
endif() | ||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
endif() | ||
|
||
# Add search path for include and lib files | ||
MESSAGE( STATUS "CPU architecture ${CMAKE_SYSTEM_PROCESSOR}" ) | ||
if(WINDOWS) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/win/bin/") | ||
else() | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/win/lib/") | ||
endif() | ||
elseif(LINUX) | ||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) | ||
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/../../../platforms/linux/" ) | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/linux/") | ||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR ARM32_BUILD) | ||
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/../../../platforms/arm32/" ) | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/arm32/") | ||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) | ||
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/../../../platforms/aarch64/" ) | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/aarch64/") | ||
endif() | ||
elseif(MACOS) | ||
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/../../../platforms/macos/" ) | ||
link_directories("${PROJECT_SOURCE_DIR}/../../../platforms/macos/") | ||
endif() | ||
include_directories("${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/../../../include/") | ||
|
||
# Add the executable | ||
add_executable(${PROJECT_NAME} main.cxx) | ||
if(WINDOWS) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
target_link_libraries (${PROJECT_NAME} "DynamsoftBarcodeReaderx64" ${OpenCV_LIBS}) | ||
else() | ||
if(CMAKE_CL_64) | ||
target_link_libraries (${PROJECT_NAME} "DBRx64" ${OpenCV_LIBS}) | ||
else() | ||
target_link_libraries (${PROJECT_NAME} "DBRx86" ${OpenCV_LIBS}) | ||
endif() | ||
endif() | ||
else() | ||
target_link_libraries (${PROJECT_NAME} "DynamsoftBarcodeReader" pthread ${OpenCV_LIBS}) | ||
endif() | ||
|
||
if(WINDOWS) | ||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory | ||
"${PROJECT_SOURCE_DIR}/../../../platforms/win/bin/" | ||
$<TARGET_FILE_DIR:main>) | ||
endif() | ||
|
||
# Set installation directory | ||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
if(WINDOWS) | ||
install (DIRECTORY "${PROJECT_SOURCE_DIR}/../../../platforms/win/bin/" DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
elseif(LINUX) | ||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) | ||
install (DIRECTORY "${PROJECT_SOURCE_DIR}/../../../platforms/linux/" DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l OR ARM32_BUILD) | ||
install (DIRECTORY "${PROJECT_SOURCE_DIR}/../../../platforms/arm32/" DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) | ||
install (DIRECTORY "${PROJECT_SOURCE_DIR}/../../../platforms/aarch64/" DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
endif() | ||
elseif(MACOS) | ||
install (DIRECTORY "${PROJECT_SOURCE_DIR}/../../../platforms/macos/" DESTINATION ${PROJECT_SOURCE_DIR}/dist) | ||
endif() | ||
|
||
|
Oops, something went wrong.