diff --git a/CMakeLists.txt b/CMakeLists.txt index eea379c58..ac372c362 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,11 @@ option(NS3_FAST_LINKERS "Use Mold or LLD to speed up linking if available" ON) option(NS3_FETCH_OPTIONAL_COMPONENTS "Fetch Brite, Click and Openflow dependencies" OFF ) +option( + NS3_FORCE_LOCAL_DEPENDENCIES + "Only search applications, headers, libraries on explicitly set directories" + OFF +) option(NS3_GSL "Build with GSL support" ON) option(NS3_GTK3 "Build with GTK3 support" ON) option(NS3_LINK_TIME_OPTIMIZATION "Build with link-time optimization" OFF) diff --git a/build-support/3rd-party/find-program-hints.cmake b/build-support/3rd-party/find-program-hints.cmake index 61106b9e6..b81957231 100644 --- a/build-support/3rd-party/find-program-hints.cmake +++ b/build-support/3rd-party/find-program-hints.cmake @@ -1,4 +1,5 @@ disable_cmake_warnings() +string(REPLACE ";" "/bin;" syspaths "${CMAKE_SYSTEM_PREFIX_PATH};") set(3RD_PARTY_FIND_PROGRAM_HINTS # find_program HINTS for Doxygen # https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/FindDoxygen.cmake @@ -18,5 +19,6 @@ set(3RD_PARTY_FIND_PROGRAM_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin" /Applications/Graphviz.app/Contents/MacOS /Applications/Utilities/Graphviz.app/Contents/MacOS + ${syspaths} ) enable_cmake_warnings() diff --git a/build-support/custom-modules/ns3-find-external-library.cmake b/build-support/custom-modules/ns3-find-external-library.cmake index 1d7506310..ada86bde8 100644 --- a/build-support/custom-modules/ns3-find-external-library.cmake +++ b/build-support/custom-modules/ns3-find-external-library.cmake @@ -111,6 +111,9 @@ function(find_external_library) # directories $ENV{PATH} # Search for libraries in PATH directories ) + if(library_search_paths) + list(REMOVE_DUPLICATES library_search_paths) + endif() enable_cmake_warnings() # cmake-format: off # @@ -223,6 +226,9 @@ function(find_external_library) # ns-3-dev/build ${CMAKE_INSTALL_PREFIX} # Search for headers in the install ) + if(header_search_paths) + list(REMOVE_DUPLICATES header_search_paths) + endif() set(not_found_headers) set(include_dirs) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 259fa200a..64abbf608 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -221,6 +221,13 @@ macro(process_options) unset(CMAKE_VERBOSE_MAKEFILE CACHE) endif() + if(${NS3_FORCE_LOCAL_DEPENDENCIES}) + set(CMAKE_FIND_FRAMEWORK NEVER) + set(CMAKE_FIND_APPBUNDLE NEVER) + set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH FALSE) + set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE) + endif() + # Set warning level and warning as errors if(${NS3_WARNINGS}) if(DEFINED MSVC)