-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
57 lines (44 loc) · 1.58 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
cmake_minimum_required (VERSION 3.5)
project(xlnt-wasm VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_VERBOSE_MAKEFILE OFF)
include(${CMAKE_SOURCE_DIR}/cmake/FunctionAddExternal.cmake)
if(NOT DEFINED ENV{EMSCRIPTEN})
message(FATAL_ERROR "Emscripten not found. Set EMSCRIPTEN environment variable to point to the emscripten root directory")
endif()
add_subdirectory(dependencies)
add_executable(bindings "")
target_sources(bindings
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/src/bindings.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/embind_helper.cpp"
)
target_include_directories(bindings
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(bindings PRIVATE -O3)
target_compile_options(bindings
PRIVATE
-O3
-Wall
$<$<COMPILE_LANGUAGE:CXX>:-std=c++14>)
set_target_properties(bindings PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
CMAKE_CXX_EXTENSIONS OFF
OUTPUT_NAME "xlnt"
SUFFIX ".js"
LINK_FLAGS "--bind -s ALLOW_MEMORY_GROWTH=1 -s WASM=1 -s EXPORT_NAME=\"'load_xlnt'\" -s MODULARIZE=1 -s EMBIND_STD_STRING_IS_UTF8=1")
add_dependencies(bindings xlnt)
target_link_libraries(bindings PRIVATE xlnt)
add_custom_command(TARGET bindings POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
xlnt.js
${CMAKE_CURRENT_SOURCE_DIR}/dist/xlnt.js)
add_custom_command(TARGET bindings POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
xlnt.wasm
${CMAKE_CURRENT_SOURCE_DIR}/dist/xlnt.wasm)