From b30b758efb90aaf2bc96b034c117c8f21490c54e Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 24 Aug 2017 21:50:51 +0100 Subject: Mention the possibility of defining CMAKE_DL_LIBS --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 228bd98..6e8ec21 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,19 @@ find_package(dlfcn-win32 REQUIRED) target_link_libraries( dlfcn-win32::dl) ... ~~~ +If you want to use this library in a cross-platform project, a convenient way +to proceed is to define the CMake variable [`CMAKE_DL_LIBS`](https://cmake.org/cmake/help/latest/variable/CMAKE_DL_LIBS.html) +(that is normally empty on Windows) and then use it for linking: +~~~ +... +if (WIN32) + find_package(dlfcn-win32 REQUIRED) + set(CMAKE_DL_LIBS dlfcn-win32::dl) +endif () +... +target_link_libraries( ${CMAKE_DL_LIBS}) +... +~~~ ### Linking caveat This library uses the Process Status API in Windows (`psapi.lib`). If you are -- cgit v1.2.3-55-g6feb