Skip to content

Commit 3863fe5

Browse files
committed
Enforce out-of-source builds and standardize third_party deps
1 parent d266237 commit 3863fe5

3 files changed

Lines changed: 87 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
cmake_minimum_required(VERSION 3.20)
22

3+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
4+
message(FATAL_ERROR
5+
"In-source builds are not supported. Configure with: cmake -S . -B build")
6+
endif()
7+
38
project(openmoq_publisher
49
VERSION 0.1.0
510
DESCRIPTION "OpenMOQ contribution project: C++20 publisher for fragmented MP4 to CMSF/MOQT"
@@ -13,8 +18,18 @@ option(OPENMOQ_BUILD_TESTS "Build OpenMOQ publisher tests" ON)
1318
option(OPENMOQ_ENABLE_PICOQUIC "Enable picoquic transport integration when picoquic is available" ON)
1419
option(OPENMOQ_RUN_PICOQUIC_SMOKE_TESTS "Build and run picoquic loopback smoke tests" OFF)
1520

16-
set(OPENMOQ_PICOQUIC_SOURCE_DIR "" CACHE PATH
17-
"Path to a picoquic source checkout")
21+
set(_OPENMOQ_THIRDPARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third_party")
22+
if(NOT EXISTS "${_OPENMOQ_THIRDPARTY_ROOT}")
23+
set(_OPENMOQ_THIRDPARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty")
24+
endif()
25+
26+
set(_OPENMOQ_DEFAULT_PICOQUIC_SOURCE_DIR "${_OPENMOQ_THIRDPARTY_ROOT}/picoquic")
27+
set(_OPENMOQ_DEFAULT_PICOTLS_SOURCE_DIR "${_OPENMOQ_THIRDPARTY_ROOT}/picotls")
28+
29+
set(OPENMOQ_PICOQUIC_SOURCE_DIR "${_OPENMOQ_DEFAULT_PICOQUIC_SOURCE_DIR}" CACHE PATH
30+
"Path to a picoquic source checkout (defaults to third_party/ or thirdparty/)")
31+
set(OPENMOQ_PICOTLS_SOURCE_DIR "${_OPENMOQ_DEFAULT_PICOTLS_SOURCE_DIR}" CACHE PATH
32+
"Path to a picotls source checkout (defaults to third_party/ or thirdparty/)")
1833

1934
set(OPENMOQ_HAS_PICOQUIC OFF)
2035

@@ -39,9 +54,6 @@ function(openmoq_sanitize_target_link_directories target_name)
3954
endfunction()
4055

4156
if(OPENMOQ_ENABLE_PICOQUIC AND EXISTS "${OPENMOQ_PICOQUIC_SOURCE_DIR}/CMakeLists.txt")
42-
set(OPENMOQ_PICOTLS_SOURCE_DIR "${OPENMOQ_PICOQUIC_SOURCE_DIR}/../picotls" CACHE PATH
43-
"Path to a picotls source checkout")
44-
4557
if(EXISTS "${OPENMOQ_PICOTLS_SOURCE_DIR}/CMakeLists.txt")
4658
# picotls still declares CMake 2.8 compatibility; newer CMake releases
4759
# require an explicit policy floor when configuring that subproject.

CMakePresets.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 20,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "default",
11+
"displayName": "Default (build/)",
12+
"generator": "Ninja",
13+
"binaryDir": "${sourceDir}/build",
14+
"cacheVariables": {
15+
"CMAKE_BUILD_TYPE": "Release",
16+
"OPENMOQ_RUN_PICOQUIC_SMOKE_TESTS": "OFF"
17+
}
18+
},
19+
{
20+
"name": "default-make",
21+
"displayName": "Default Makefiles (build/)",
22+
"generator": "Unix Makefiles",
23+
"binaryDir": "${sourceDir}/build",
24+
"cacheVariables": {
25+
"CMAKE_BUILD_TYPE": "Release",
26+
"OPENMOQ_RUN_PICOQUIC_SMOKE_TESTS": "OFF"
27+
}
28+
}
29+
],
30+
"buildPresets": [
31+
{
32+
"name": "default",
33+
"configurePreset": "default"
34+
},
35+
{
36+
"name": "default-make",
37+
"configurePreset": "default-make"
38+
}
39+
],
40+
"testPresets": [
41+
{
42+
"name": "default",
43+
"configurePreset": "default",
44+
"output": {
45+
"outputOnFailure": true
46+
}
47+
},
48+
{
49+
"name": "default-make",
50+
"configurePreset": "default-make",
51+
"output": {
52+
"outputOnFailure": true
53+
}
54+
}
55+
]
56+
}

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,24 @@ cmake --build build
7979
ctest --test-dir build --output-on-failure
8080
```
8181

82+
Using presets (same `build/` output directory):
83+
84+
```bash
85+
cmake --preset default
86+
cmake --build --preset default
87+
ctest --preset default
88+
```
89+
8290
On Windows with the Visual Studio generator, the binary lands in `build\Release\` or `build\Debug\` depending on the config passed to `--build`.
8391

8492
### Build with local picoquic and picotls
8593

86-
Clone picoquic and picotls to any convenient location and initialise the picotls submodules:
94+
By default, CMake now looks for:
95+
96+
- `third_party/picoquic` and `third_party/picotls`
97+
- fallback: `thirdparty/picoquic` and `thirdparty/picotls`
98+
99+
If you prefer custom paths, clone picoquic and picotls to any convenient location and initialise the picotls submodules:
87100

88101
```bash
89102
git clone https://github.com/private-octopus/picoquic.git /path/to/picoquic

0 commit comments

Comments
 (0)