diff options
author | Silvio Traversaro <pegua1@gmail.com> | 2017-09-27 18:36:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 18:36:26 +0200 |
commit | f1edc33522cfd5c55ad61d820419c0e9511a1491 (patch) | |
tree | f3d8442ec4b64e6bd7dd58e41837bc7e86e05681 | |
parent | 2d03bf631daefa0157176697074b66f9d760e4b5 (diff) | |
parent | b30b758efb90aaf2bc96b034c117c8f21490c54e (diff) | |
download | dlfcn-win32-f1edc33522cfd5c55ad61d820419c0e9511a1491.tar.gz dlfcn-win32-f1edc33522cfd5c55ad61d820419c0e9511a1491.tar.bz2 dlfcn-win32-f1edc33522cfd5c55ad61d820419c0e9511a1491.zip |
Merge pull request #40 from dlfcn-win32/document-cmake-usage
Document how to use the library when using CMake
-rw-r--r-- | README.md | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -20,6 +20,30 @@ http://www.opengroup.org/onlinepubs/009695399/functions/dlopen.html | |||
20 | Using This Library | 20 | Using This Library |
21 | ------------------ | 21 | ------------------ |
22 | 22 | ||
23 | ### Using CMake | ||
24 | Once the library has been installed, add to your project `CMakeLists.txt` : | ||
25 | ~~~ | ||
26 | ... | ||
27 | find_package(dlfcn-win32 REQUIRED) | ||
28 | ... | ||
29 | target_link_libraries(<target> dlfcn-win32::dl) | ||
30 | ... | ||
31 | ~~~ | ||
32 | If you want to use this library in a cross-platform project, a convenient way | ||
33 | to proceed is to define the CMake variable [`CMAKE_DL_LIBS`](https://cmake.org/cmake/help/latest/variable/CMAKE_DL_LIBS.html) | ||
34 | (that is normally empty on Windows) and then use it for linking: | ||
35 | ~~~ | ||
36 | ... | ||
37 | if (WIN32) | ||
38 | find_package(dlfcn-win32 REQUIRED) | ||
39 | set(CMAKE_DL_LIBS dlfcn-win32::dl) | ||
40 | endif () | ||
41 | ... | ||
42 | target_link_libraries(<target> ${CMAKE_DL_LIBS}) | ||
43 | ... | ||
44 | ~~~ | ||
45 | |||
46 | ### Linking caveat | ||
23 | This library uses the Process Status API in Windows (`psapi.lib`). If you are | 47 | This library uses the Process Status API in Windows (`psapi.lib`). If you are |
24 | linking to the static `dl.lib` or `libdl.a`, then you would need to explicitly | 48 | linking to the static `dl.lib` or `libdl.a`, then you would need to explicitly |
25 | add `psapi.lib` or `-lpsapi` to your linking command, depending on if MinGW is | 49 | add `psapi.lib` or `-lpsapi` to your linking command, depending on if MinGW is |