Skip to content

Commit

Permalink
cmake: Add DEVELOPER_BUILD define
Browse files Browse the repository at this point in the history
So we can add code we don't want in production
  • Loading branch information
iamsergio committed Oct 5, 2024
1 parent 88aff29 commit dfce2ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
cmake_minimum_required(VERSION 3.21)
project(qtwidgets_basic)

option(DEVELOPER_BUILD "Enable DEVELOPER_BUILD (tests, helper code, etc)" OFF)

set(CMAKE_CXX_STANDARD 23)

set(CMAKE_AUTOMOC ON)
Expand Down Expand Up @@ -50,8 +52,10 @@ endif()
message(
"FLUTTER_ENGINE_LIBRARY=$ENV{FLUTTER_ENGINE_FOLDER}/${FLUTTER_ENGINE_LIBRARY}"
)
message(${FLUTTER_ENGINE_INCLUDE_DIR})
include_directories(${FLUTTER_ENGINE_INCLUDE_DIR})

include_directories(
${FLUTTER_ENGINE_INCLUDE_DIR}
"$ENV{FLUTTER_ENGINE_FOLDER}/shell/platform/common/client_wrapper/include")

if(ENABLE_ASAN)
add_compile_options(-fsanitize=address -fsanitize=undefined)
Expand All @@ -70,6 +74,10 @@ endif()
target_compile_definitions(qtembedder
PRIVATE FLUTTER_ICUDTL_DIR="${CMAKE_BINARY_DIR}")

if(DEVELOPER_BUILD)
target_compile_definitions(qtembedder PRIVATE DEVELOPER_BUILD)
endif()

# ICU
find_program(FLUTTER_EXE flutter REQUIRED)
message(STATUS "Flutter SDK: ${FLUTTER_EXE}")
Expand Down
11 changes: 3 additions & 8 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"DEVELOPER_BUILD": "ON"
},
"environment": {
"CXX": "clang++",
Expand All @@ -18,16 +19,10 @@
{
"name": "dev-asan",
"description": "dev-asan",
"generator": "Ninja",
"inherits": "dev",
"binaryDir": "${sourceDir}/build-dev-asan",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"ENABLE_ASAN": "ON"
},
"environment": {
"CXX": "clang++",
"CC": "clang"
}
},
{
Expand Down

0 comments on commit dfce2ae

Please sign in to comment.