-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
70 lines (63 loc) · 2.53 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
cmake_minimum_required(VERSION 3.3)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(libmc)
set(CMAKE_BUILD_TYPE debug)
enable_testing()
option(BUILD_SAMPLES "Build the sample programs" ON)
option(BUILD_DOCUMENTATION "Build the documentation" OFF)
option(BUILD_SCREENSHOTS "Generate screenshots for the documentation" OFF)
option(BUILD_COVERAGE "Generate gcov code coverage reports" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include_directories(SYSTEM
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)
if(DEFINED ENV{EMSCRIPTEN})
if(CMAKE_BUILD_TYPE MATCHES debug)
set(EMSCRIPTEN_FLAGS
"-O1"
"-s ASSERTIONS=2"
"-s SAFE_HEAP=1"
"-s STACK_OVERFLOW_CHECK=2"
"-s DISABLE_EXCEPTION_CATCHING=0"
"-s ALLOW_MEMORY_GROWTH=1"
)
string (REPLACE ";" " " EMSCRIPTEN_FLAGS "${EMSCRIPTEN_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMSCRIPTEN_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMSCRIPTEN_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_FLAGS}")
elseif(CMAKE_BUILD_TYPE MATCHES release)
set(EMSCRIPTEN_FLAGS
"-O2"
"-s ASSERTIONS=0"
"-s SAFE_HEAP=0"
"-s STACK_OVERFLOW_CHECK=0"
"-s DISABLE_EXCEPTION_CATCHING=1"
"-s ALLOW_MEMORY_GROWTH=0"
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMSCRIPTEN_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EMSCRIPTEN_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_FLAGS}")
else()
message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif()
# Use C++11 everywhere with Emscripten
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# C++ demangle support with Emscripten
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s DEMANGLE_SUPPORT=1")
endif()
if(BUILD_COVERAGE)
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
endif()
if(BUILD_PROFILE)
SET(GCC_PROFILE_COMPILE_FLAGS "-pg")
SET(GCC_PROFILE_LINK_FLAGS "-pg")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_PROFILE_COMPILE_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_PROFILE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_PROFILE_LINK_FLAGS}")
endif()
add_subdirectory("./src")