summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Puleo <james@jame.xyz>2022-02-07 03:47:30 -0500
committerLinus Groh <mail@linusgroh.de>2022-02-07 11:04:07 +0000
commit2f646f42848522a5898adc5e774e64b443faa71b (patch)
treea7be0573ea7b0f9bd32dd5451a8b8550969901ee
parentb28e861776661f51122a39ca6e0d045833e78c94 (diff)
downloadserenity-2f646f42848522a5898adc5e774e64b443faa71b.zip
Meta: Add instructions on using Lagom in an external project
-rw-r--r--Meta/Lagom/ReadMe.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/Meta/Lagom/ReadMe.md b/Meta/Lagom/ReadMe.md
index 390f826056..aee06fef36 100644
--- a/Meta/Lagom/ReadMe.md
+++ b/Meta/Lagom/ReadMe.md
@@ -130,3 +130,29 @@ You may run into annoying issues with the stacktrace:
That means it couldn't find the executable `llvm-symbolizer`, which could be in your OS's package `llvm`.
`llvm-symbolizer-11` will [not be recognized](https://stackoverflow.com/a/42845444/).
+
+## Using Lagom in an External Project
+It is possible to use Lagom for your own projects outside of Serenity too!
+
+An example of this in use can be found [on Linus' LibJS test262 runner](https://github.com/linusg/libjs-test262).
+
+To implement this yourself:
+- Download a copy of [linusg/libjs-test262/cmake/FetchLagom.cmake](https://github.com/linusg/libjs-test262/blob/7832c333c1504eecf1c5f9e4247aa6b34a52a3be/cmake/FetchLagom.cmake) and place it wherever you wish
+- In your root `CMakeLists.txt`, add the following commands:
+ ```cmake
+ include(FetchContent)
+ include(cmake/FetchLagom.cmake) # If you've placed the file downloaded above differently, be sure to reflect that in this command :^)
+ ```
+- In addition, you will need to also add some compile options that Serenity uses to ensure no warnings or errors:
+ ```cmake
+ add_compile_options(-Wno-literal-suffix) # AK::StringView defines operator"" sv, which GCC complains does not have an underscore.
+ add_compile_options(-fno-gnu-keywords) # JS::Value has a method named typeof, which also happens to be a GNU keyword.
+ ```
+
+Now, you can link against Lagom libraries.
+
+Things to keep in mind:
+- You should prefer to use a library's `Lagom::` alias when linking
+ - Example: `Lagom::Core` vs `LibCore`
+- If you still _need_ to use the standard library, you may have to compile with the `AK_DONT_REPLACE_STD` macro.
+ - Serenity defines its own `move` and `forward` functions inside of `AK/StdLibExtras.h` that will clash with the standard library's definitions. This macro will make Serenity use the standard library's `move` and `forward` instead.