From 5c8ac8f3606d9c84588ff64f57b86b74c48a7c7d Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Tue, 21 May 2024 23:17:47 -0600 Subject: [PATCH 1/6] Build debug, correctly handle CMAKE_BUILD_TYPE --- .github/workflows/cmake-multi-platform.yml | 2 +- CMakeLists.txt | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index da0a67a..88951a9 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest] - build_type: [Release] + build_type: [Release, Debug] steps: - uses: actions/checkout@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9528507..ee103d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") From a72afddf2ddd4ba2c0bdf29ae6341983a08af051 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Thu, 23 May 2024 19:26:26 -0600 Subject: [PATCH 2/6] Update README to reflect new flag for release builds --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4bb5b8a..a1bec63 100644 --- a/README.md +++ b/README.md @@ -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 non-release. 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 non-release 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 From b5dfbeb1b1bb5f5886d86c886cb868705eaa0d3b Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Thu, 23 May 2024 19:34:33 -0600 Subject: [PATCH 3/6] Bump CMAKE min version to 3.5 to address deprecation warnings --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee103d3..46f1a10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5) project(autolab-cli) From 19cb0d75f742666ebde88267285b314f32b2f8f0 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Thu, 23 May 2024 19:35:23 -0600 Subject: [PATCH 4/6] Mark val as [[maybe_unused]] to remove warnings when compiling in release mode --- lib/logger/logger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/logger/logger.h b/lib/logger/logger.h index 142da9a..90fbc4e 100644 --- a/lib/logger/logger.h +++ b/lib/logger/logger.h @@ -73,7 +73,7 @@ namespace Logger { }; struct debug_logger { template - debug_logger &operator<<(T val) { + debug_logger &operator<<([[maybe_unused]] T val) { #ifdef PRINT_DEBUG std::cout << val; #endif From 577c2ae6023ece31c6b22607b25effb29ff1e7f5 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Thu, 23 May 2024 19:53:59 -0600 Subject: [PATCH 5/6] Improve wording re: release and debug builds --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1bec63..41ad9b6 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,9 @@ 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 -DCMAKE_BUILD_TYPE=Release ..` (note the periods at the end), then run `make`. +The default are 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 From 18fc27eed37452ac764e5c3768701dab7ed43422 Mon Sep 17 00:00:00 2001 From: Damian Ho Date: Thu, 23 May 2024 19:59:35 -0600 Subject: [PATCH 6/6] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41ad9b6..93b760b 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ This will move our autocompletion script out of a local folder and into the bash There are two kinds of builds available: release and debug. Release builds do not contain debug output (output that use `Logger::debug`). -The default are 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`. +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