You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Xmake supports not only installing packages from the official repository but also creating and distributing private libraries. This is very useful for reusing private code libraries within a company.
4
8
5
9
We can package compiled static/dynamic libraries into local packages or remote packages for distribution, or install them directly to the system directory.
First, we can use the `xmake create` command to quickly create an empty static or dynamic library project.
10
14
@@ -35,6 +39,26 @@ target("test")
35
39
add_files("src/main.cpp")
36
40
```
37
41
42
+
By default, `add_headerfiles` installs header files directly to the `include` directory.
43
+
44
+
If you want to install header files to a subdirectory (e.g. `include/foo/foo.h`) to avoid filename conflicts, you can set `prefixdir`:
45
+
46
+
```lua
47
+
add_headerfiles("src/foo.h", {prefixdir="foo"})
48
+
```
49
+
50
+
For more details, please refer to: [add_headerfiles documentation](/api/description/project-target.html#add_headerfiles).
51
+
52
+
In addition to header files, we can also use [`add_installfiles`](/api/description/project-target.html#add_installfiles) to install any other files, such as documentation, scripts, resource files, etc.
If our library is only used within the local LAN or shared with others via a network drive, and does not need to be deployed to a remote git repository, we can use local package distribution.
@@ -94,7 +118,7 @@ Each package directory contains the generated binary library files (`.a`/`.lib`/
94
118
95
119
96
120
97
-
### Integration
121
+
### Consume Local Package {#local-package-integration}
98
122
99
123
We copy the generated `build/packages` directory to any location, or use it directly. Then configure it in the consumer project's `xmake.lua`:
100
124
@@ -144,7 +168,7 @@ The `build/packages` directory generated by `xmake package` mentioned above is a
144
168
145
169
When executing `xmake` to build, Xmake will link the corresponding binary libraries directly from the local repository.
If we need to manage versions and distribute via a git repository, we can use the remote package mode. It supports distributing both source packages and binary packages.
150
174
@@ -153,7 +177,7 @@ The advantages of remote packages are:
153
177
- Supports source distribution (automatic compilation) and binary distribution (direct installation)
In the consumer project, we need to add this private repository.
225
249
@@ -239,13 +263,13 @@ target("bar")
239
263
240
264
Xmake will automatically pull the package description from the `my-repo` repository, and then download the `foo` source code according to `add_urls` for compilation and installation.
241
265
242
-
## Distribute C++ Modules {#distribute-cxx-modules}
266
+
## Distribute C++ Modules Package {#distribute-cxx-modules}
243
267
244
268
Xmake also supports distributing C++ Modules libraries. We only need to add `{install = true}` in `add_files` to package and distribute module files (`.mpp`, `.ixx`, etc.) together.
245
269
246
270
Usually, we need to define the package in an independent repository.
247
271
248
-
### Library Project
272
+
### Configure Library Project
249
273
250
274
In the `xmake.lua` of the library project, we need to export the module files:
251
275
@@ -288,7 +312,7 @@ target("bar")
288
312
289
313
For more complete examples, please refer to: [C++ Modules Package Distribution Example](https://github.com/xmake-io/xmake/tree/master/tests/projects/c%2B%2B/modules/packages).
The generated installation package can be installed by double-clicking, and it automatically configures environment variables such as PATH, making it convenient for users to use.
516
+
It will automatically download the NSIS tool and generate the installation package. The generated installation package can be installed by double-clicking, and it automatically configures environment variables such as PATH, making it convenient for users to use.
456
517
457
518
For more details, please see the documentation: [XPack Packaging](/guide/extensions/builtin-plugins.html#xpack).
0 commit comments