|
1 | 1 | # Copyright (C) 2020 Matthew "strager" Glazar |
2 | 2 | # See end of file for extended copyright information. |
3 | 3 |
|
4 | | -include(CheckCXXCompilerFlag) |
| 4 | +if (QUICK_LINT_JS_USE_BUNDLED_BOOST) |
| 5 | + include(CheckCXXCompilerFlag) |
5 | 6 |
|
6 | | -add_library( |
7 | | - boost |
8 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/alloc_lib.c" |
9 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/dlmalloc.cpp" |
10 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/global_resource.cpp" |
11 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/monotonic_buffer_resource.cpp" |
12 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/pool_resource.cpp" |
13 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/synchronized_pool_resource.cpp" |
14 | | - "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/unsynchronized_pool_resource.cpp" |
15 | | -) |
16 | | -# NOTE(strager): SYSTEM disable undesirable warnings in Boost header files. |
17 | | -target_include_directories(boost SYSTEM PUBLIC "${CMAKE_CURRENT_LIST_DIR}/boost") |
18 | | -target_compile_definitions( |
19 | | - boost |
20 | | - PUBLIC |
21 | | - BOOST_ALL_NO_LIB |
22 | | - BOOST_CONTAINER_NO_LIB |
23 | | - BOOST_JSON_STANDALONE |
24 | | - BOOST_JSON_USE_BOOST_PMR |
25 | | - BOOST_LEAF_NO_EXCEPTIONS |
26 | | - BOOST_NO_EXCEPTIONS |
27 | | -) |
28 | | -# Disable undesirable warnings in headers and source files. |
29 | | -quick_lint_js_add_warning_options_if_supported( |
30 | | - boost |
31 | | - PRIVATE |
32 | | - -Wno-null-pointer-arithmetic |
33 | | -) |
34 | | - |
35 | | -# Allow the entire project to be compiled with -fno-rtti. Boost uses |
36 | | -# dynamic_cast which requires RTTI, so forcefully enable RTTI for Boost. |
37 | | -check_cxx_compiler_flag(-frtti QUICK_LINT_JS_HAVE_FRTTI) |
38 | | -if (QUICK_LINT_JS_HAVE_FRTTI) |
39 | | - target_compile_options( |
| 7 | + add_library( |
| 8 | + boost |
| 9 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/alloc_lib.c" |
| 10 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/dlmalloc.cpp" |
| 11 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/global_resource.cpp" |
| 12 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/monotonic_buffer_resource.cpp" |
| 13 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/pool_resource.cpp" |
| 14 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/synchronized_pool_resource.cpp" |
| 15 | + "${CMAKE_CURRENT_LIST_DIR}/boost/libs/container/src/unsynchronized_pool_resource.cpp" |
| 16 | + ) |
| 17 | + # NOTE(strager): SYSTEM disable undesirable warnings in Boost header files. |
| 18 | + target_include_directories(boost SYSTEM PUBLIC "${CMAKE_CURRENT_LIST_DIR}/boost") |
| 19 | + target_compile_definitions( |
| 20 | + boost |
| 21 | + PUBLIC |
| 22 | + BOOST_ALL_NO_LIB |
| 23 | + BOOST_CONTAINER_NO_LIB |
| 24 | + BOOST_JSON_STANDALONE |
| 25 | + BOOST_JSON_USE_BOOST_PMR |
| 26 | + BOOST_LEAF_NO_EXCEPTIONS |
| 27 | + BOOST_NO_EXCEPTIONS |
| 28 | + ) |
| 29 | + # Disable undesirable warnings in headers and source files. |
| 30 | + quick_lint_js_add_warning_options_if_supported( |
40 | 31 | boost |
41 | 32 | PRIVATE |
42 | | - $<$<COMPILE_LANGUAGE:CXX>:-frtti> |
| 33 | + -Wno-null-pointer-arithmetic |
43 | 34 | ) |
44 | | -endif () |
45 | 35 |
|
46 | | -if (EMSCRIPTEN) |
47 | | - # HACK(strager): In STANDALONE_WASM mode, emscripten generates calls to |
48 | | - # clock_time_get, originating from Boost. As of Node.js version v12.20.0, such |
49 | | - # calls require Node to be run with --experimental-wasm-bigint. Without this |
50 | | - # flag, clock_time_get calls fail with the following message: |
51 | | - # |
52 | | - # > Error: TypeError: wasm function signature contains illegal type |
53 | | - # |
54 | | - # Our Visual Studio Code plugin cannot enable this Node.js flag itself. Work |
55 | | - # around emscripten's code gen by avoiding the call to clock_time_get in |
56 | | - # Boost's dlmalloc. |
57 | | - target_compile_definitions(boost PRIVATE LACKS_TIME_H) |
58 | | -endif () |
| 36 | + # Allow the entire project to be compiled with -fno-rtti. Boost uses |
| 37 | + # dynamic_cast which requires RTTI, so forcefully enable RTTI for Boost. |
| 38 | + check_cxx_compiler_flag(-frtti QUICK_LINT_JS_HAVE_FRTTI) |
| 39 | + if (QUICK_LINT_JS_HAVE_FRTTI) |
| 40 | + target_compile_options( |
| 41 | + boost |
| 42 | + PRIVATE |
| 43 | + $<$<COMPILE_LANGUAGE:CXX>:-frtti> |
| 44 | + ) |
| 45 | + endif () |
59 | 46 |
|
60 | | -# Keep boost_json as a separate library so we can use it only in tests (and not |
61 | | -# compile and link it into production executables). |
62 | | -add_library(boost_json STATIC "${CMAKE_CURRENT_LIST_DIR}/boost-json.cpp") |
63 | | -target_link_libraries(boost_json PUBLIC boost) |
| 47 | + if (EMSCRIPTEN) |
| 48 | + # HACK(strager): In STANDALONE_WASM mode, emscripten generates calls to |
| 49 | + # clock_time_get, originating from Boost. As of Node.js version v12.20.0, such |
| 50 | + # calls require Node to be run with --experimental-wasm-bigint. Without this |
| 51 | + # flag, clock_time_get calls fail with the following message: |
| 52 | + # |
| 53 | + # > Error: TypeError: wasm function signature contains illegal type |
| 54 | + # |
| 55 | + # Our Visual Studio Code plugin cannot enable this Node.js flag itself. Work |
| 56 | + # around emscripten's code gen by avoiding the call to clock_time_get in |
| 57 | + # Boost's dlmalloc. |
| 58 | + target_compile_definitions(boost PRIVATE LACKS_TIME_H) |
| 59 | + endif () |
| 60 | + |
| 61 | + # Keep boost_json as a separate library so we can use it only in tests (and not |
| 62 | + # compile and link it into production executables). |
| 63 | + add_library(boost_json STATIC "${CMAKE_CURRENT_LIST_DIR}/boost-json.cpp") |
| 64 | + target_link_libraries(boost_json PUBLIC boost) |
| 65 | +else () |
| 66 | + find_package(Boost REQUIRED COMPONENTS container json) |
| 67 | + add_library(boost INTERFACE) |
| 68 | + target_link_libraries(boost INTERFACE Boost::boost Boost::container) |
| 69 | + add_library(boost_json ALIAS Boost::json) |
| 70 | +endif () |
64 | 71 |
|
65 | 72 | # quick-lint-js finds bugs in JavaScript programs. |
66 | 73 | # Copyright (C) 2020 Matthew "strager" Glazar |
|
0 commit comments