diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cddc7050..ba9fbce3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,17 @@ # # LLNL-CODE-402774 +include(PnMPI_headers) + + +# Include common include directories. +# +# As almost all source code files need any kind of PnMPI header to be included, +# the common PnMPI header path will be included for all subdirectories instead +# of including the path independently in all paths. +include_directories(${PNMPI_HEADER_DIR}) + + add_subdirectory(modules) add_subdirectory(patch) add_subdirectory(pnmpi) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 32adb9ac..1e6d4139 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -35,7 +35,6 @@ if (NOT ENABLE_MODULES) endif () -include(PnMPI_headers) include(PnMPI_modules) include(GNUInstallDirs) @@ -74,7 +73,6 @@ set(PnMPI_MODULES_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/pnmpi-modules" # Include directories for all modules. include_directories( ${MPI_C_INCLUDE_PATH} - ${PNMPI_HEADER_DIR} ) diff --git a/src/modules/metrics/CMakeLists.txt b/src/modules/metrics/CMakeLists.txt index 89953046..6089a292 100644 --- a/src/modules/metrics/CMakeLists.txt +++ b/src/modules/metrics/CMakeLists.txt @@ -49,7 +49,7 @@ configure_file(config.h.in config.h) include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} # Required for generated source files. ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/src/pnmpi/CMakeLists.txt b/src/pnmpi/CMakeLists.txt index e7e68756..874a7869 100644 --- a/src/pnmpi/CMakeLists.txt +++ b/src/pnmpi/CMakeLists.txt @@ -30,7 +30,6 @@ include(CheckFortranMPIFunctionExists) include(CheckMPIFunctionExists) include(easylib) -include(PnMPI_headers) # Feature checks. @@ -54,6 +53,17 @@ if (C11_FOUND) endif () +# Include common include directories. +# +# Instead of including the same directories in the recursive directories, the +# common ones will be included before recursing for sharing. +include_directories( + ${PROJECT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${MPI_C_INCLUDE_PATH} +) + # Recurse into subdirectories. # # This has to be done BEFORE adding the PnMPI libraries, because for adding @@ -220,11 +230,3 @@ install( EXPORT pnmpi-libs DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/PnMPI ) - -# Extra directories to include from when building. -include_directories( - ${PROJECT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${PNMPI_HEADER_DIR} - ${MPI_C_INCLUDE_PATH}) diff --git a/src/pnmpi/debug/CMakeLists.txt b/src/pnmpi/debug/CMakeLists.txt index 5c6f611f..be0ac087 100644 --- a/src/pnmpi/debug/CMakeLists.txt +++ b/src/pnmpi/debug/CMakeLists.txt @@ -55,11 +55,6 @@ pnmpi_add_man(pnmpi_debug_io PNMPI_Warning) pnmpi_add_man(pnmpi_debug_io PNMPI_Error) -include_directories( - ${PNMPI_HEADER_DIR} - ${MPI_C_INCLUDE_PATH}) - - easy_add_library(pnmpi_debug OBJECT get_rank.c print_debug.c diff --git a/src/pnmpi/modules/CMakeLists.txt b/src/pnmpi/modules/CMakeLists.txt index 736dc0d0..fe4fedc9 100644 --- a/src/pnmpi/modules/CMakeLists.txt +++ b/src/pnmpi/modules/CMakeLists.txt @@ -47,13 +47,6 @@ pnmpi_add_man(pnmpi_module_hooks PNMPI_AppStartup) pnmpi_add_man(pnmpi_module_hooks PNMPI_AppShutdown) -include_directories( - ${PNMPI_HEADER_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${CMAKE_CURRENT_BINARY_DIR}/.. - ${PROJECT_BINARY_DIR} - ${MPI_C_INCLUDE_PATH}) - easy_add_library(pnmpi_modules OBJECT call_hook.c hook_activated.c diff --git a/src/pnmpi/service/CMakeLists.txt b/src/pnmpi/service/CMakeLists.txt index 197ef8cb..189bb869 100644 --- a/src/pnmpi/service/CMakeLists.txt +++ b/src/pnmpi/service/CMakeLists.txt @@ -62,14 +62,6 @@ pnmpi_add_man(PNMPI_Service_strerror "") pnmpi_add_man(PNMPI_status_t "") -include_directories( - ${PNMPI_HEADER_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${CMAKE_CURRENT_BINARY_DIR}/.. - ${PROJECT_BINARY_DIR} - ${MPI_C_INCLUDE_PATH}) - - easy_add_library(pnmpi_service OBJECT callHook.c changeStack.c diff --git a/src/pnmpi/wrapper/CMakeLists.txt b/src/pnmpi/wrapper/CMakeLists.txt index e24b2866..15f07e72 100644 --- a/src/pnmpi/wrapper/CMakeLists.txt +++ b/src/pnmpi/wrapper/CMakeLists.txt @@ -50,9 +50,6 @@ pnmpi_add_private_header(mpi_interface.h) pnmpi_add_private_header(mpi_reentry.h) pnmpi_add_private_header(return_address.h.in return_address.h) - -include_directories(${PNMPI_HEADER_DIR}) - easy_add_library(pnmpi_wrapper OBJECT mpi_interface.c mpi_reentry.c diff --git a/src/pnmpize/CMakeLists.txt b/src/pnmpize/CMakeLists.txt index 06cc07ef..0613cfa2 100644 --- a/src/pnmpize/CMakeLists.txt +++ b/src/pnmpize/CMakeLists.txt @@ -37,7 +37,6 @@ endif () include(GNUInstallDirs) -include(PnMPI_headers) find_package(argp REQUIRED) find_package(help2man) @@ -71,9 +70,7 @@ configure_file(config.h.in config.h) # Include all required directories. -include_directories( - ${PNMPI_HEADER_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Build and install PnMPIze.