summaryrefslogtreecommitdiff
path: root/Meta/CMake/utils.cmake
AgeCommit message (Collapse)Author
2023-03-21Everywhere: Use `LibFileSystem` where trivialCameron Youell
2023-03-19Meta: Add a tar extraction CMake wrapperkleines Filmröllchen
This is a copy of the zip wrapper adopted for tar archives.
2023-01-19Meta: Use existing test-sources lists for Lagom instead of globbingSam Atkins
...mostly. This creates and uses an override for the `serenity_test()` function, so that Lagom can make use of the existing `Tests/LibFoo/CMakeLists.txt` files instead of having to GLOB for test source files and manually copy any data files. Some GLOBs remain but this is most of them. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2022-12-21CMake: Fall back to the Web Archive when downloading filesTim Schumacher
2022-12-10CMake: Force-link clang_rt.profile.a to LibC when building with coverageAndrew Kaster
This used to be in place until 671712cae67d7b8782afa94c09e980a77450efd6. I had commented on that PR that "yeah should be good to remove". Turns out that's not the case. A future patch to the clang driver might make this obsolete :^).
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-11-01LibC: Properly implement stack protectorsTim Schumacher
The shared parts are now firmly compiled into LibC instead of being defined as a static library and then being copied over manually. The non-shared ("local") parts are kept as a static library that is linked into each binary on demand. This finally allows us to support linking with the -fstack-protector flag, which now replaces the `ssp` target being linked into each binary accidentally via CMake.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-10-27Meta: Allow specifying additional dependencies with invoke_generatorTimothy Flynn
2022-10-17Lagom+CMake: Propagate dependencies for generated custom targetsAndrew Kaster
We have logic for serenity_generated_sources which works well for source files that are specified in GENERATED_SOURCES prior to calling serenity_lib or serenity_bin. However, code generated with invoke_generator, and the LibWeb generators do not always follow the pattern of the IDL and GML files. For the LibWeb generators, we can just add_dependencies to LibWeb at the time we declare the generate_Foo custom target. However for LibLocale, LibTimeZone, and LibUnicode, we don't have the name of the target available, so export the name in a variable to set into GENERATED_SOURCES. To make this work for Lagom, we need to make sure that lagom_lib and serenity_bin in Lagom/CMakeLists.txt call serenity_generated_sources on the target. This enables the Xcode generator on macOS hosts, at least for Lagom.
2022-10-16Meta: Remove unused "prefix" variable from invoke_generator() helperTimothy Flynn
This became unused after 1ae0cfd.
2022-10-16CMake+Userland: Use CMakeLists from Userland to build Lagom LibrariesAndrew Kaster
Also do this for Shell. This greatly simplifies the CMakeLists in Lagom, replacing many glob patterns with a big list of libraries. There are still a few special libraries that need some help to conform to the pattern, like LibELF and LibWebView. It also lets us remove essentially all of the Serenity or Lagom binary directory detection logic from code generators, as now both projects directories enter the generator logic from the same place.
2022-09-16CMake: Use `-static-libstdc++` on Clang as wellTim Schumacher
This resolves an old FIXME that we added ages ago, and our LLVM driver apparently gained support for `-static-libstdc++` somewhere along the way.
2022-09-09Meta: Use CMake functions to extract filesDiego Iastrubni
Newer cmake's have internal functions to un-compress files. These functions will work on pure windows - as well as linux. This eliminates the need to search for external tools (TAR,GZIP,ZIP) - and helps fixing #9866. In order to finally fix #9866 we need to decide to bump the cmake version requirements and remove the checks. If we demand a newer cmake version, we will loose Ubuntu 20.04 as a build target - as it ships with CMake 3.16. For now - we keep compatibility with CMake 3.16 - and only if CMake 3.18 as been found - we use its new functionality.
2022-09-05LibUnicode+Userland: Migrate generated CLDR data to LibLocaleDataTimothy Flynn
Currently, LibUnicodeData contains the generated UCD and CLDR data. Move the UCD data to the main LibUnicode library, and rename LibUnicodeData to LibLocaleData. This is another prepatory change to migrate to LibLocale.
2022-09-05LibUnicode: Move CLDR data generators to a LibLocale subfolderTimothy Flynn
To prepare for placing all CLDR generated data in a new library, LibLocale, this moves the code generators for the CLDR data to the LibLocale subfolder.
2022-07-06Meta: Build select Services in LagomAndrew Kaster
Add overrides for serenity_bin and serenity_lib to allow the actual CMakeLists.txt from Userland to be used to build as many services as possible without adding more clutter to Meta/Lagom/CMakeLists.txt
2022-07-06Meta: Use CMAKE_INSTALL_FOODIR variables instead of hardcoding usr/fooAndrew Kaster
In preparation for future refactoring of Lagom, let's use the variables from GNUInstallDirs as much as possible for the helper macros and other scripts used by the main build already.
2022-05-02Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake optionAndrew Kaster
This option sets -fprofile-instr-generate -fcoverage-mapping for Clang builds only on almost all of Userland. Loader and LibTimeZone are exempt. This can be used for generating code coverage reports, or even PGO in the future.
2022-05-02Meta: Remove unused serenity_libc_static helper functionAndrew Kaster
2022-03-24CMake: Add serenity_lib_staticLenny Maiorani
2022-03-19CMake: Modify include path when building from Hack StudioItamar
With regular builds, the generated IPC headers exist inside the Build directory. The path Userland/Services under the build directory is added to the include path. For in-system builds the IPC headers are installed at /usr/include/. To support this, we add /usr/include/Userland/Services to the build path when building from Hack Studio. Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
2022-01-26Meta: Add a CMake function to download remote files during the buildTimothy Flynn
This function will handle download failures. It doesn't support hashing for integrity yet, but if the download times out or otherwise fails, the build itself will fail. But default, file(DOWNLOAD) in CMake doesn't fail the build; we must pass in and check a STATUS variable.
2022-01-24Toolchain: Add support for building the userland with the mold linkerDaniel Bertalan
This commit adds support for building the SerenityOS userland with the new [mold linker]. This is not enabled by default yet; to link using mold, run the `Toolchain/BuildMold.sh` script to build the latest release of mold, and set the `ENABLE_MOLD_LINKER` CMake variable to ON. This option relies on toolchain support that has been added just recently, so you might need to rebuild your toolchain for mold to work. [mold linker]: https://github.com/rui314/mold
2022-01-08Meta: Move invoke_generator to utils.cmakeTimothy Flynn
2022-01-08Meta: Move remove_unicode_data_if_version_changed to utils.cmakeTimothy Flynn
This function will be used by the time zone database parser. Move it to the common utilities file, and rename it remove_path_if_version_changed to be more generic.
2022-01-08Meta: Redefine link_with_unicode_data to not include unicode_data.cmakeTimothy Flynn
This is to prevent an import cycle in a subsequent commit.
2021-12-30Meta: Add helper CMake function to link directly against LibUnicodeDataTimothy Flynn
Rather than each CMakeLists.txt needing to import unicode_data.cmake and check if Unicode data generation is enabled, add a helper method to do this.
2021-11-26CMake: Also install the source files of userland programsItamar
Previously, we only copied the source files of libraries to `/usr/src/serenity`. We now also install the source files of userland programs.
2021-11-26CMake: Simplify serenity_install_sources by inferring installation pathItamar
The serenity_install_sources function now infers the path under `/usr/src/serenity` in which to install the source files according to the relative path of the source files in the repository. For example `Userland/Libraries/LibGUI/Widget.h` gets installed at `/usr/src/serenity/Userland/Libraries/LibGUI/Widget.h`. This fixes cases where the source files of libraries are not under `Userland/Libraries` (for example LibShell & LibLanguageServer).
2021-11-13Meta: Resolve cyclic dependency between LibPthread and libc++Daniel Bertalan
libc++ uses a Pthread condition variable in one of its initialization functions. This means that Pthread forwarding has to be set up in LibC before libc++ can be initialized. Also, because LibPthread is written in C++, (at least some) parts of the C++ standard library have to be linked against it. This is a circular dependency, which means that the order in which these two libraries' initialization functions are called is undefined. In some cases, libc++ will come first, which will then trigger an assert due to the missing Pthread forwarding. This issue isn't necessarily unique to LibPthread, as all libraries that libc++ depends on exhibit the same circular dependency issue. The reason why this issue didn't affect the GNU toolchain is that libstdc++ is always linked statically. If we were to change that, I believe that we would run into the same issue.
2021-11-10CMake: Build serenity_lib libraries with a custom SONAMETim Schumacher
This allows libraries and binaries to explicitly link against `<library>.so.serenity`, which avoids some confusion if there are other libraries with the same name, such as OpenSSL's `libcrypto`.
2021-11-10CMake: Remove unused serenity_shared_lib functionTim Schumacher
2021-10-17Toolchain+Meta: Update LLVM version to 13.0.0Daniel Bertalan
This commit updates the Clang toolchain's version to 13.0.0, which comes with better C++20 support and improved handling of new features by clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our Clang binaries will only be 2-4% slower than if we dynamically linked them, but we save hundreds of megabytes of disk space. The `BuildClang.sh` script has been reworked to build the entire toolchain in just three steps: one for the compiler, one for GNU binutils, and one for the runtime libraries. This reduces the complexity of the build script, and will allow us to modify the CI configuration to only rebuild the libraries when our libc headers change. Most of the compile flags have been moved out to a separate CMake cache file, similarly to how the Android and Fuchsia toolchains are implemented within the LLVM repo. This provides a nicer interface than the heaps of command-line arguments. We no longer build separate toolchains for each architecture, as the same Clang binary can compile code for multiple targets. The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in this commit. Clang happily accepts an `i686-pc-serenity` target triple, which matches what our GCC toolchain accepts.
2021-09-15Meta: Switch to a SuperBuild that splits host and target buildsAndrew Kaster
Replace the old logic where we would start with a host build, and swap all the CMake compiler and target variables underneath it to trick CMake into building for Serenity after we configured and built the Lagom code generators. The SuperBuild creates two ExternalProjects, one for Lagom and one for Serenity. The Serenity project depends on the install stage for the Lagom build. The SuperBuild also generates a CMakeToolchain file for the Serenity build to use that replaces the old toolchain file that was only used for Ports. To ensure that code generators are rebuilt when core libraries such as AK and LibCore are modified, developers will need to direct their manual `ninja` invocations to the SuperBuild's binary directory instead of the Serenity binary directory. This commit includes warning coalescing and option style cleanup for the affected CMakeLists in the Kernel, top level, and runtime support libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be confused by a host clang compiler.
2021-08-30CMake: Add custom target to build only the generated sourcesBrian Gianforcaro
This is needed so all headers and files exist on disk, so that the sonar cloud analyzer can find them when executing the compilation commands contained in compile_commands.json, without actually building. Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2021-08-28Meta: Prefer SerenityOS_SOURCE_DIR to CMAKE_SOURCE_DIRAndrew Kaster
By using SerenityOS_SOURCE_DIR we can make custom targets and commands agnostic to the actual location of the root CMakeLists directory. All we care about is the root of the SerenityOS project.
2021-08-28Meta: Move code generator helpers to their own CMake helper fileAndrew Kaster
compile_gml, compile_ipc, and generate_state_machine all use host tools to generate sources for the target build. As part of trying to organize host tools into a common area, let's move these helper rules to a common file that we can add other host tools to later. And, keep the host tool helpers separate from the CMake target helpers for apps and libraries.
2021-08-28Meta: Move components CMake helpers to their own fileAndrew Kaster
It's hard to follow how all the functions in the utils.cmake helper file flow together, so let's move the pieces that are related to each other into specialized helpers. First up: all the ConfigureComponents related properties and functions.
2021-08-12Meta: Properly quote some CMake variables in serenity_componentsin-ack
This probably isn't all of them, because I'm no CMake expert. :^) It does however allow "/bin/false" to build now.
2021-08-08Meta: Add Clang support to the CMake build scriptsDaniel Bertalan
2021-07-29Meta/LibTest: Build object libraries for test main filesAndrew Kaster
By using the power of object libraries and $<TARGET_OBJECTS> we can make sure to only build TestMain.cpp and JavaScriptTestRunnerMain.cpp once. Previously we built these cpp files into object files once for every single test executable. This change reduces the number of total compile jobs in a Serenity target build by around 100.
2021-06-17Meta: Add support for declaring componentsGunnar Beutner
Components are a group of build targets that can be built and installed separately. Whether a component should be built can be configured with CMake arguments: -DBUILD_<NAME>=ON|OFF, where <NAME> is the name of the component (in all caps). Components can be marked as REQUIRED if they're necessary for a minimally functional base system or they can be marked as RECOMMENDED if they're not strictly necessary but are useful for most users. A component can have an optional description which isn't used by the build system but may be useful for a configuration UI. Components specify the TARGETS which should be built when the component is enabled. They can also specify other components which they depend on (with DEPENDS). This also adds the BUILD_EVERYTHING CMake variable which lets the user build all optional components. For now this defaults to ON to make the transition to the components-based build system easier. The list of components is exported as an INI file in the build directory (e.g. Build/i686/components.ini). Fixes #8048.
2021-05-20StateMachineGenerator: Put output into the CMake build directoryAndreas Kling
Don't pollute the source directory with generated code.
2021-05-20Meta: Make generate_state_machine() generate a proper targetAli Mohammad Pur
And use GENERATED_SOURCES (or add_dependencies) to make LibVT depend on that target. Fixes a FIXME.
2021-05-18LibJS+LibTest: Move out the test-js test runner into LibTestAli Mohammad Pur
2021-05-17Build: Stop using precompiled headers (PCH)Andreas Kling
This had very bad interactions with ccache, often leading to rebuilds with 100% cache misses, etc. Ali says it wasn't that big of a speedup in the end anyway, so let's not bother with it. We can always bring it back in the future if it seems like a good idea.
2021-05-16LibVT: Implement new ANSI escape sequence parserDaniel Bertalan
This commit replaces the former, hand-written parser with a new one that can be generated automatically according to a state change diagram. The new `EscapeSequenceParser` class provides a more ergonomic interface to dealing with escape sequences. This interface has been inspired by Alacritty's [vte library](https://github.com/alacritty/vte/). I tried to avoid changing the application logic inside the `Terminal` class. While this code has not been thoroughly tested, I can't find regressions in the basic command line utilities or `vttest`. `Terminal` now displays nicer debug messages when it encounters an unknown escape sequence. Defensive programming and bounds checks have been added where we access parameters, and as a result, we can now endure 4-5 seconds of `cat /dev/urandom`. :D We generate EscapeSequenceStateMachine.h when building the in-kernel LibVT, and we assume that the file is already in place when the userland library is being built. This will probably cause problems later on, but I can't find a way to do it nicely.
2021-05-13CMake: Make missing medium icon a FATAL_ERRORBrian Gianforcaro
Now that all of the medium icons pass this check, we can make it FATAL_ERROR to stop any new violations from being checked in.
2021-05-13CMake: Fix message levels for error conditions during configurationBrian Gianforcaro
Make messages which should be fatal, actually fail the build. - FATAL is not a valid mode keyword. The full list is available in the docs: https://cmake.org/cmake/help/v3.19/command/message.html - SEND_ERROR doesn't immediately stop processing, FATAL_ERROR does. We should immediately stop if the Toolchain is not present. - The app icon size validation was just a WARNING that is easy to overlook. We should promote it to a FATAL_ERROR so that people will not overlook the issue when adding a new application. We can only make the small icon message FATAL_ERROR, as there is currently one violation of the medium app icon validation.