build: Fix CMake and ns3 script bugs, add a test suite and fix formatting

This commit is contained in:
Gabriel Ferreira
2021-12-05 21:53:49 +00:00
parent 1dc223f85a
commit a893eba7e3
123 changed files with 3492 additions and 1135 deletions

View File

@@ -1,6 +1,7 @@
file(GLOB_RECURSE scratches ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
set(DONT_BUILD)
set(target_prefix scratch_)
foreach(scratch_src ${scratches})
# Get source filename without path or extension
@@ -9,17 +10,27 @@ foreach(scratch_src ${scratches})
# Get source absolute path and transform into relative path
get_filename_component(scratch_absolute_directory ${scratch_src} DIRECTORY)
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" scratch_directory ${scratch_absolute_directory})
string(REPLACE "${PROJECT_SOURCE_DIR}" "${CMAKE_OUTPUT_DIRECTORY}"
scratch_directory ${scratch_absolute_directory}
)
# Build scratch if not listed as a DONT_BUILD
string(FIND "${DONT_BUILD}" "${scratch_name}" res)
if(res LESS 0)
add_executable(${scratch_name} "${scratch_src}")
add_executable(${target_prefix}${scratch_name} "${scratch_src}")
if(${NS3_STATIC})
target_link_libraries(${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC} ${lib-ns3-static})
target_link_libraries(
${target_prefix}${scratch_name} ${LIB_AS_NEEDED_PRE_STATIC}
${lib-ns3-static}
)
else()
target_link_libraries(${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}")
target_link_libraries(
${target_prefix}${scratch_name} "${ns3-libs}" "${ns3-contrib-libs}"
"${ns3-external-libs}"
)
endif()
set_runtime_outputdirectory(${scratch_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/scratch/${scratch_directory}/)
set_runtime_outputdirectory(
${scratch_name} ${scratch_directory}/ ${target_prefix}
)
endif()
endforeach()