Skip to content

Commit

Permalink
New option to add extra includes path (#75)
Browse files Browse the repository at this point in the history
* Add options to set additional include directories

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Fit readme table into the page

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Add new options to load project settings file

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

---------

Signed-off-by: Raul Sanchez-Mateos <[email protected]>
  • Loading branch information
rsanchez15 authored Jul 12, 2023
1 parent 0667019 commit e3d805d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
58 changes: 30 additions & 28 deletions cmake_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,41 @@ Every module requires to have a `LICENSE` file in order to install it with the r
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.

| Variable | Default | Description |
| Variable | Default | Description |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_NAME | x | Name of the module (must be project name) |
| MODULE_TARGET_NAME | ${MODULE_NAME} | Output name of the target |
| MODULE_NAME_LARGE | ${MODULE_NAME} | Large name |
| MODULE_SUMMARY | ${MODULE_NAME_LARGE} | Summary (short description) |
| MODULE_DESCRIPTION | ${MODULE_SUMMARY} | Description |
| MODULE_MACRO | TOUPPER ${MODULE_NAME} | Macro to use in CMake and C++ definitions (it is recommended to leave it as Uppercase of name) |
| MODULE_HEADERS_PATH | ${MODULE_NAME} | Path (relative to include) where headers to be installed are located |
| MODULE_HEADERS_INSTALL_PATH | ${MODULE_HEADERS_PATH} | Path (relative to install dir) where headers are installed |
| MODULE_NAME | x | Name of the module (must be project name) |
| MODULE_TARGET_NAME | ${MODULE_NAME} | Output name of the target |
| MODULE_NAME_LARGE | ${MODULE_NAME} | Large name |
| MODULE_SUMMARY | ${MODULE_NAME_LARGE} | Summary (short description) |
| MODULE_DESCRIPTION | ${MODULE_SUMMARY} | Description |
| MODULE_MACRO | TOUPPER ${MODULE_NAME} | Macro to use in CMake and C++ definitions (it is recommended to leave it as Uppercase of name) |
| MODULE_HEADERS_PATH | ${MODULE_NAME} | Path (relative to include) where headers to be installed are located |
| MODULE_HEADERS_INSTALL_PATH | ${MODULE_HEADERS_PATH} | Path (relative to install dir) where headers are installed |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_FIND_PACKAGES | - | Modules that require to be found by find_package |
| MODULE_THIRDPARTY_HEADERONLY | - | Headeronly thirdparties that require to be included (must be inside ${MODULE_THIRDPARTY_PATH} dir) |
| MODULE_THIRDPARTY_PATH | ../thirdparty | Thirdparties parent dir path |
| MODULE_DEPENDENCIES | ${MODULE_FIND_PACKAGES} | Libraries that require to be linked by the target |
| MODULE_FIND_PACKAGES | - | Modules that require to be found by find_package |
| MODULE_THIRDPARTY_HEADERONLY | - | Headeronly thirdparties that require to be included (must be inside ${MODULE_THIRDPARTY_PATH} dir) |
| MODULE_THIRDPARTY_PATH | ../thirdparty | Thirdparties parent dir path |
| MODULE_DEPENDENCIES | ${MODULE_FIND_PACKAGES} | Libraries that require to be linked by the target |
| MODULE_PUBLIC_EXTRA_HEADERS | - | Specifies public scope include directories to use when compiling a given target. |
| MODULE_PRIVATE_EXTRA_HEADERS | - | Specifies private scope include directories to use when compiling a given target. |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_VERSION_FILE_PATH | ../VERSION | Path to the file containing version information |
| MODULE_VERSION_MAJOR | x (if not set, are taken from VERSION file) | Major version |
| MODULE_VERSION_MINOR | x (if not set, are taken from VERSION file) | Minor version |
| MODULE_VERSION_PATCH | x (if not set, are taken from VERSION file) | Patch version |
| MODULE_VERSION | ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}.${MODULE_VERSION_PATCH} | Module version |
| MODULE_VERSION_STRING | v${MODULE_VERSION} | Module version |
| MODULE_VERSION_FILE_PATH | ../VERSION | Path to the file containing version information |
| MODULE_VERSION_MAJOR | x (if not set, are taken from VERSION file) | Major version |
| MODULE_VERSION_MINOR | x (if not set, are taken from VERSION file) | Minor version |
| MODULE_VERSION_PATCH | x (if not set, are taken from VERSION file) | Patch version |
| MODULE_VERSION | ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}.${MODULE_VERSION_PATCH} | Module version |
| MODULE_VERSION_STRING | v${MODULE_VERSION} | Module version |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_LICENSE_FILE_PATH | ../LICENSE | Path to the license file |
| MODULE_RESOURCES_PATH | (if not given, no resources will be installed) | Path of the resources to install |
| MODULE_LICENSE_FILE_PATH | ../LICENSE | Path to the license file |
| MODULE_RESOURCES_PATH | (if not given, no resources will be installed) | Path of the resources to install |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_BIN_INSTALL_DIR | bin/ | Binary installation path |
| MODULE_INCLUDE_INSTALL_DIR | include/ | Include installation path |
| MODULE_LIB_INSTALL_DIR | lib/ | Library installation path |
| MODULE_DATA_INSTALL_DIR | share/ | Data installation path |
| MODULE_LICENSE_INSTALL_DIR | share/ | License installation path |
| MODULE_BIN_INSTALL_DIR | bin/ | Binary installation path |
| MODULE_INCLUDE_INSTALL_DIR | include/ | Include installation path |
| MODULE_LIB_INSTALL_DIR | lib/ | Library installation path |
| MODULE_DATA_INSTALL_DIR | share/ | Data installation path |
| MODULE_LICENSE_INSTALL_DIR | share/ | License installation path |
|------------------------------|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------|
| MODULE_CPP_VERSION | '' | C++ version |
| MODULE_CPP_VERSION | '' | C++ version |

### Minimum Package Version

Expand All @@ -101,7 +103,7 @@ 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
set(fastrtps_MINIMUM_VERSION "2.8") # This will force to use a version of fastrtps higher or equal 2.8
```

---
Expand Down
3 changes: 3 additions & 0 deletions cmake_utils/cmake/compilation/compile_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ function(compile_library _SOURCE_PATH _INCLUDE_PATH)
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/${MODULE_NAME}>
$<BUILD_INTERFACE:${_SOURCE_PATH}>
$<INSTALL_INTERFACE:include>
${MODULE_PUBLIC_EXTRA_HEADERS}
PRIVATE
${MODULE_PRIVATE_EXTRA_HEADERS}
)

target_link_libraries(${MODULE_NAME}
Expand Down
10 changes: 10 additions & 0 deletions cmake_utils/cmake/project/load_project_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ macro(load_project_settings)
set (MODULE_HEADERS_INSTALL_PATH ${MODULE_HEADERS_PATH})
endif()

# Set MODULE_PUBLIC_EXTRA_HEADERS
if (NOT MODULE_PUBLIC_EXTRA_HEADERS)
set (MODULE_PUBLIC_EXTRA_HEADERS "")
endif()

# Set MODULE_PRIVATE_EXTRA_HEADERS
if (NOT MODULE_PRIVATE_EXTRA_HEADERS)
set (MODULE_PRIVATE_EXTRA_HEADERS "")
endif()

#####
# Module external options

Expand Down

0 comments on commit e3d805d

Please sign in to comment.