Skip to content

Commit 3242769

Browse files
authored
Merge pull request #2591 from opensim-org/spdlog_cmake
Bring spdlog into OpenSim.
2 parents 688f988 + 548b428 commit 3242769

File tree

6 files changed

+57
-8
lines changed

6 files changed

+57
-8
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ if(${OPENSIM_INSTALL_UNIX_FHS})
169169
set(OPENSIM_INSTALL_JAVASRCDIR "${CMAKE_INSTALL_DATAROOTDIR}/OpenSim/java")
170170
set(OPENSIM_INSTALL_APIEXDIR "${CMAKE_INSTALL_DOCDIR}/Code")
171171
set(OPENSIM_INSTALL_SIMBODYDIR ".")
172+
set(OPENSIM_INSTALL_SPDLOGDIR ".")
172173

173174
else()
174175

@@ -189,6 +190,7 @@ else()
189190
set(OPENSIM_INSTALL_JAVASRCDIR sdk/Java)
190191
set(OPENSIM_INSTALL_APIEXDIR Resources/Code)
191192
set(OPENSIM_INSTALL_SIMBODYDIR sdk/Simbody)
193+
set(OPENSIM_INSTALL_SPDLOGDIR sdk/spdlog)
192194

193195
endif()
194196

@@ -584,6 +586,10 @@ if(WITH_BTK)
584586
endif()
585587
endif()
586588

589+
find_package(spdlog REQUIRED
590+
HINTS "${OPENSIM_DEPENDENCIES_DIR}/spdlog")
591+
592+
587593
if(NOT SIMBODY_HOME AND OPENSIM_DEPENDENCIES_DIR)
588594
set(SIMBODY_HOME "${OPENSIM_DEPENDENCIES_DIR}/simbody")
589595
endif()
@@ -749,6 +755,10 @@ if(${OPENSIM_COPY_DEPENDENCIES})
749755
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
750756
endif()
751757

758+
# spdlog
759+
# ------
760+
install(DIRECTORY "${spdlog_DIR}/../../../"
761+
DESTINATION "${OPENSIM_INSTALL_SPDLOGDIR}")
752762
endif()
753763

754764
if(BUILD_PYTHON_WRAPPING AND OPENSIM_PYTHON_STANDALONE)

