Skip to content

Bring spdlog into OpenSim. #2591

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

Merged
merged 2 commits into from
Oct 15, 2019
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
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ if(${OPENSIM_INSTALL_UNIX_FHS})
set(OPENSIM_INSTALL_JAVASRCDIR "${CMAKE_INSTALL_DATAROOTDIR}/OpenSim/java")
set(OPENSIM_INSTALL_APIEXDIR "${CMAKE_INSTALL_DOCDIR}/Code")
set(OPENSIM_INSTALL_SIMBODYDIR ".")
set(OPENSIM_INSTALL_SPDLOGDIR ".")

else()

Expand All @@ -189,6 +190,7 @@ else()
set(OPENSIM_INSTALL_JAVASRCDIR sdk/Java)
set(OPENSIM_INSTALL_APIEXDIR Resources/Code)
set(OPENSIM_INSTALL_SIMBODYDIR sdk/Simbody)
set(OPENSIM_INSTALL_SPDLOGDIR sdk/spdlog)

endif()

Expand Down Expand Up @@ -584,6 +586,10 @@ if(WITH_BTK)
endif()
endif()

find_package(spdlog REQUIRED
HINTS "${OPENSIM_DEPENDENCIES_DIR}/spdlog")


if(NOT SIMBODY_HOME AND OPENSIM_DEPENDENCIES_DIR)
set(SIMBODY_HOME "${OPENSIM_DEPENDENCIES_DIR}/simbody")
endif()
Expand Down Expand Up @@ -749,6 +755,10 @@ if(${OPENSIM_COPY_DEPENDENCIES})
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()

# spdlog
# ------
install(DIRECTORY "${spdlog_DIR}/../../../"
DESTINATION "${OPENSIM_INSTALL_SPDLOGDIR}")
endif()

