-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CMake's FetchContent module to (optionally) download and build FMILibrary #23
Changes from 2 commits
a11efdf
166be2a
6393d1c
9a6adaf
714bf45
d7dbcb6
b1df7b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright (C) 2018 Fondazione Istituto Italiano di Tecnologia | ||
# | ||
# Licensed under either the GNU Lesser General Public License v3.0 : | ||
# | ||
# Licensed under either the GNU Lesser General Public License v3.0 : | ||
# https://www.gnu.org/licenses/lgpl-3.0.html | ||
# or the GNU Lesser General Public License v2.1 : | ||
# https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html | ||
|
@@ -24,6 +24,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}" | |
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}") | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
if (CMAKE_VERSION VERSION_LESS 3.11) | ||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-3.11) | ||
endif() | ||
|
||
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON) | ||
|
||
|
@@ -33,6 +36,7 @@ if(BUILD_TESTING) | |
enable_testing() | ||
endif() | ||
|
||
|
||
# Encourage user to specify a build type (e.g. Release, Debug, etc.), otherwise set it to Release. | ||
if(NOT CMAKE_CONFIGURATION_TYPES) | ||
if(NOT CMAKE_BUILD_TYPE) | ||
|
@@ -49,13 +53,17 @@ if (gazebo_VERSION_MAJOR LESS 7.0) | |
endif() | ||
|
||
find_package(FMILibrary REQUIRED) | ||
if (NOT FMILibary_FOUND}) | ||
message("Could not find FMILIbrary package. Downloading it using FetchContent...") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove this message. |
||
include(FetchFMILibrary) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3 spaces, instead of 4 |
||
endif() | ||
|
||
# Add extern libraries vendored (only used for the tests) | ||
if(BUILD_TESTING) | ||
add_subdirectory(extern) | ||
endif() | ||
|
||
# Add plugins | ||
# Add plugins | ||
add_subdirectory(plugins) | ||
|
||
include(InstallBasicPackageFiles) | ||
|
@@ -69,5 +77,3 @@ install_basic_package_files(${PROJECT_NAME} | |
|
||
# Add the uninstall target | ||
include(AddUninstallTarget) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
|
||
# About versioning | ||
The project is undergoing _heavy_ development: APIs may still be subject to changes, and some functionalities may be broken. | ||
The project is undergoing _heavy_ development: APIs may still be subject to changes, and some functionalities may be broken. | ||
|
||
|
||
# Background | ||
|
@@ -28,10 +28,12 @@ gazebo-fmi depends on | |
- [Gazebo](http://gazebosim.org/) - `version >= 7` | ||
- [FMILibrary](https://jmodelica.org/) (see https://github.com/svn2github/FMILibrary for an updated GitHub mirror) - `version >= 2.0.3` | ||
|
||
We recommend to install Gazebo as described in [official documentation](http://gazebosim.org/tutorials?cat=install), | ||
while for FMILibrary the easiest option is to compile it as any CMake project and then add its installation prefix to [`CMAKE_PREFIX_PATH`](https://cmake.org/cmake/help/v3.10/variable/CMAKE_PREFIX_PATH.html). | ||
We recommend to install Gazebo as described in [official documentation](http://gazebosim.org/tutorials?cat=install). | ||
For FMILibrary, one option is to compile it as any CMake project and then add its installation prefix to [`CMAKE_PREFIX_PATH`](https://cmake.org/cmake/help/v3.10/variable/CMAKE_PREFIX_PATH.html). | ||
See [CGold guide](https://cgold.readthedocs.io/en/latest/first-step.html) if you need some details on how to build a CMake project. | ||
|
||
An easier option is provided by the gazebo-fmi repository which downloads and compiles the FMILibrary internally within its build folder using CMake's FetchContent option. This is performed when FMILibrary package is not already existing in the system or if the FMILibrary related environment variable (`FMI_ROOT`) is not set, making gazebo-fmi unable to find FMILibrary package. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the docs considering the name variable change. |
||
# Build the plugins | ||
Use the following commands to build and install the plugin. | ||
|
||
|
@@ -63,10 +65,10 @@ See plugin-specific documentation on how to use each plugin: | |
* [gazebo-fmi-actuator documentation](plugins/actuator/README.md) | ||
|
||
|
||
# Test the plugins | ||
For running the automatic tests of the plugins contained in this repo, you need the additional dependency of the [OpenModelica](https://openmodelica.org/) compiler. The OpenModelica compiler is used to generate test FMUs from [Modelica](https://www.modelica.org/) models. | ||
# Test the plugins | ||
For running the automatic tests of the plugins contained in this repo, you need the additional dependency of the [OpenModelica](https://openmodelica.org/) compiler. The OpenModelica compiler is used to generate test FMUs from [Modelica](https://www.modelica.org/) models. | ||
|
||
Once you installed OpenModelica on your system, you can regenerated the project with the `BUILD_TESTING` CMake option set to `ON` to compile the tests. Once test are compiled, you can run them using [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html), for example run: | ||
Once you installed OpenModelica on your system, you can regenerated the project with the `BUILD_TESTING` CMake option set to `ON` to compile the tests. Once test are compiled, you can run them using [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html), for example run: | ||
```cmake | ||
$ ctest [-VV] | ||
``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (C) 2018 Fondazione Istituto Italiano di Tecnologia | ||
# | ||
# Licensed under either the GNU Lesser General Public License v3.0 : | ||
# https://www.gnu.org/licenses/lgpl-3.0.html | ||
# or the GNU Lesser General Public License v2.1 : | ||
# https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html | ||
# at your option. | ||
|
||
# Fetch FMI library for downloading and installing | ||
include(FetchContent) | ||
FetchContent_Declare(FMILibrary | ||
GIT_REPOSITORY https://github.com/svn2github/FMILibrary.git) | ||
|
||
FetchContent_GetProperties(FMILibrary) | ||
if(NOT FMILibrary_POPULATED) | ||
FetchContent_Populate(FMILibrary) | ||
set(BUILD_SHARED_LIBS OFF) | ||
option (FMILIB_BUILD_TESTS "Build tests" OFF) | ||
add_subdirectory(${fmilibrary_SOURCE_DIR} ${fmilibrary_BINARY_DIR}) | ||
set(BUILD_SHARED_LIBS ON) | ||
endif() | ||
|
||
add_library(FMILibrary_FMILibrary INTERFACE) | ||
target_include_directories(FMILibrary_FMILibrary INTERFACE ${fmilibrary_SOURCE_DIR}/src/CAPI/include | ||
${fmilibrary_SOURCE_DIR}/src/Import/include | ||
${fmilibrary_SOURCE_DIR}/src/Util/include | ||
${fmilibrary_SOURCE_DIR}/src/XML/include | ||
${fmilibrary_SOURCE_DIR}/src/ZIP/include | ||
${fmilibrary_SOURCE_DIR}/ThirdParty/FMI/default | ||
${fmilibrary_SOURCE_DIR}/Config.cmake | ||
${fmilibrary_BINARY_DIR}) | ||
target_link_libraries(FMILibrary_FMILibrary INTERFACE fmilib) | ||
add_library(FMILibrary::FMILibrary ALIAS FMILibrary_FMILibrary) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, it should be
NOT FMILibrary_FOUND