Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions cmake_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ In order to compile a C++ library, use the following macros:
1. To compile tests for the library: `compile_test(${<test path>})`
1. To install the package following eprosima defaults `eprosima_packaging()`

---

## Module Requirements

In order create a package (called Module from now on) using this library,
Expand All @@ -49,8 +51,9 @@ The version will be loaded from this file if it is not set in `project_settings.

Every module requires to have a `LICENSE` file in order to install it with the result of the module.

---

#### Project using cmake_utils variables
## Project configuration using cmake_utils variables

These are the variables that could/must be set in the `project_settings.cmake` file.
Those variables which default is `x` must be set, and those with `-` are not required.
Expand Down Expand Up @@ -87,7 +90,21 @@ Those variables which default is `x` must be set, and those with `-` are not req
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_CPP_VERSION | C++17 | C++ version |

#### Project using cmake_utils CMake options
### Minimum Package Version

Setting the CMake variable `<library>_MINIMUM_VERSION` will force the `find_package` call to look for library
`<library>` with minimum version `${<library>_MINIMUM_VERSION}`.

e.g.

```cmake
set(MODULE_FIND_PACKAGES fastrtps)
set(fastrtps_MINIMUM_VERSION "2.8") # This will force to use a version of fastrtps higher or equal 2.8
```

---

## Project using cmake_utils CMake options set

There are default CMake options used within cmake_utils package that will always be set.
In case the user sets these variables, they will have that value. Otherwise,
Expand Down
21 changes: 19 additions & 2 deletions cmake_utils/cmake/cpp_common/find_external.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@
#
# ARGUMENTS:
# - EXTERNAL_PROJECT_NAMES: List of names of external projects to find
#
# If ${${EXTERNAL_PROJECT}_MINIMUM_VERSION} is set for any of the project names passed as argument, it will
# be used in order to look for a minimum version for this package.
#

macro(find_external_projects EXTERNAL_PROJECT_NAMES)

foreach(EXTERNAL_PROJECT ${EXTERNAL_PROJECT_NAMES})
find_package("${EXTERNAL_PROJECT}" REQUIRED)
message(STATUS "Package ${EXTERNAL_PROJECT} found")
# Check if this project requires a minimum version, set as ${EXTERNAL_PROJECT}_MINIMUM_VERSION
if (${${EXTERNAL_PROJECT}_MINIMUM_VERSION})

find_package("${EXTERNAL_PROJECT}" "${${EXTERNAL_PROJECT}_MINIMUM_VERSION}" REQUIRED)
message(
STATUS
"Package ${EXTERNAL_PROJECT} found higher than minimum version ${EXTERNAL_PROJECT}_MINIMUM_VERSION")

else()

find_package("${EXTERNAL_PROJECT}" REQUIRED)
message(STATUS "Package ${EXTERNAL_PROJECT} found")

endif()
endforeach()

# Finish macro
Expand Down