if(BUILD_PYTHON_WRAPPING AND OPENSIM_PYTHON_STANDALONE)
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ OpenSimAddLibrary(
KIT Common
AUTHORS "Clay_Anderson-Ayman_Habib-Peter_Loan"
# Clients of osimCommon need not link to BTK.
LINKLIBS PUBLIC ${Simbody_LIBRARIES} PRIVATE ${BTK_LIBRARIES}
LINKLIBS PUBLIC ${Simbody_LIBRARIES} spdlog::spdlog PRIVATE ${BTK_LIBRARIES}
INCLUDES ${INCLUDES}
SOURCES ${SOURCES}
TESTDIRS "Test"
Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ state = manager.integrate(10.0);
```

</details>
---

Building from the source code
-----------------------------
Expand Down Expand Up @@ -492,6 +491,9 @@ On Windows using Visual Studio
* **command-line argument parsing**: docopt.cpp. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/gabime/spdlog).
* **API documentation** (optional):
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
* **version control** (optional): git. There are many options:
Expand Down Expand Up @@ -605,10 +607,14 @@ On Windows using Visual Studio
`BTKConfig.cmake`. If the root directory of your BTK installation is
`C:/BTKCore-install`, then set this variable to
`C:/BTKCore-install/share/btk-0.4dev`.
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
containing `docopt-config.cmake`. If the root directory of your
docopt.cpp installation is `C:/docopt.cpp-install`, then set this
variable to `C:/docopt.cpp-install/lib/cmake`.
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
`spdlogConfig.cmake`. If the root directory of your spdlog
installation is `C:/spdlog-install`, then set this variable to
`C:/spdlog-install/lib/spdlog/cmake`.
7. Set the remaining configuration options.
* `BUILD_API_EXAMPLES` to compile C++ API examples.
* `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
Expand Down Expand Up @@ -767,6 +773,9 @@ ctest -j8
* **command-line argument parsing**: docopt.cpp. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/gabime/spdlog).
* **API documentation** (optional):
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
* **version control** (optional): git.
Expand Down Expand Up @@ -866,10 +875,14 @@ You can get most of these dependencies using [Homebrew](http://brew.sh):
2. BTK: Set the `BTK_DIR` variable to the directory containing
`BTKConfig.cmake`. If you installed BTK in `~/BTKCore-install`, then
set `BTK_DIR` to `~/BTKCore-install/share/btk-0.4dev`
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
containing `docopt-config.cmake`. If the root directory of your
docopt.cpp installation is `~/docopt.cpp-install`, then set this
variable to `~/docopt.cpp-install/lib/cmake`.
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
`spdlogConfig.cmake`. If the root directory of your spdlog
installation is `~/spdlog-install`, then set this variable to
`~/spdlog-install/lib/spdlog/cmake`.
7. Set the remaining configuration options.
* `BUILD_API_EXAMPLES` to compile C++ API examples.
* `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
Expand Down Expand Up @@ -953,6 +966,9 @@ specific Ubuntu versions under 'For the impatient' below.
* **command-line argument parsing**: docopt.cpp. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
* **logging**: spdlog. Two options:
* Let OpenSim get this for you using superbuild (see below); much easier!
* [Build on your own](https://github.com/gabime/spdlog).
* **API documentation** (optional):
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6;
`doxygen`.
Expand Down Expand Up @@ -1057,10 +1073,14 @@ And you could get all the optional dependencies via:
2. BTK: Set the `BTK_DIR` variable to the directory containing
`BTKConfig.cmake`. If you installed BTK in `~/BTK-install`, then set
`BTK-DIR` to `~/BTK-install/share/btk-0.4dev`.
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
containing `docopt-config.cmake`. If the root directory of your
docopt.cpp installation is `~/docopt.cpp-install`, then set this
variable to `~/docopt.cpp-install/lib/cmake`.
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
`spdlogConfig.cmake`. If the root directory of your spdlog
installation is `~/spdlog-install`, then set this variable to
`~/spdlog-install/lib/spdlog/cmake`.
7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:
* **Debug**: debugger symbols; no optimizations (more than 10x slower).
Library names end with `_d`.
Expand Down
1 change: 1 addition & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ configure_package_config_file(
CMAKE_INSTALL_LIBDIR
OPENSIM_INSTALL_CMAKEDIR
OPENSIM_INSTALL_SIMBODYDIR
OPENSIM_INSTALL_SPDLOGDIR
)

# Version file.
Expand Down
13 changes: 11 additions & 2 deletions cmake/OpenSimConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,22 @@ set(@CMAKE_PROJECT_NAME@_JAR_FILE
# Dependencies
# ------------
if (@OPENSIM_COPY_DEPENDENCIES@) # OPENSIM_COPY_DEPENDENCIES
# Find the copy of Simbody within the OpenSim installation.
# Find the copies of Simbody and spdlog within the OpenSim installation.
# We define _SIMBODY_PATH and _SPDLOG_PATH before find_package(Simbody)
# because finding Simbody redefines the PACKAGE_PREFIX_DIR variable
# that appears in this file after configuring, thereby incorrectly
# causing CMake to look for spdlog within Simbody's installation.
set(_SIMBODY_PATH "@PACKAGE_OPENSIM_INSTALL_SIMBODYDIR@")
set(_SPDLOG_PATH "@PACKAGE_OPENSIM_INSTALL_SPDLOGDIR@")
find_package(Simbody @SIMBODY_VERSION_TO_USE@ REQUIRED
PATHS "@PACKAGE_OPENSIM_INSTALL_SIMBODYDIR@" NO_MODULE NO_DEFAULT_PATH)
PATHS "${_SIMBODY_PATH}" NO_MODULE NO_DEFAULT_PATH)
find_package(spdlog REQUIRED
PATHS "${_SPDLOG_PATH}" NO_MODULE NO_DEFAULT_PATH)
else()
# Find the correct version anywhere on the machine.
include(CMakeFindDependencyMacro)
find_dependency(Simbody @SIMBODY_VERSION_TO_USE@)
find_dependency(spdlog)
endif()


11 changes: 10 additions & 1 deletion dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,16 @@ AddDependency(NAME simbody
AddDependency(NAME docopt
URL https://github.com/docopt/docopt.cpp.git
TAG af03fa044ee1eff20819549b534ea86829a24a54)



AddDependency(NAME spdlog
URL https://github.com/gabime/spdlog.git
TAG v1.4.1
CMAKE_ARGS -DSPDLOG_BUILD_BENCH:BOOL=OFF
-DSPDLOG_BUILD_TESTS:BOOL=OFF
-DSPDLOG_BUILD_EXAMPLE:BOOL=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON)

#######################

RemoveDefaultInstallDirIfEmpty("${DEFAULT_CMAKE_INSTALL_PREFIX}")