Skip to content

Commit

Permalink
Optimize CMake include_directories
Browse files Browse the repository at this point in the history
Instead of including the same directories over and over again, common
directories will be included just once in the parent directories now.
  • Loading branch information
alehaa committed Jun 4, 2018
1 parent 4159ced commit 6128cc6
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 39 deletions.
11 changes: 11 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions src/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ if (NOT ENABLE_MODULES)
endif ()


include(PnMPI_headers)
include(PnMPI_modules)
include(GNUInstallDirs)

Expand Down Expand Up @@ -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}
)


Expand Down
2 changes: 1 addition & 1 deletion src/modules/metrics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)

Expand Down
20 changes: 11 additions & 9 deletions src/pnmpi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
include(CheckFortranMPIFunctionExists)
include(CheckMPIFunctionExists)
include(easylib)
include(PnMPI_headers)


# Feature checks.
Expand All @@ -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
Expand Down Expand Up @@ -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})
5 changes: 0 additions & 5 deletions src/pnmpi/debug/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/pnmpi/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions src/pnmpi/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/pnmpi/wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions src/pnmpize/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ endif ()


include(GNUInstallDirs)
include(PnMPI_headers)

find_package(argp REQUIRED)
find_package(help2man)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 6128cc6

Please sign in to comment.