diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 9b1c6d1b..973e771d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -36,7 +36,13 @@ else() endif() add_custom_target(libloot-cpp-build - COMMAND cargo build + # Force LTO to be disabled when building the first layer of the C++ wrapper, + # as it may be enabled by default, and if so that leads to undefined symbols + # in the C++ wrapper's shared library. It's not enough to just pass -fno-lto + # when building libloot-cpp itself, it also needs to be passed when building + # the cxx crate, as otherwise there will be missing cxxbridge symbols. + COMMAND ${CMAKE_COMMAND} -E env --modify "CXXFLAGS=string_append: -fno-lto" -- + cargo build $<$>:--release> $<$,$>:--config> $<$,$>:${PROJECT_SOURCE_DIR}/.cargo/msvc-debug-config.toml>