Creating examples in scratch folder with nested directory structures
I am creating a more complex example in the scratch
folder that contains a nested directory structure, i.e something like this:
scratch/
...
myexample/
...
sim.cc
foo.h
foo.cc
bar/
bar.h
bar.cc
From what I know there are three ways to create runnable examples in the scratch folder: create a single script file or create a subdirectory, either with all source files placed directly under that dir or with a CMakeLists.txt
file that deals with custom structure.
My example would fall under the second/third way, but I could not figure out how to do it with a CMakeLists.txt
(not yet a CMake expert). Instead, I have locally "hot-fixed" things by modifying scratch/CMakeLists.txt
to glob recursively for source files in each subdirectory instead of globbing recursively for subdirectories (moving the GLOB_RECURSE
from line 65 to line 88).
My questions:
- I don't know the rationale behind the first
GLOB_RECURSE
: is it intended behavior to search for executable source files recursively but then not search for nested source files within a subdir? If yes, my fix probably is not a good long-term solution and I should rather try to make it work with a cmake file. - It would help out to add a section to the FAQ/documentation or an example on how to write scripts with nested directory structures and a
CMakeLists.txt
file, as I imagine i'm not the only one who creates scripts that are too large to have all source files lying in a flat hierarchy.
My Setup: Ubuntu 20.04.5 LTS, using ns-3 version 3.37 (downloaded the archive from https://www.nsnam.org/release/ns-allinone-3.37.tar.bz2).