diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index 1801f85b4..fb9639cdb 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -567,5 +567,14 @@ function(write_module_header name header_files) list(APPEND contents " #endif " ) + if(EXISTS ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${name}-module.h) + file(READ ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${name}-module.h oldcontents) + string(REPLACE ";" "" contents "${contents}") + # If the header-module.h already exists and is the exact same, do not + # overwrite it to preserve timestamps + if("${contents}" STREQUAL "${oldcontents}") + return() + endif() + endif() file(WRITE ${CMAKE_HEADER_OUTPUT_DIRECTORY}/${name}-module.h ${contents}) endfunction() diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index d9b131b16..a53760fae 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -295,22 +295,6 @@ endfunction() macro(process_options) clear_global_cached_variables() - # check if the include directory exists in the output directory - if((EXISTS ${CMAKE_OUTPUT_DIRECTORY}) AND (EXISTS - ${CMAKE_OUTPUT_DIRECTORY}/include) - ) - # if it does, delete it to make sure we only have relevant header stubs - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0") - set(delete_directory_cmd rm -R) # introduced in CMake 3.17 - else() - set(delete_directory_cmd remove_directory) # deprecated in CMake 3.17 - endif() - execute_process( - COMMAND ${CMAKE_COMMAND} -E ${delete_directory_cmd} - ${CMAKE_OUTPUT_DIRECTORY}/include - ) - endif() - # make sure to default to RelWithDebInfo if no build type is specified if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "default" CACHE STRING "Choose the type of build." @@ -797,7 +781,8 @@ macro(process_options) endif() # Disable the below warning from bindings built in debug mode with clang++: - # "expression with side effects will be evaluated despite being used as an operand to 'typeid'" + # "expression with side effects will be evaluated despite being used as an + # operand to 'typeid'" if(${ENABLE_PYTHON_BINDINGS} AND ${CLANG}) add_compile_options(-Wno-potentially-evaluated-expression) endif() @@ -1392,6 +1377,12 @@ function(copy_headers_before_building_lib libname outputdir headers visibility) get_filename_component( header_name ${CMAKE_CURRENT_SOURCE_DIR}/${header} NAME ) + + # If header already exists, skip symlinking/stub header creation + if(EXISTS ${outputdir}/${header_name}) + continue() + endif() + # CMake 3.13 cannot create symlinks on Windows, so we use stub headers as a # fallback if(WIN32 AND (${CMAKE_VERSION} VERSION_LESS "3.13.0")) diff --git a/utils/tests/test-ns3.py b/utils/tests/test-ns3.py index 9d7e4c584..d333fba40 100644 --- a/utils/tests/test-ns3.py +++ b/utils/tests/test-ns3.py @@ -838,6 +838,9 @@ class NS3ConfigureTestCase(NS3BaseTestCase): Test passing 'show version' argument to ns3 to get the build version @return None """ + if shutil.which("git") is None: + self.skipTest("git is not available") + return_code, _, _ = run_ns3("configure -G \"Unix Makefiles\" --enable-build-version") self.assertEqual(return_code, 0) @@ -924,7 +927,7 @@ class NS3ConfigureTestCase(NS3BaseTestCase): """ # Skip test if mpi is not installed if shutil.which("mpiexec") is None: - return + self.skipTest("Mpi is not available") # Ensure sample simulator was built return_code, stdout, stderr = run_ns3("build sample-simulator")