mirror of
https://github.com/bensuperpc/astar.git
synced 2026-05-05 19:05:24 +02:00
+103
@@ -0,0 +1,103 @@
|
||||
# Building with CMake
|
||||
|
||||
## Build
|
||||
|
||||
This project doesn't require any special command-line flags to build to keep
|
||||
things simple.
|
||||
|
||||
### Building with Make
|
||||
|
||||
You can use the Makefile provided in the root of the project to easily build multiple presets:
|
||||
|
||||
```sh
|
||||
make base # Build the base preset
|
||||
```
|
||||
|
||||
```sh
|
||||
make debug # Build the debug preset
|
||||
```
|
||||
|
||||
### Building with CMake
|
||||
|
||||
Here are the steps for building in release mode with a single-configuration
|
||||
generator, like the Unix Makefiles one:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
Here are the steps for building in release mode with a multi-configuration
|
||||
generator, like the Visual Studio ones:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build
|
||||
cmake --build build --config Release
|
||||
```
|
||||
|
||||
### Building with MSVC
|
||||
|
||||
Note that MSVC by default is not standards compliant and you need to pass some
|
||||
flags to make it behave properly. See the `flags-windows` preset in the
|
||||
[CMakePresets.json](CMakePresets.json) file for the flags and with what
|
||||
variable to provide them to CMake during configuration.
|
||||
|
||||
### Building on Apple Silicon
|
||||
|
||||
CMake supports building on Apple Silicon properly since 3.20.1. Make sure you
|
||||
have the [latest version][1] installed.
|
||||
|
||||
## Install
|
||||
|
||||
This project doesn't require any special command-line flags to install to keep
|
||||
things simple. As a prerequisite, the project has to be built with the above
|
||||
commands already.
|
||||
|
||||
The below commands require at least CMake 3.15 to run, because that is the
|
||||
version in which [Install a Project][2] was added.
|
||||
|
||||
Here is the command for installing the release mode artifacts with a
|
||||
single-configuration generator, like the Unix Makefiles one:
|
||||
|
||||
```sh
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
Here is the command for installing the release mode artifacts with a
|
||||
multi-configuration generator, like the Visual Studio ones:
|
||||
|
||||
```sh
|
||||
cmake --install build --config Release
|
||||
```
|
||||
|
||||
### CMake package
|
||||
|
||||
This project exports a CMake package to be used with the [`find_package`][3]
|
||||
command of CMake:
|
||||
|
||||
* Package name: `astar`
|
||||
* Target name: `astar::astar`
|
||||
|
||||
Example usage:
|
||||
|
||||
```cmake
|
||||
find_package(astar REQUIRED)
|
||||
# Declare the imported target as a build requirement using PRIVATE, where
|
||||
# project_target is a target created in the consuming project
|
||||
target_link_libraries(
|
||||
project_target PRIVATE
|
||||
astar::astar
|
||||
)
|
||||
```
|
||||
|
||||
### Note to packagers
|
||||
|
||||
The `CMAKE_INSTALL_INCLUDEDIR` is set to a path other than just `include` if
|
||||
the project is configured as a top level project to avoid indirectly including
|
||||
other libraries when installed to a common prefix. Please review the
|
||||
[install-rules.cmake](cmake/install-rules.cmake) file for the full set of
|
||||
install rules.
|
||||
|
||||
[1]: https://cmake.org/download/
|
||||
[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project
|
||||
[3]: https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
Reference in New Issue
Block a user