forked from kig/zxing-cpp-emscripten
-
Notifications
You must be signed in to change notification settings - Fork 142
/
CMakeLists.txt
78 lines (68 loc) · 2.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#
# CMake listfile to specify the build process, see:
# http://www.cmake.org/cmake/help/documentation.html
#
project(zxing)
cmake_minimum_required(VERSION 2.8.0)
set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
# Check for polluted source tree.
if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt OR
EXISTS ${CMAKE_SOURCE_DIR}/CMakeFiles)
message(FATAL_ERROR
"Source directory is polluted:"
"\n * remove CMakeCache.txt"
"\n * remove CMakeFiles directory")
endif()
# Suppress in-source builds.
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"CMake generation is not allowed within the source directory:"
"\n * mkdir build"
"\n * cd build"
"\n * Unix-like: cmake -G \"Unix Makefiles\" .."
"\n * Windows: cmake -G \"Visual Studio 10\" ..")
endif()
# Adjust CMake's module path.
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
# Suppress MSVC CRT warnings.
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(/Za)
endif()
if (EMSCRIPTEN)
set(CMAKE_AR "emcc")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".bc")
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
set(CMAKE_CXX_FLAGS "-std=c++11 --bind -Oz -s RESERVED_FUNCTION_POINTERS=20 -s EXPORT_NAME=\"'ZXing'\" -s MODULARIZE=1 -s DISABLE_EXCEPTION_CATCHING=0 --memory-init-file 0 -s EXPORTED_FUNCTIONS=\"['_resize','_decode_qr','_decode_qr_multi','_decode_any','_decode_multi']\"")
# Add libzxing library.
file(GLOB_RECURSE LIBZXING_FILES
"./core/src/*.cpp"
"./core/src/*.h"
"./core/src/*.cc"
"./core/src/*.hh"
)
include_directories("./core/src/")
add_library(libzxing STATIC ${LIBZXING_FILES})
set_target_properties(libzxing PROPERTIES PREFIX "")
add_definitions(-DNO_ICONV=1)
# Add cli executable.
file(GLOB_RECURSE ZXING_FILES
"./emscripten/zxing.js.cpp"
)
add_executable(zxing ${ZXING_FILES})
target_link_libraries(zxing libzxing)
# Add testrunner executable.
find_package(CPPUNIT)
if(CPPUNIT_FOUND)
file(GLOB_RECURSE TESTRUNNER_FILES
"./core/tests/src/*.cpp"
"./core/tests/src/*.h"
)
add_executable(testrunner ${TESTRUNNER_FILES})
include_directories(${CPPUNIT_INCLUDE_DIR})
target_link_libraries(testrunner libzxing ${CPPUNIT_LIBRARIES})
else()
message(WARNING "Not building testrunner, because CppUnit is missing")
endif()