OpenSim/Common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ OpenSimAddLibrary(
1414
KIT Common
1515
AUTHORS "Clay_Anderson-Ayman_Habib-Peter_Loan"
1616
# Clients of osimCommon need not link to BTK.
17-
LINKLIBS PUBLIC ${Simbody_LIBRARIES} PRIVATE ${BTK_LIBRARIES}
17+
LINKLIBS PUBLIC ${Simbody_LIBRARIES} spdlog::spdlog PRIVATE ${BTK_LIBRARIES}
1818
INCLUDES ${INCLUDES}
1919
SOURCES ${SOURCES}
2020
TESTDIRS "Test"

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ state = manager.integrate(10.0);
436436
```
437437

438438
</details>
439-
---
440439

441440
Building from the source code
442441
-----------------------------
@@ -492,6 +491,9 @@ On Windows using Visual Studio
492491
* **command-line argument parsing**: docopt.cpp. Two options:
493492
* Let OpenSim get this for you using superbuild (see below); much easier!
494493
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
494+
* **logging**: spdlog. Two options:
495+
* Let OpenSim get this for you using superbuild (see below); much easier!
496+
* [Build on your own](https://github.com/gabime/spdlog).
495497
* **API documentation** (optional):
496498
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
497499
* **version control** (optional): git. There are many options:
@@ -605,10 +607,14 @@ On Windows using Visual Studio
605607
`BTKConfig.cmake`. If the root directory of your BTK installation is
606608
`C:/BTKCore-install`, then set this variable to
607609
`C:/BTKCore-install/share/btk-0.4dev`.
608-
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
610+
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
609611
containing `docopt-config.cmake`. If the root directory of your
610612
docopt.cpp installation is `C:/docopt.cpp-install`, then set this
611613
variable to `C:/docopt.cpp-install/lib/cmake`.
614+
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
615+
`spdlogConfig.cmake`. If the root directory of your spdlog
616+
installation is `C:/spdlog-install`, then set this variable to
617+
`C:/spdlog-install/lib/spdlog/cmake`.
612618
7. Set the remaining configuration options.
613619
* `BUILD_API_EXAMPLES` to compile C++ API examples.
614620
* `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
@@ -767,6 +773,9 @@ ctest -j8
767773
* **command-line argument parsing**: docopt.cpp. Two options:
768774
* Let OpenSim get this for you using superbuild (see below); much easier!
769775
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
776+
* **logging**: spdlog. Two options:
777+
* Let OpenSim get this for you using superbuild (see below); much easier!
778+
* [Build on your own](https://github.com/gabime/spdlog).
770779
* **API documentation** (optional):
771780
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6
772781
* **version control** (optional): git.
@@ -866,10 +875,14 @@ You can get most of these dependencies using [Homebrew](http://brew.sh):
866875
2. BTK: Set the `BTK_DIR` variable to the directory containing
867876
`BTKConfig.cmake`. If you installed BTK in `~/BTKCore-install`, then
868877
set `BTK_DIR` to `~/BTKCore-install/share/btk-0.4dev`
869-
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
878+
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
870879
containing `docopt-config.cmake`. If the root directory of your
871880
docopt.cpp installation is `~/docopt.cpp-install`, then set this
872881
variable to `~/docopt.cpp-install/lib/cmake`.
882+
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
883+
`spdlogConfig.cmake`. If the root directory of your spdlog
884+
installation is `~/spdlog-install`, then set this variable to
885+
`~/spdlog-install/lib/spdlog/cmake`.
873886
7. Set the remaining configuration options.
874887
* `BUILD_API_EXAMPLES` to compile C++ API examples.
875888
* `BUILD_TESTING` to ensure that OpenSim works correctly. The tests take a
@@ -953,6 +966,9 @@ specific Ubuntu versions under 'For the impatient' below.
953966
* **command-line argument parsing**: docopt.cpp. Two options:
954967
* Let OpenSim get this for you using superbuild (see below); much easier!
955968
* [Build on your own](https://github.com/docopt/docopt.cpp) (no instructions).
969+
* **logging**: spdlog. Two options:
970+
* Let OpenSim get this for you using superbuild (see below); much easier!
971+
* [Build on your own](https://github.com/gabime/spdlog).
956972
* **API documentation** (optional):
957973
[Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) >= 1.8.6;
958974
`doxygen`.
@@ -1057,10 +1073,14 @@ And you could get all the optional dependencies via:
10571073
2. BTK: Set the `BTK_DIR` variable to the directory containing
10581074
`BTKConfig.cmake`. If you installed BTK in `~/BTK-install`, then set
10591075
`BTK-DIR` to `~/BTK-install/share/btk-0.4dev`.
1060-
3. docopt.cpp. Set the variable `docopt_DIR` to the directory
1076+
3. docopt.cpp: Set the variable `docopt_DIR` to the directory
10611077
containing `docopt-config.cmake`. If the root directory of your
10621078
docopt.cpp installation is `~/docopt.cpp-install`, then set this
10631079
variable to `~/docopt.cpp-install/lib/cmake`.
1080+
4. spdlog: Set the variable `spdlog_DIR` to the directory containing
1081+
`spdlogConfig.cmake`. If the root directory of your spdlog
1082+
installation is `~/spdlog-install`, then set this variable to
1083+
`~/spdlog-install/lib/spdlog/cmake`.
10641084
7. Choose your build type by setting `CMAKE_BUILD_TYPE` to one of the following:
10651085
* **Debug**: debugger symbols; no optimizations (more than 10x slower).
10661086
Library names end with `_d`.

cmake/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ configure_package_config_file(
1717
CMAKE_INSTALL_LIBDIR
1818
OPENSIM_INSTALL_CMAKEDIR
1919
OPENSIM_INSTALL_SIMBODYDIR
20+
OPENSIM_INSTALL_SPDLOGDIR
2021
)
2122

2223
# Version file.

cmake/OpenSimConfig.cmake.in

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,22 @@ set(@CMAKE_PROJECT_NAME@_JAR_FILE
7474
# Dependencies
7575
# ------------
7676
if (@OPENSIM_COPY_DEPENDENCIES@) # OPENSIM_COPY_DEPENDENCIES
77-
# Find the copy of Simbody within the OpenSim installation.
77+
# Find the copies of Simbody and spdlog within the OpenSim installation.
78+
# We define _SIMBODY_PATH and _SPDLOG_PATH before find_package(Simbody)
79+
# because finding Simbody redefines the PACKAGE_PREFIX_DIR variable
80+
# that appears in this file after configuring, thereby incorrectly
81+
# causing CMake to look for spdlog within Simbody's installation.
82+
set(_SIMBODY_PATH "@PACKAGE_OPENSIM_INSTALL_SIMBODYDIR@")
83+
set(_SPDLOG_PATH "@PACKAGE_OPENSIM_INSTALL_SPDLOGDIR@")
7884
find_package(Simbody @SIMBODY_VERSION_TO_USE@ REQUIRED
79-
PATHS "@PACKAGE_OPENSIM_INSTALL_SIMBODYDIR@" NO_MODULE NO_DEFAULT_PATH)
85+
PATHS "${_SIMBODY_PATH}" NO_MODULE NO_DEFAULT_PATH)
86+
find_package(spdlog REQUIRED
87+
PATHS "${_SPDLOG_PATH}" NO_MODULE NO_DEFAULT_PATH)
8088
else()
8189
# Find the correct version anywhere on the machine.
8290
include(CMakeFindDependencyMacro)
8391
find_dependency(Simbody @SIMBODY_VERSION_TO_USE@)
92+
find_dependency(spdlog)
8493
endif()
8594

8695

dependencies/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,16 @@ AddDependency(NAME simbody
158158
AddDependency(NAME docopt
159159
URL https://github.com/docopt/docopt.cpp.git
160160
TAG af03fa044ee1eff20819549b534ea86829a24a54)
161-
161+
162+
163+
AddDependency(NAME spdlog
164+
URL https://github.com/gabime/spdlog.git
165+
TAG v1.4.1
166+
CMAKE_ARGS -DSPDLOG_BUILD_BENCH:BOOL=OFF
167+
-DSPDLOG_BUILD_TESTS:BOOL=OFF
168+
-DSPDLOG_BUILD_EXAMPLE:BOOL=OFF
169+
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON)
170+
162171
#######################
163172

164173
RemoveDefaultInstallDirIfEmpty("${DEFAULT_CMAKE_INSTALL_PREFIX}")

0 commit comments

Comments
 (0)