Skip to content

Commit

Permalink
⚙️ Reduce goldilock default build by introducing BUILD_TESTING and ma…
Browse files Browse the repository at this point in the history
…king tests builds optional.

When HFC provisions goldilock on a platform where pre-released binaries are
incompatible, it builds with default CMake flags, which did build all test
with it which is wasteful in such scenario.

CMake common practice is to rely on BUILD_TESTING, which would be
automatically defined  when doing `include(CTest)`, this would
however set a BUILD_TESTING option with the default to ON
 - c.f. https://cmake.org/cmake/help/latest/module/CTest.html

We think that especially for goldilock which is more like a dependency
than a main project being worked on for it's main target audience we
prefer BUILD_TESTING being OFF by default.
  • Loading branch information
daminetreg committed Feb 10, 2025
1 parent 9fd76b4 commit 869133a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v2
- name: install and build
run: |
cmake -S . -B build/macos -DCMAKE_TOOLCHAIN_FILE=environments/macos-clang-cxx17.cmake -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build/macos -DCMAKE_TOOLCHAIN_FILE=environments/macos-clang-cxx17.cmake -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build/macos
cd build/macos/ && cpack -G ZIP
- name: Upload goldilock package
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
- uses: actions/checkout@v2
- name: install and build
run: |
cmake -S . -B build/macos -DCMAKE_TOOLCHAIN_FILE=environments/macos-clang-cxx17.cmake -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build/macos -DCMAKE_TOOLCHAIN_FILE=environments/macos-clang-cxx17.cmake -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build/macos
cd build/macos/
cpack -G ZIP
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- name: install and build
run: |
tipi run cmake -S . -B build/linux -GNinja -DCMAKE_TOOLCHAIN_FILE=environments/linux-clang-cxx17-static.cmake -DCMAKE_BUILD_TYPE=Release
tipi run cmake -S . -B build/linux -GNinja -DCMAKE_TOOLCHAIN_FILE=environments/linux-clang-cxx17-static.cmake -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release
tipi run cmake --build build/linux
cd build/linux/
tipi run cpack -G ZIP
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ project(goldilock
LANGUAGES CXX
)

enable_testing()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -47,4 +45,10 @@ target_include_directories(libgoldilock-utils INTERFACE
)

add_subdirectory(src)
add_subdirectory(test)

# BUILD_TESTING is CTest module's default, but we prefer it OFF by default
# Instead of include(CTest) we check on the option ourselves.
if (BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,23 @@ Usage:
Building
--------

Build using `tipi` (substitute the toolchain your platform of choice e.g. `windows-cxx17` or `vs-16-2019-win64-cxx17` etc...)
By using the provided `cmake` build system:

```shell
tipi . -t linux-cxx17
cmake -S . -B build/linux -GNinja -DBUILD_TESTING=ON
cmake --build build/linux
```

... or by using the provided `cmake` build system:
Developing the project
--------
If you plan to develop the project and contribute to it, you will need to enable `-DBUILD_TESTING=ON`.

```shell
mkdir -p build/linux
cmake -S . -B build/linux -GNinja -DCMAKE_TOOLCHAIN_FILE=environments/linux-clang-cxx17.cmake
cmake -S . -B build/linux -GNinja -DBUILD_TESTING=ON
cmake --build build/linux
```


License
-------

`goldilock` is available under a proprietary license or subject to GPLv2 licence as per your choice. Please contact [tipi technologies Ltd.](https://tipi.build/) for commercial options.
`goldilock` is available under a proprietary license or subject to GPLv2 licence as per your choice. Please contact [tipi technologies Ltd.](https://tipi.build/) for more details.

0 comments on commit 869133a

Please sign in to comment.