diff options
author | Silvio Traversaro <silvio@traversaro.it> | 2023-12-23 11:28:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 11:28:18 +0100 |
commit | 68dbd5e5f589f6f648e917851e901c538c8d314c (patch) | |
tree | a807fe43d019252836dedcc2026cf46f70458724 /README.md | |
parent | 048bff80f2bd00bb651bcc3357cb6f76e3d76fd5 (diff) | |
download | dlfcn-win32-fix49.tar.gz dlfcn-win32-fix49.tar.bz2 dlfcn-win32-fix49.zip |
Add support to consume library via CMake's FetchContentfix49
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -20,8 +20,11 @@ It follows the standard as described here: | |||
20 | Using This Library | 20 | Using This Library |
21 | ------------------ | 21 | ------------------ |
22 | 22 | ||
23 | ### Using CMake | 23 | ### Using CMake |
24 | Once the library has been installed, add to your project `CMakeLists.txt` : | 24 | |
25 | #### Use installed library | ||
26 | |||
27 | Once the library has been installed (for example by compiling from source or installing it via a package manager), add to your project `CMakeLists.txt` : | ||
25 | ~~~cmake | 28 | ~~~cmake |
26 | ... | 29 | ... |
27 | find_package(dlfcn-win32 REQUIRED) | 30 | find_package(dlfcn-win32 REQUIRED) |
@@ -45,6 +48,28 @@ target_link_libraries(<target> ${CMAKE_DL_LIBS}) | |||
45 | 48 | ||
46 | When cross-compiling you might want to set [`CMAKE_CROSSCOMPILING_EMULATOR`](https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING_EMULATOR.html) to the path of wine to run tests. | 49 | When cross-compiling you might want to set [`CMAKE_CROSSCOMPILING_EMULATOR`](https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING_EMULATOR.html) to the path of wine to run tests. |
47 | 50 | ||
51 | #### Download and build library as part of CMake build | ||
52 | |||
53 | If you do not have installed and you do not want to install the library, you can also download and build it using [CMake's FetchContent module](https://cmake.org/cmake/help/latest/module/FetchContent.html). Just add in your CMake project: | ||
54 | ~~~cmake | ||
55 | ... | ||
56 | if (WIN32) | ||
57 | include(FetchContent) | ||
58 | FetchContent_Declare( | ||
59 | dlfcn-win32 | ||
60 | GIT_REPOSITORY "https://github.com/dlfcn-win32/dlfcn-win32.git" | ||
61 | GIT_TAG "v1.5.0" | ||
62 | SYSTEM | ||
63 | ) | ||
64 | FetchContent_MakeAvailable(dlfcn-win32) | ||
65 | set(CMAKE_DL_LIBS dlfcn-win32::dl) | ||
66 | endif () | ||
67 | ... | ||
68 | target_link_libraries(<target> ${CMAKE_DL_LIBS}) | ||
69 | ... | ||
70 | ~~~ | ||
71 | |||
72 | |||
48 | Authors | 73 | Authors |
49 | ------- | 74 | ------- |
50 | 75 | ||