-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
56 lines (41 loc) · 1.79 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
cmake_minimum_required(VERSION 3.1)
project(penguin-recognizer)
# Use C++ 17
set(CMAKE_CXX_STANDARD 17)
# Set Release as default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# change the path to opencv if necessary
if(NOT OPENCV_DIR)
set(OPENCV_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../opencv")
endif(NOT OPENCV_DIR)
# change the path to emsdk if necessary
if(NOT EMSDK_DIR)
set(EMSDK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../emsdk")
endif(NOT EMSDK_DIR)
# Does not work
# find_package(OpenCV REQUIRED PATHS "${OPENCV_DIR}/build_wasm" NO_DEFAULT_PATH)
# Needed for opencv2/opencv.hpp
include_directories("${OPENCV_DIR}/sources/include")
# Needed by opencv.hpp for opencv2/opencv_modules.hpp
include_directories("${OPENCV_DIR}/build_wasm")
# Needed by opencv_modules.hpp for every module
file(GLOB opencv_include_modules "${OPENCV_DIR}/sources/modules/*/include")
include_directories(${opencv_include_modules})
# Needed by emscripten.hpp
include_directories("${EMSDK_DIR}/upstream/emscripten/system/include")
# Needed by sources
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
# Needed by 3rdparty
file(GLOB 3rdparty_include_modules "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/*/include")
include_directories(${3rdparty_include_modules})
# Recognize executable
add_executable(penguin-recognizer "${CMAKE_CURRENT_SOURCE_DIR}/src/recognizer_wasm.cpp")
# Link to opencv.js precompiled libraries
file(GLOB opencv_libs "${OPENCV_DIR}/build_wasm/lib/*.a")
target_link_libraries(penguin-recognizer ${opencv_libs})
file(GLOB opencv_3rdlibs "${OPENCV_DIR}/build_wasm/3rdparty/lib/*.a")
target_link_libraries(penguin-recognizer ${opencv_3rdlibs})
# Specify linker arguments
set_target_properties(penguin-recognizer PROPERTIES LINK_FLAGS "--bind -O3 -s ALLOW_MEMORY_GROWTH=1")