Skip to content

Commit

Permalink
build: Limit scope of MPI definition and include directory
Browse files Browse the repository at this point in the history
  • Loading branch information
a-andre authored and Gabrielcarvfer committed Dec 7, 2024
1 parent 3192d8f commit f67ff99
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions build-support/macros-and-definitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/source/working-with-cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/brite/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ if(${ENABLE_MPI})
${libnix-vector-routing}
${libapplications}
${libmpi}
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
)
endif()
2 changes: 1 addition & 1 deletion src/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
2 changes: 0 additions & 2 deletions src/mpi/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
link_libraries(${MPI_CXX_LIBRARIES})

set(base_examples
simple-distributed
simple-distributed-mpi-comm
Expand Down
2 changes: 1 addition & 1 deletion src/point-to-point/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(${ENABLE_MPI})
)
set(mpi_libraries
${libmpi}
${MPI_CXX_LIBRARIES}
MPI::MPI_CXX
)
endif()

Expand Down

0 comments on commit f67ff99

Please sign in to comment.