Skip to content

Commit

Permalink
Add debug builds to CI (#36)
Browse files Browse the repository at this point in the history
* Build debug, correctly handle CMAKE_BUILD_TYPE

* Update README to reflect new flag for release builds

* Bump CMAKE min version to 3.5 to address deprecation warnings

* Mark val as [[maybe_unused]] to remove warnings when compiling in release mode

* Improve wording re: release and debug builds

* Update README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
damianhxy and coderabbitai[bot] authored May 24, 2024
1 parent 5c510f3 commit deee5f7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release]
build_type: [Release, Debug]

steps:
- uses: actions/checkout@v4
Expand Down
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)

project(autolab-cli)

Expand All @@ -11,15 +11,20 @@ set(variant "" CACHE STRING "build variant")
# command line options
option(release "build release version (no debug output)" OFF)

if(NOT release)
# build debug
set(CMAKE_BUILD_TYPE Debug)
# Existing CMAKE_BUILD_TYPE takes priority if directly defined
if(NOT CMAKE_BUILD_TYPE)
if(release)
set(CMAKE_BUILD_TYPE Release)
else()
set(CMAKE_BUILD_TYPE Debug)
endif()
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(PRINT_DEBUG TRUE)
else(NOT release)
# build release
set(CMAKE_BUILD_TYPE Release)
else()
set(PRINT_DEBUG FALSE)
endif(NOT release)
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build variant: ${variant}")
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ This will move our autocompletion script out of a local folder and into the bash

#### Release vs Debug

There are two kinds of builds available: release and non-release. Release builds do not contain debug output (output that use Logger::debug).
There are two kinds of builds available: release and debug. Release builds do not contain debug output (output that use `Logger::debug`).

The default is non-release builds. To build a release version, when inside the 'build' directory, run `cmake -Drelease=ON ..` (note the periods at the end), then run `make`.
The default is debug builds. To build a release version, when inside the 'build' directory, run `cmake -DCMAKE_BUILD_TYPE=Release ..` (note the periods at the end), then run `make`.
Alternatively (but less preferable), you can use the flag `-Drelease=ON`.

#### Build Variant

Expand Down
2 changes: 1 addition & 1 deletion lib/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Logger {
};
struct debug_logger {
template<class T>
debug_logger &operator<<(T val) {
debug_logger &operator<<([[maybe_unused]] T val) {
#ifdef PRINT_DEBUG
std::cout << val;
#endif
Expand Down

0 comments on commit deee5f7

Please sign in to comment.