Skip to content

Commit

Permalink
Add support for conditional dependencies (#32)
Browse files Browse the repository at this point in the history
* Add support for conditional dependencies
* Add documentation for the cmake_condition: option in dependencies.yaml
* Only use cmake_conditon if it is set
* Log a message if cmake_condition is used to exclude a dependency

---------

Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored Nov 8, 2023
1 parent a477ef2 commit efaee36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
23 changes: 6 additions & 17 deletions dependency_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,15 @@ libtimer:

```

If you want to automatically check out certain dependencies into a *workspace* you can add a **workspace.yaml** file to the root of your source repository. It should look like this:
If you want to conditionally include some dependencies, eg. for testing, you can do this in the following way:
```yaml
---
workspace: ~/workspace
local_dependencies:
liblog:
libtimer:

```

You can overwrite the git_tag in your **workspace.yaml**, so you can use a development version in your workspace:
```yaml
---
workspace: ~/workspace
local_dependencies:
liblog:
git_tag: devel
timer:
catch2:
git: https://github.com/catchorg/Catch2.git
git_tag: v3.4.0
cmake_condition: "BUILD_TESTING"

```
Here *cmake_condition* can be any string that CMake can use in an if() block. Please be aware that any variables you use here must be defined before a call to *evc_setup_edm()* is made in your CMakeLists.txt

## Create a workspace config from an existing directory tree
Suppose you already have a directory tree that you want to save into a config file.
Expand Down
2 changes: 1 addition & 1 deletion dependency_manager/src/edm_tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
"""Everest Dependency Manager."""
from edm_tool import edm
__version__ = "0.5.5"
__version__ = "0.5.6"


def get_parser():
Expand Down
8 changes: 8 additions & 0 deletions dependency_manager/src/edm_tool/templates/cpm.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ set(CPM_{{ dep["name"] }}_SOURCE "{{ dep["path"] }}")
{% for name, value in dependencies.items() %}
if("{{name}}" IN_LIST EVEREST_EXCLUDE_DEPENDENCIES)
message(STATUS "Excluding dependency {{name}}")
{% if "cmake_condition" in value and value["cmake_condition"]|length > 0 %}
elseif({{ value["cmake_condition"] }})
{% else %}
else()
{% endif %}
{% if value and "git" in value %}
CPMAddPackage(
NAME {{ name }}
Expand Down Expand Up @@ -39,6 +43,10 @@ if({{name}}_ADDED)
add_library({{value["alias"]["name"]}} ALIAS {{value["alias"]["target"]}})
endif()
{% endif %}
{% if "cmake_condition" in value and value["cmake_condition"]|length > 0 %}
else()
message(STATUS "Excluding dependency catch2 based on cmake_condition")
{% endif %}
endif()

{% endfor %}
Expand Down

0 comments on commit efaee36

Please sign in to comment.