diff --git a/build-support/custom-modules/ns3-executables.cmake b/build-support/custom-modules/ns3-executables.cmake index ab4f3ac0e..47d001f89 100644 --- a/build-support/custom-modules/ns3-executables.cmake +++ b/build-support/custom-modules/ns3-executables.cmake @@ -168,8 +168,20 @@ function(scan_python_examples path) return() endif() - # Search for python examples - file(GLOB_RECURSE python_examples ${path}/*.py) + # Search for example scripts in the directory and its immediate children + # directories + set(python_examples) + file(GLOB examples_subdirs LIST_DIRECTORIES TRUE ${path}/*) + foreach(subdir ${path} ${examples_subdirs}) + if(NOT (IS_DIRECTORY ${subdir})) + continue() + endif() + file(GLOB python_examples_subdir ${subdir}/*.py) + list(APPEND python_examples ${python_examples_subdir}) + endforeach() + + # Add example scripts to the list + list(REMOVE_DUPLICATES python_examples) foreach(python_example ${python_examples}) if(NOT (${python_example} MATCHES "examples-to-run")) set(ns3-execs-py "${python_example};${ns3-execs-py}" diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 12f052bfb..259fa200a 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -320,10 +320,17 @@ macro(process_options) if("${CMAKE_FORMAT_PROGRAM}" STREQUAL "CMAKE_FORMAT_PROGRAM-NOTFOUND") message(${HIGHLIGHTED_STATUS} "Proceeding without cmake-format") else() - file(GLOB_RECURSE MODULES_CMAKE_FILES src/**/CMakeLists.txt - contrib/**/CMakeLists.txt examples/**/CMakeLists.txt - scratch/**/CMakeLists.txt + file( + GLOB + MODULES_CMAKE_FILES + src/**/CMakeLists.txt + contrib/**/CMakeLists.txt + src/**/examples/CMakeLists.txt + contrib/**/examples/CMakeLists.txt + examples/**/CMakeLists.txt + scratch/**/CMakeLists.txt ) + file(GLOB_RECURSE SCRATCH_CMAKE_FILES scratch/**/CMakeLists.txt) file( GLOB INTERNAL_CMAKE_FILES @@ -342,7 +349,7 @@ macro(process_options) COMMAND ${CMAKE_FORMAT_PROGRAM} -c ${PROJECT_SOURCE_DIR}/build-support/cmake-format-modules.yaml -i - ${MODULES_CMAKE_FILES} + ${MODULES_CMAKE_FILES} ${SCRATCH_CMAKE_FILES} ) add_custom_target( cmake-format-check diff --git a/ns3 b/ns3 index 9a1b4c088..33ab77be0 100755 --- a/ns3 +++ b/ns3 @@ -657,7 +657,7 @@ def remove_file(file_to_remove, dry_run): def clean_cmake_artifacts(dry_run=False): remove_dir(out_dir, dry_run, "output") - cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) + cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path) for cmake_cache_file in cmake_cache_files: dirname = os.path.dirname(cmake_cache_file) remove_dir(dirname, dry_run, "CMake cache") @@ -707,7 +707,7 @@ def clean_vcpkg_artifacts(dry_run=False): def search_cmake_cache(build_profile): # Search for the CMake cache - cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) + cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path) current_cmake_cache_folder = None current_cmake_generator = None