Skip to content

Commit 2e05115

Browse files
authored
docs: move pixi-build example to subfolder and restore cpp-sdl example (prefix-dev#2723)
1 parent 3750f98 commit 2e05115

19 files changed

+3634
-165
lines changed

examples/cpp-sdl/CMakeLists.txt

-9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,3 @@ target_link_libraries(
1616
SDL2::SDL2
1717
SDL2::SDL2main
1818
)
19-
20-
include(GNUInstallDirs)
21-
install(
22-
TARGETS ${PROJECT_NAME}
23-
EXPORT ${PROJECT_NAME}Targets
24-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
25-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
26-
RUNTIME DESTINATION ${BINDIR}
27-
)

examples/cpp-sdl/pixi.lock

+3,244-134
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/cpp-sdl/pixi.toml

+37-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
1-
[workspace]
2-
channels = ["https://prefix.dev/conda-forge"]
3-
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
4-
preview = ["pixi-build"]
5-
6-
[package]
1+
[project]
72
authors = ["Bas Zalmstra <bas@prefix.dev>"]
3+
channels = ["conda-forge"]
84
description = "Showcases how to create a simple C++ executable with Pixi"
95
name = "sdl_example"
10-
version = "0.1.0"
11-
12-
[build-system]
13-
build-backend = { name = "pixi-build-cmake", version = "*" }
14-
channels = [
15-
"https://prefix.dev/pixi-build-backends",
16-
"https://prefix.dev/conda-forge",
17-
]
6+
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
187

198
[tasks.start]
20-
cmd = "sdl_example"
21-
22-
[host-dependencies]
23-
# This ensures that SDL2 is available at build time.
24-
sdl2 = ">=2.26.5,<3.0"
9+
# Start the built executable
10+
cmd = ".build/bin/sdl_example"
11+
depends-on = ["build"]
2512

2613
[dependencies]
27-
# Define a dependency on ourselves. This will invoke the build backend to build
28-
# the C++ code and install the executable in an environment ready to be used.
29-
sdl_example = { path = "." }
14+
sdl2 = "2.26.5.*"
15+
16+
[feature.build.dependencies]
17+
cmake = "3.26.4.*"
18+
cxx-compiler = "1.5.2.*"
19+
make = ">=4.3,<5"
20+
ninja = "1.11.1.*"
21+
22+
[feature.build.tasks.configure]
23+
# Configures CMake
24+
cmd = [
25+
"cmake",
26+
# Use the cross-platform Ninja generator
27+
"-GNinja",
28+
# The source is in the root directory
29+
"-S.",
30+
# We wanna build in the .build directory
31+
"-B.build",
32+
]
33+
inputs = ["CMakeLists.txt"]
34+
outputs = [".build/CMakeFiles/"]
35+
36+
# Build the executable but make sure CMake is configured first.
37+
[feature.build.tasks.build]
38+
cmd = ["cmake", "--build", ".build"]
39+
depends-on = ["configure"]
40+
inputs = ["CMakeLists.txt", "src/*"]
41+
outputs = [".build/bin/sdl_example"]
42+
43+
[environments]
44+
build = ["build"]

examples/pixi-build/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Pixi Build
2+
3+
These examples utilize pixi build and require a development version of pixi to work.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# pixi environments
2+
.pixi
3+
4+
# The build directory
5+
.build
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.7)
2+
project(sdl_example)
3+
4+
find_package(SDL2 REQUIRED)
5+
6+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
7+
8+
add_executable(${PROJECT_NAME} src/main.cc)
9+
10+
if (MSVC)
11+
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
12+
endif()
13+
14+
target_link_libraries(
15+
${PROJECT_NAME} PRIVATE
16+
SDL2::SDL2
17+
SDL2::SDL2main
18+
)
19+
20+
include(GNUInstallDirs)
21+
install(
22+
TARGETS ${PROJECT_NAME}
23+
EXPORT ${PROJECT_NAME}Targets
24+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
25+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
26+
RUNTIME DESTINATION ${BINDIR}
27+
)

examples/pixi-build/cpp-sdl/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Simple C++ SDL Example
2+
3+
This is a simple pixi demo that showcases how to use C++ and SDL.
4+
5+
## How to use?
6+
7+
Make sure you have `pixi` available in your terminal.
8+
Navigate to this directory and run:
9+
10+
```shell
11+
# Configure the CMake project
12+
pixi run configure
13+
14+
# Build the executable
15+
pixi run build
16+
17+
# Start the build executable
18+
pixi run start
19+
```

examples/pixi-build/cpp-sdl/pixi.lock

+183
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/pixi-build/cpp-sdl/pixi.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[workspace]
2+
channels = ["https://prefix.dev/conda-forge"]
3+
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
4+
preview = ["pixi-build"]
5+
6+
[package]
7+
authors = ["Bas Zalmstra <bas@prefix.dev>"]
8+
description = "Showcases how to create a simple C++ executable with Pixi"
9+
name = "sdl_example"
10+
version = "0.1.0"
11+
12+
[build-system]
13+
build-backend = { name = "pixi-build-cmake", version = "*" }
14+
channels = [
15+
"https://prefix.dev/pixi-build-backends",
16+
"https://prefix.dev/conda-forge",
17+
]
18+
19+
[tasks.start]
20+
cmd = "sdl_example"
21+
22+
[host-dependencies]
23+
# This ensures that SDL2 is available at build time.
24+
sdl2 = ">=2.26.5,<3.0"
25+
26+
[dependencies]
27+
# Define a dependency on ourselves. This will invoke the build backend to build
28+
# the C++ code and install the executable in an environment ready to be used.
29+
sdl_example = { path = "." }

0 commit comments

Comments
 (0)