Skip to content

Commit e2de1b9

Browse files
committed
Disable filib shared lib for windows
1 parent 6fa425b commit e2de1b9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ The following dependencies are optionally used based on CMake options:
8484
* [filib](https://github.com/zfergus/filib): interval arithmetic for nonlinear trajectories/CCD
8585
* Enable by using the CMake option `IPC_TOOLKIT_WITH_FILIB`
8686
* Enabled by default
87+
* NOTE: filib is licensed under LGPL-2.1 and as such it is required to be dynamically linked. We enable this by default for Linux and MacOS. However, for Windows, we disable this by default because it requires copying the DLLs to the binary directory. To enable this, set the CMake option `FILIB_BUILD_SHARED_LIBS` to `ON` and add this CMake code to copy the DLLs to the binary directory:
88+
```cmake
89+
if(WIN32)
90+
# Copy DLLs to the output directory
91+
add_custom_command(
92+
TARGET ${MY_EXE_TARGET} POST_BUILD
93+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:${MY_EXE_TARGET}> $<TARGET_FILE_DIR:${MY_EXE_TARGET}>
94+
COMMAND_EXPAND_LISTS
95+
)
96+
endif()
97+
```
98+
* where `${MY_EXE_TARGET}` is the name of your executable target. If you know a better way to handle this, please [let us know](https://github.com/ipc-sim/ipc-toolkit/discussions)!
99+
* If you would rather avoid LGPL code entirely, you can disable filib by setting `IPC_TOOLKIT_WITH_FILIB` to `OFF`. With this option disabled, CMake will not download or use any of filib's code.
87100
* [rational-cpp](https://github.io/zfergus/rational-cpp): rational arithmetic used for exact intersection checks
88101
* Enable by using the CMake option `IPC_TOOLKIT_WITH_RATIONAL_INTERSECTION`
89102
* Requires [GMP](https://gmplib.org/) to be installed at a system level

cmake/recipes/filib.cmake

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ endif()
66

77
message(STATUS "Third-party: creating target 'filib::filib'")
88

9-
# This has to be set to ON to avoid licensing IPC Toolkit under LGPL
10-
set(FILIB_BUILD_SHARED_LIB ON CACHE BOOL "Build shared library" FORCE)
9+
# filib should be built as a shared library to avoid licensing IPC Toolkit under LGPL
10+
if(WIN32 AND NOT IPC_TOOLKIT_TOPLEVEL_PROJECT)
11+
# Setting up proper linkage on Windows is a bit tricky, so we'll just use a
12+
# static library by default and provide instructions on how to build as a
13+
# shared library in the README.
14+
option(FILIB_BUILD_SHARED_LIB "Build shared library" OFF)
15+
else()
16+
# NOTE: Our Windows CMake is properly configured to build shared libraries for
17+
# OUR applications and python bindings.
18+
option(FILIB_BUILD_SHARED_LIB "Build shared library" ON)
19+
endif()
1120

1221
include(CPM)
1322
CPMAddPackage("gh:zfergus/filib#03e4eb0fc59399bd0003f8efd3179078195df49f")

0 commit comments

Comments
 (0)