diff --git a/build-support/custom-modules/ns3-compiler-workarounds.cmake b/build-support/custom-modules/ns3-compiler-workarounds.cmake index 8bbe15035..6624b787d 100644 --- a/build-support/custom-modules/ns3-compiler-workarounds.cmake +++ b/build-support/custom-modules/ns3-compiler-workarounds.cmake @@ -63,18 +63,19 @@ check_cxx_source_compiles( " STACKTRACE_LIBRARY_ENABLED ) +mark_as_advanced(stacktrace_flags) +set(stacktrace_flags "" CACHE INTERNAL "") if(STACKTRACE_LIBRARY_ENABLED) - set(stacktrace_flags) if(GCC) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0.0") # GCC does not support stacktracing elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "14.0.0") - set(stacktrace_flags -lstdc++_libbacktrace) + set(stacktrace_flags -lstdc++_libbacktrace CACHE INTERNAL "") else() - set(stacktrace_flags -lstdc++exp) + set(stacktrace_flags -lstdc++exp CACHE INTERNAL "") endif() elseif(CLANG) - set(stacktrace_flags -lstdc++_libbacktrace) + set(stacktrace_flags -lstdc++_libbacktrace CACHE INTERNAL "") else() # Most likely MSVC, which does not need custom flags for this endif() @@ -96,6 +97,7 @@ if(STACKTRACE_LIBRARY_ENABLED) if(STACKTRACE_LIBRARY_IS_LINKED) add_definitions(-DSTACKTRACE_LIBRARY_IS_LINKED=1) - link_libraries(${stacktrace_flags}) + else() + set(stacktrace_flags "" CACHE INTERNAL "") endif() endif() diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index 70f2e1ee9..742bc8521 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -288,8 +288,8 @@ endfunction() function(build_lib_reexport_third_party_libraries libname libraries_to_link) # Separate ns-3 and non-ns-3 libraries to manage their propagation properly separate_ns3_from_non_ns3_libs( - "${libname}" "${libraries_to_link}" ns_libraries_to_link - non_ns_libraries_to_link + "${libname}" "${libraries_to_link};${stacktrace_flags}" + ns_libraries_to_link non_ns_libraries_to_link ) set(ns3-external-libs "${non_ns_libraries_to_link};${ns3-external-libs}"