This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
CMakeLists.txt
90 lines (78 loc) · 2.63 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
79
80
81
82
83
84
85
86
87
88
89
90
# ============================================================================ #
# Project modules #
# ============================================================================ #
# CMake version
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
# Compile to Wasm
option(BABYLON_WASM "Target emscriptem / wasm" OFF)
if (BABYLON_WASM)
# emscripten is detected via
# - if (EMSCRIPTEN) in cmake code
# - #ifdef __EMSCRIPTEN__ in c++ code
set(EMSCRIPTEN ON)
set(BUILD_SHARED_LIBS OFF)
set(BABYLON_DISABLE_INSTALL ON)
set(OPTION_BUILD_TESTS_DEFAULT OFF)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/WasmEmscriptenOptions.cmake)
else()
set(OPTION_BUILD_TESTS_DEFAULT ON)
endif()
if (NOT BABYLON_WASM OR NOT IOS)
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
endif()
option(BABYLON_SANITIZE_ASAN "Use clang address sanitizer" OFF)
if (BABYLON_SANITIZE_ASAN)
add_compile_options("-fsanitize=address")
link_libraries("-fsanitize=address")
link_libraries(-shared-libasan)
endif()
option(BABYLON_SANITIZE_UB "Use clang UB (undefined behavior) sanitizer" OFF)
if (BABYLON_SANITIZE_UB)
add_compile_options("-fsanitize=undefined")
link_libraries("-fsanitize=undefined")
endif()
# use ccache if present
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
option(USE_CCACHE "Use ccache for the build" OFF)
if (USE_CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
endif()
option(OPTION_BUILD_TESTS "Build tests." ${OPTION_BUILD_TESTS_DEFAULT})
if(OPTION_BUILD_TESTS)
enable_testing()
endif()
# use clang-tidy if present
option(BABYLON_USE_CLANG_TIDY "Use clang-tidy static analysis" OFF)
if (BABYLON_USE_CLANG_TIDY)
find_program(
CLANG_TIDY_EXE
HINTS ~/bin/clang/bin/
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(NOT CLANG_TIDY_EXE)
message(FATAL "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
# set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*,-clang-analyzer-alpha.*")
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()
endif()
function(babylon_target_clang_tidy target)
if (BABYLON_USE_CLANG_TIDY)
set_target_properties(
${target} PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
endif()
endfunction()
# Generate folders for IDE targets (e.g., VisualStudio solutions)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Project name
project(BabylonCpp C CXX)
# Project modules
add_subdirectory(codegeneration)
add_subdirectory(external)
add_subdirectory(src)