Skip to content

Commit d984fd9

Browse files
committed
Support MinGW in Windows
1 parent ea4230d commit d984fd9

17 files changed

+682
-529
lines changed

BarcodeReader.cxx

Lines changed: 232 additions & 229 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ option(ARM32_BUILD "Build for ARM32" OFF)
66

77
# The version number.
88
set(BarcodeReader_VERSION_MAJOR 8)
9-
set(BarcodeReader_VERSION_MINOR 1)
9+
set(BarcodeReader_VERSION_MINOR 6)
1010

1111
# Check platforms
1212
if (CMAKE_HOST_WIN32)
@@ -17,6 +17,25 @@ elseif(CMAKE_HOST_UNIX)
1717
set(LINUX 1)
1818
endif()
1919

20+
# Check compiler architecture
21+
if(CMAKE_CL_64)
22+
MESSAGE( STATUS ">>>>>>>> 64-bit")
23+
else()
24+
MESSAGE( STATUS ">>>>>>>> 32-bit")
25+
endif()
26+
27+
# Check compilers
28+
MESSAGE( STATUS ">>>>>>>> ${CMAKE_CXX_COMPILER_ID}")
29+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
30+
MESSAGE( STATUS "Using Clang" )
31+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
32+
MESSAGE( STATUS "Using GNU" )
33+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
34+
MESSAGE( STATUS "Using Intel" )
35+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
36+
MESSAGE( STATUS "Using MSVC" )
37+
endif()
38+
2039
# Set RPATH
2140
if(WINDOWS)
2241
else()
@@ -36,8 +55,11 @@ configure_file (
3655
# Add search path for include and lib files
3756
MESSAGE( STATUS "CPU architecture ${CMAKE_SYSTEM_PROCESSOR}" )
3857
if(WINDOWS)
39-
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/platforms/win/lib/" )
40-
link_directories("${PROJECT_SOURCE_DIR}/platforms/win/lib/")
58+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
59+
link_directories("${PROJECT_SOURCE_DIR}/platforms/win/bin/")
60+
else()
61+
link_directories("${PROJECT_SOURCE_DIR}/platforms/win/lib/")
62+
endif()
4163
elseif(LINUX)
4264
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
4365
MESSAGE( STATUS "Link directory: ${PROJECT_SOURCE_DIR}/platforms/linux/" )
@@ -56,23 +78,26 @@ endif()
5678
include_directories("${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/include/")
5779

5880
# Add the executable
59-
add_executable(BarcodeReader BarcodeReader.cxx)
81+
add_executable(${PROJECT_NAME} BarcodeReader.cxx)
6082
if(WINDOWS)
61-
if(CMAKE_CL_64)
62-
target_link_libraries (BarcodeReader "DBRx64")
83+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
84+
target_link_libraries (${PROJECT_NAME} "DynamsoftBarcodeReaderx64")
6385
else()
64-
target_link_libraries (BarcodeReader "DBRx86")
86+
if(CMAKE_CL_64)
87+
target_link_libraries (${PROJECT_NAME} "DBRx64")
88+
else()
89+
target_link_libraries (${PROJECT_NAME} "DBRx86")
90+
endif()
6591
endif()
6692
else()
67-
target_link_libraries (BarcodeReader "DynamsoftBarcodeReader" pthread)
93+
target_link_libraries (${PROJECT_NAME} "DynamsoftBarcodeReader" pthread)
6894
endif()
6995

7096
if(WINDOWS)
71-
add_custom_command(TARGET BarcodeReader POST_BUILD
72-
COMMAND ${CMAKE_COMMAND} -E copy_directory
73-
"${PROJECT_SOURCE_DIR}/platforms/win/bin/"
74-
$<TARGET_FILE_DIR:BarcodeReader>)
75-
97+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
98+
COMMAND ${CMAKE_COMMAND} -E copy_directory
99+
"${PROJECT_SOURCE_DIR}/platforms/win/bin/"
100+
$<TARGET_FILE_DIR:BarcodeReader>)
76101
endif()
77102

78103
# Set installation directory
@@ -91,10 +116,10 @@ elseif(MACOS)
91116
install (DIRECTORY "${PROJECT_SOURCE_DIR}/platforms/macos/" DESTINATION lib)
92117
endif()
93118

94-
install (TARGETS BarcodeReader DESTINATION bin)
119+
install (TARGETS ${PROJECT_NAME} DESTINATION bin)
95120
install (FILES "${PROJECT_BINARY_DIR}/BarcodeReaderConfig.h" DESTINATION include)
96121
install (DIRECTORY "${PROJECT_SOURCE_DIR}/include/" DESTINATION include)
97122

98123
# Use CTest
99124
include(CTest)
100-
add_test (BarcodeReaderRuns BarcodeReader)
125+
add_test (BarcodeReaderRuns ${PROJECT_NAME})

images/multi-qr-code.jpg

2.49 MB
Loading

0 commit comments

Comments
 (0)