-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
75 lines (65 loc) · 2.35 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
cmake_minimum_required(VERSION 3.24)
project(includejs VERSION 0.0.1 LANGUAGES C CXX
DESCRIPTION "Build your own JavaScript runtime"
HOMEPAGE_URL "https://www.includejs.org")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(vendor/noa/cmake/noa.cmake)
include(cmake/CompilerOptions.cmake)
# C++ standard
set(CMAKE_CXX_STANDARD 17)
# Options
set(INCLUDEJS_BACKEND "JavaScriptCore" CACHE STRING "The IncludeJS Engine backend")
option(INCLUDEJS_ENGINE "Build the IncludeJS engine library" ON)
option(INCLUDEJS_TESTS "Build the IncludeJS tests" OFF)
option(INCLUDEJS_DOCS "Build the IncludeJS docs" OFF)
option(INCLUDEJS_INSTALL "Install the IncludeJS library" ON)
option(INCLUDEJS_ADDRESS_SANITIZER "Build IncludeJS with an address sanitizer" OFF)
option(INCLUDEJS_UNDEFINED_SANITIZER "Build IncludeJS with an undefined behavior sanitizer" OFF)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT includejs_dev)
if(INCLUDEJS_ENGINE)
add_subdirectory(src/engine)
endif()
if(INCLUDEJS_ADDRESS_SANITIZER)
noa_sanitizer(TYPE address)
elseif(INCLUDEJS_UNDEFINED_SANITIZER)
noa_sanitizer(TYPE undefined)
endif()
if(INCLUDEJS_DOCS)
noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
endif()
if(PROJECT_IS_TOP_LEVEL)
noa_target_clang_format(SOURCES
src/*.h src/*.cc
test/*.h test/*.cc)
noa_target_clang_tidy(SOURCES
src/*.h src/*.cc)
endif()
# Testing
if(INCLUDEJS_TESTS)
find_package(GoogleTest REQUIRED)
enable_testing()
if(INCLUDEJS_ENGINE)
add_subdirectory(test/engine)
endif()
if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
if(NOT INCLUDEJS_ADDRESS_SANITIZER AND NOT INCLUDEJS_UNDEFINED_SANITIZER)
add_subdirectory(test/packaging)
endif()
endif()
endif()