-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added sample cmake pre-load scripts and a user presets file, and updated the buildsystem to install them in the `share` directory tree. - Added /dpdk.cmake and /es2k.cmake to .gitignore. Signed-off-by: Derek Foster <derek.foster@intel.com>
- Loading branch information
Showing
7 changed files
with
186 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache 2.0 | ||
|
||
install( | ||
FILES | ||
CMakeUserPresets.json | ||
dpdk.cmake | ||
es2k.cmake | ||
README.md | ||
DESTINATION | ||
${CMAKE_INSTALL_PREFIX}/share/p4cp/cmake | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"version": 4, | ||
"configurePresets": [ | ||
{ | ||
"name": "dpdk", | ||
"displayName": "DPDK target (P4OVS mode)", | ||
"inherits": [ | ||
"base-dpdk-target", | ||
"install-path-presets", | ||
"ovs-legacy-mode" | ||
] | ||
}, | ||
{ | ||
"name": "dpdk-ovsp4rt", | ||
"displayName": "DPDK target (OVSP4RT mode)", | ||
"inherits": [ | ||
"base-dpdk-target", | ||
"install-path-presets", | ||
"ovs-ovsp4rt-mode" | ||
] | ||
}, | ||
{ | ||
"name": "es2k", | ||
"displayName": "ES2K target (P4OVS mode)", | ||
"inherits": [ | ||
"base-es2k-target", | ||
"install-path-presets", | ||
"ovs-legacy-mode" | ||
] | ||
}, | ||
{ | ||
"name": "es2k-ovsp4rt", | ||
"displayName": "ES2K target (OVSP4RT mode)", | ||
"inherits": [ | ||
"base-es2k-target", | ||
"install-path-presets", | ||
"ovs-ovsp4rt-mode" | ||
] | ||
}, | ||
{ | ||
"name": "tofino", | ||
"displayName": "Tofino target (no OVS)", | ||
"inherits": [ | ||
"base-tofino-target", | ||
"install-path-presets" | ||
] | ||
|
||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# Sample CMake Scripts | ||
|
||
This folder contains sample scripts that may be customized and added | ||
to your build environment. | ||
|
||
## Pre-load scripts | ||
|
||
- `dpdk.cmake` | ||
- `es2k.cmake` | ||
|
||
### About pre-load scripts | ||
|
||
These scripts allow you to specify one or more sets of parameters to be | ||
applied at cmake configuration time. | ||
|
||
Each file defines one or more cmake variables to be loaded into the cache | ||
after the command line is processed and before the first CMakeLists.txt | ||
file is read. | ||
|
||
To use a sample script, copy it to the top-level folder and make any | ||
changes you wish. You can create as many pre-load scripts as you want. | ||
|
||
Pre-load scripts are customer-specific and are not stored in the | ||
repository. | ||
|
||
### Configure with a pre-load script | ||
|
||
```bash | ||
cmake -B build -C dpdk.cmake [more options] | ||
``` | ||
|
||
### Override an option | ||
|
||
```bash | ||
cmake -B build -C es2k.cmake -DCMAKE_INSTALL_PREFIX=/opt/p4cp | ||
``` | ||
|
||
## Preset files | ||
|
||
- `CMakeUserPresets.json` | ||
|
||
### About presets | ||
|
||
This file defines user presets that can be used to configure cmake. | ||
It makes use of hidden presets that are defined in `CMakePresets.json`, | ||
which is stored in the repository. | ||
|
||
To use it, copy the file to the top-level (networking-recipe) directory | ||
and make any changes you want. Deleting targets you don't plan to use | ||
would be a good place to start. | ||
|
||
User presets are customer-specific and are not stored in the repository. | ||
The `.gitignore` file instructs git to ignore the file if it is in the | ||
top-level directory. | ||
|
||
Presets were introduced in cmake 3.19. This file uses schema version 4, | ||
which requires cmake 3.23.0 or later. | ||
|
||
See the [cmake-presets guide](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) | ||
for more information. | ||
|
||
### List available presets | ||
|
||
```text | ||
frodo@bagend:~/networking-recipe$ cmake --list-presets | ||
Available configure presets: | ||
"dpdk" - DPDK target (P4OVS mode) | ||
"dpdk-ovsp4rt" - DPDK target (OVSP4RT mode) | ||
"es2k" - ES2K target (P4OVS mode) | ||
"es2k-ovsp4rt" - ES2K target (OVSP4RT mode) | ||
"tofino" - Tofino target (no OVS) | ||
``` | ||
|
||
### Configure using a preset | ||
|
||
```text | ||
frodo@bagend:~/networking-recipe$ cmake --preset dpdk | ||
Preset CMake variables: | ||
CMAKE_BUILD_TYPE="RelWithDebInfo" | ||
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL="TRUE" | ||
CMAKE_INSTALL_PREFIX:PATH="/home/dfoster/work/latest/install" | ||
DEPEND_INSTALL_DIR:PATH="/opt/deps" | ||
OVS_INSTALL_DIR:PATH="/home/dfoster/work/latest/ovs/install" | ||
P4OVS_MODE="P4OVS" | ||
SDE_INSTALL_DIR:PATH="/home/dfoster/SDE/install" | ||
SET_RPATH:BOOL="TRUE" | ||
TDI_TARGET="dpdk" | ||
-- The C compiler identification is GNU 9.4.0 | ||
-- The CXX compiler identification is GNU 9.4.0 | ||
. | ||
. | ||
-- Configuring done (2.4s) | ||
-- Generating done (0.4s) | ||
-- Build files have been written to: /home/bilbo/networking-recipe/build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Configures CMake for a DPDK build. | ||
# Usage: cmake -B <build-dir> -C dpdk.cmake | ||
|
||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "p4cp install directory") | ||
set(DEPEND_INSTALL_DIR "$ENV{DEPEND_INSTALL}" CACHE PATH "stratum-deps install directory") | ||
set(OVS_INSTALL_DIR "${CMAKE_SOURCE_DIR}/ovs/install" CACHE PATH "ovs install directory") | ||
set(SDE_INSTALL_DIR "$ENV{SDE_INSTALL}" CACHE PATH "SDE install directory") | ||
set(SET_RPATH YES CACHE BOOL "Whether to set RPATH in binary artifacts") | ||
set(TDI_TARGET "DPDK" CACHE STRING "TDI target to build") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Configures CMake for an ES2K build. | ||
# Usage: cmake -B <build-dir> -C es2k.cmake | ||
|
||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "p4cp install directory") | ||
set(DEPEND_INSTALL_DIR "$ENV{DEPEND_INSTALL}" CACHE PATH "stratum-deps install directory") | ||
set(OVS_INSTALL_DIR "${CMAKE_SOURCE_DIR}/ovs/install" CACHE PATH "ovs install directory") | ||
set(SDE_INSTALL_DIR "$ENV{SDE_INSTALL}" CACHE PATH "SDE install directory") | ||
set(SET_RPATH YES CACHE BOOL "Whether to set RPATH in binary artifacts") | ||
set(TDI_TARGET "ES2K" CACHE STRING "TDI target to build") |