Commit a27f518b authored by Marc Vef's avatar Marc Vef
Browse files

Merge branch 'amiranda/improve-cmake-dependency-management' into 'master'

Improve cmake

This MR improves the current CMake scripts in the following manner:

- Dependency management is now handled more consistently: system dependencies are found using `find_package()`, whereas source-only dependencies are found using `include_from_source()`. This new function integrates a dependency provided its source code is available. If it's not, it will try to download it from its git repository if it was defined.
- All external dependencies are now searched for in the top-level `CMakeLists.txt`.
- More consistent use of targets (we are closer to 100% modern CMake).
- Adds the `gkfs_feature_summary()` to allow printing a summary of all GekkoFS configuration options and their values.
- Moves all option definitions to `CMake/gfks-options.cmake`, so that the top-level `CMakeLists.txt` is cleaner. It also defines the `gkfs_define_option()` and `gkfs_define_variable()` functions to integrate the definition of options/variables with the automated reporting provided by `gkfs_feature_summary()`.

It also fixes #249.

Closes #211

Closes #211 and #249

See merge request !143
parents 6d4b20f2 eaed52ff
Loading
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -160,6 +160,8 @@ gkfwd:integration:
  parallel:
    matrix:
      - SUBTEST: [ forwarding ]
  rules:
    - when: never

  script:
    ## run tests
@@ -297,8 +299,9 @@ coverage:baseline:
coverage:
  stage: report
  image: gekkofs/testing:0.9.2
  needs: [ 'coverage:baseline', 'gkfs:integration', 'gkfwd:integration',
           'gkfs:unit' ]
#  needs: [ 'coverage:baseline', 'gkfs:integration', 'gkfwd:integration',
#           'gkfs:unit' ]
  needs: [ 'coverage:baseline', 'gkfs:integration', 'gkfs:unit' ]
  script:
    - cd ${CI_PROJECT_DIR}
    - cmake
+6 −3
Original line number Diff line number Diff line
[submodule "external/hermes"]
	path = external/hermes
	url = https://github.com/bsc-ssrg/hermes.git
[submodule "external/fmt"]
	path = external/fmt
	url = https://github.com/fmtlib/fmt
[submodule "tests/scripts/bats"]
	path = tests/scripts/bats
	url = https://github.com/bats-core/bats-core.git
@@ -19,3 +16,9 @@
[submodule "external/spdlog"]
	path = external/spdlog
	url = https://github.com/gabime/spdlog
[submodule "external/fmt"]
	path = external/fmt
	url = https://github.com/fmtlib/fmt.git
[submodule "external/CLI11"]
	path = external/CLI11
	url = https://github.com/CLIUtils/CLI11.git
+12 −0
Original line number Diff line number Diff line
@@ -21,6 +21,18 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- FLOCK and fcntl functions for locks, are not supported, but they are available.
- Added support for [CMake presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) to simplify build 
  configurations ([!163](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/163#note_8179)).
- Several improvements to CMake scripts ([!143](https://storage.bsc.es/gitlab/hpc/gekkofs/-/merge_requests/143))):
  - Dependency management is now handled more consistently: system
    dependencies are found using `find_package()`, whereas source-only
    dependencies are found using `include_from_source()`. This new function
    integrates a dependency provided its source code is available at
    `GKFS_DEPENDENCIES_PATH`. If it's not, it will try to
    automatically download it from its git repository using CMake's
    `FetchContent()`.
  - More consistent use of targets (we are closer to 100% modern CMake).
  - Adds the `gkfs_feature_summary()` to allow printing a summary of all
    GekkoFS configuration options and their values. This should help users
    when building to precisely see how a GekkoFS instance has been configured.

### Changed

+25 −10
Original line number Diff line number Diff line
@@ -26,21 +26,36 @@
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

find_path(AGIOS_INCLUDE_DIR
find_path(
  AGIOS_INCLUDE_DIR
  NAMES agios.h
  PATH_SUFFIXES include
)

find_library(AGIOS_LIBRARY
    NAMES agios
)
find_library(AGIOS_LIBRARY NAMES agios)

set(AGIOS_INCLUDE_DIRS ${AGIOS_INCLUDE_DIR})
set(AGIOS_LIBRARIES ${AGIOS_LIBRARY})

mark_as_advanced(AGIOS_LIBRARY AGIOS_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(AGIOS DEFAULT_MSG AGIOS_LIBRARIES AGIOS_INCLUDE_DIRS)
find_package_handle_standard_args(
  AGIOS
  FOUND_VAR AGIOS_FOUND
  REQUIRED_VARS AGIOS_LIBRARY AGIOS_INCLUDE_DIR
)

mark_as_advanced(
    AGIOS_LIBRARY
    AGIOS_INCLUDE_DIR
if(AGIOS_FOUND)
  set(AGIOS_INCLUDE_DIRS ${AGIOS_INCLUDE_DIR})
  set(AGIOS_LIBRARIES ${AGIOS_LIBRARY})
  if(NOT TARGET AGIOS::AGIOS)
    add_library(AGIOS::AGIOS UNKNOWN IMPORTED)
    set_target_properties(
      AGIOS::AGIOS
      PROPERTIES IMPORTED_LOCATION "${AGIOS_LIBRARY}"
      INTERFACE_INCLUDE_DIRECTORIES "${AGIOS_INCLUDE_DIR}"
    )
  endif()
endif( )
+24 −19
Original line number Diff line number Diff line

################################################################################
# Copyright 2018-2022, Barcelona Supercomputing Center (BSC), Spain            #
# Copyright 2015-2022, Johannes Gutenberg Universitaet Mainz, Germany          #
@@ -25,29 +26,33 @@
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################
find_path(
  AIO_INCLUDE_DIR
  NAMES aio.h
  PATH_SUFFIXES include
)

# - Find Lz4
# Find the lz4 compression library and includes
#
# LZ4_FOUND - True if lz4 found.
# LZ4_LIBRARIES - List of libraries when using lz4.
# LZ4_INCLUDE_DIR - where to find lz4.h, etc.
find_library(AIO_LIBRARY NAMES rt)

find_path(LZ4_INCLUDE_DIR
    NAMES lz4.h
)
mark_as_advanced(AIO_INCLUDE_DIR AIO_LIBRARY)

find_library(LZ4_LIBRARY
    NAMES lz4
find_package_handle_standard_args(
  AIO
  FOUND_VAR AIO_FOUND
  REQUIRED_VARS AIO_INCLUDE_DIR AIO_LIBRARY
)

set(LZ4_LIBRARIES ${LZ4_LIBRARY} )
set(LZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
if(AIO_FOUND AND NOT TARGET AIO::AIO)
  add_library(AIO::AIO UNKNOWN IMPORTED)
  if(AIO_INCLUDE_DIR)
    set_target_properties(
      AIO::AIO PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${AIO_INCLUDE_DIR}"
    )
  endif()

mark_as_advanced(
    LZ4_LIBRARY
    LZ4_INCLUDE_DIR
  set_target_properties(
    AIO::AIO PROPERTIES IMPORTED_LOCATION "${AIO_LIBRARY}"
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
  )
endif()
Loading