build: reduce scope of NS3_ENABLE_EXAMPLES flag

Prevents recompilation of modules when tests are enabled
This commit is contained in:
Gabriel Ferreira
2022-07-27 19:07:03 -03:00
parent 4e0747d759
commit ddf49b31ef
2 changed files with 13 additions and 6 deletions

View File

@@ -97,6 +97,19 @@ function(build_lib)
${CMAKE_HEADER_OUTPUT_DIRECTORY}/version-defines.h
)
endif()
# Enable examples as tests suites
if(${ENABLE_EXAMPLES} AND ${ENABLE_TESTS})
if(NOT ${XCODE})
target_compile_definitions(
${lib${BLIB_LIBNAME}}-obj PRIVATE NS3_ENABLE_EXAMPLES
)
else()
target_compile_definitions(
${lib${BLIB_LIBNAME}} PRIVATE NS3_ENABLE_EXAMPLES
)
endif()
endif()
endif()
set_target_properties(
${lib${BLIB_LIBNAME}}

View File

@@ -1156,12 +1156,6 @@ macro(process_options)
add_definitions(-DNS3_ASSERT_ENABLE)
endif()
# Enable examples as tests suites
if(${ENABLE_EXAMPLES})
set(NS3_ENABLE_EXAMPLES "1")
add_definitions(-DNS3_ENABLE_EXAMPLES -DCMAKE_EXAMPLE_AS_TEST)
endif()
set(ENABLE_TAP OFF)
if(${NS3_TAP})
set(ENABLE_TAP ON)