build: explicitly link stdc++fs on GCC 8

This commit is contained in:
Gabriel Ferreira
2023-04-15 11:48:06 -03:00
parent d38bcac1ab
commit 4b5769439e
2 changed files with 10 additions and 1 deletions

View File

@@ -104,7 +104,9 @@ function(build_lib)
)
endif()
if(NOT FILESYSTEM_LIBRARY_IS_LINKED)
if((NOT FILESYSTEM_LIBRARY_IS_LINKED) OR (${GCC} AND ${GCC8}))
# The GCC8 alternative is necessary since when installed alongside newer
# releases, the incorrect shared library can end up being linked.
list(APPEND BLIB_LIBRARIES_TO_LINK -lstdc++fs)
endif()

View File

@@ -202,6 +202,7 @@ if(CLANG)
endif()
set(GCC FALSE)
set(GCC8 FALSE)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GNU_MinVersion})
message(
@@ -209,6 +210,12 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
"GNU ${CMAKE_CXX_COMPILER_VERSION} ${below_minimum_msg} ${GNU_MinVersion}"
)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")
# This block is used to identify if GCC8 is being used. In this case, we
# want to explicitly link stdc++fs, which is done in
# ns3-module-macros.cmake.
set(GCC8 TRUE)
endif()
set(GCC TRUE)
add_definitions(-fno-semantic-interposition)
if(${NS3_COLORED_OUTPUT} OR "$ENV{CLICOLOR}")