|
2 | 2 |
|
3 | 3 | Adds the following targets::
|
4 | 4 |
|
5 |
| - pybind11::pybind11 - link to headers and pybind11 |
| 5 | + pybind11::pybind11 - link to Python headers and pybind11::headers |
6 | 6 | pybind11::module - Adds module links
|
7 | 7 | pybind11::embed - Adds embed links
|
8 | 8 | pybind11::lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set)
|
@@ -75,6 +75,32 @@ set_property(
|
75 | 75 | APPEND
|
76 | 76 | PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11)
|
77 | 77 |
|
| 78 | +# -------------- emscripten requires exceptions enabled ------------- |
| 79 | +# _pybind11_no_exceptions is a private mechanism to disable this addition. |
| 80 | +# Please open an issue if you need to use it; it will be removed if no one |
| 81 | +# needs it. |
| 82 | +if(CMAKE_SYSTEM_NAME MATCHES Emscripten AND NOT _pybind11_no_exceptions) |
| 83 | + if(CMAKE_VERSION VERSION_LESS 3.13) |
| 84 | + message(WARNING "CMake 3.13+ is required to build for Emscripten. Some flags will be missing") |
| 85 | + else() |
| 86 | + if(_is_config) |
| 87 | + set(_tmp_config_target pybind11::pybind11_headers) |
| 88 | + else() |
| 89 | + set(_tmp_config_target pybind11_headers) |
| 90 | + endif() |
| 91 | + |
| 92 | + set_property( |
| 93 | + TARGET ${_tmp_config_target} |
| 94 | + APPEND |
| 95 | + PROPERTY INTERFACE_LINK_OPTIONS -fexceptions) |
| 96 | + set_property( |
| 97 | + TARGET ${_tmp_config_target} |
| 98 | + APPEND |
| 99 | + PROPERTY INTERFACE_COMPILE_OPTIONS -fexceptions) |
| 100 | + unset(_tmp_config_target) |
| 101 | + endif() |
| 102 | +endif() |
| 103 | + |
78 | 104 | # --------------------------- link helper ---------------------------
|
79 | 105 |
|
80 | 106 | add_library(pybind11::python_link_helper IMPORTED INTERFACE ${optional_global})
|
@@ -329,7 +355,7 @@ function(_pybind11_generate_lto target prefer_thin_lto)
|
329 | 355 |
|
330 | 356 | if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
|
331 | 357 | # Do nothing
|
332 |
| - elseif(CMAKE_SYSTEM_PROCESSOR MATCHES emscripten) |
| 358 | + elseif(CMAKE_SYSTEM_NAME MATCHES Emscripten) |
333 | 359 | # This compile is very costly when cross-compiling, so set this without checking
|
334 | 360 | set(PYBIND11_LTO_CXX_FLAGS "-flto${thin}${cxx_append}")
|
335 | 361 | set(PYBIND11_LTO_LINKER_FLAGS "-flto${thin}${linker_append}")
|
|
0 commit comments