build: Limit scope of MPI definition and include directory

This commit is contained in:
André Apitzsch
2024-11-21 17:43:50 +01:00
committed by Gabriel Ferreira
parent 3192d8f936
commit f67ff99635
6 changed files with 5 additions and 8 deletions

View File

@@ -840,8 +840,7 @@ macro(process_options)
message(FATAL_ERROR "MPI was not found.")
else()
message(STATUS "MPI was found.")
add_definitions(-DNS3_MPI)
include_directories(${MPI_CXX_INCLUDE_DIRS})
target_compile_definitions(MPI::MPI_CXX INTERFACE NS3_MPI)
set(ENABLE_MPI TRUE)
endif()
endif()

View File

@@ -2855,7 +2855,7 @@ followed by a header configuration:
else()
# If it is false, we add necessary C++ definitions (e.g. NS3_MPI)
message(STATUS "MPI was found.")
add_definitions(-DNS3_MPI)
target_compile_definitions(MPI::MPI_CXX INTERFACE NS3_MPI)
# Then set ENABLE_MPI to TRUE, which can be used to check
# if NS3_MPI is enabled AND MPI was found

View File

@@ -20,6 +20,6 @@ if(${ENABLE_MPI})
${libnix-vector-routing}
${libapplications}
${libmpi}
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
)
endif()

View File

@@ -22,6 +22,6 @@ build_lib(
model/mpi-receiver.h
model/parallel-communication-interface.h
LIBRARIES_TO_LINK ${libnetwork}
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
TEST_SOURCES ${example_as_test_suite}
)

View File

@@ -1,5 +1,3 @@
link_libraries(${MPI_CXX_LIBRARIES})
set(base_examples
simple-distributed
simple-distributed-mpi-comm

View File

@@ -11,7 +11,7 @@ if(${ENABLE_MPI})
)
set(mpi_libraries
${libmpi}
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
)
endif()