Skip to content

Commit

Permalink
fix: it is best to define log domain in CFLAGS
Browse files Browse the repository at this point in the history
Otherwise all source files need to include config.h, which is
cumbersome. Fail to do this and debug logs lose default domain.
  • Loading branch information
abelcheung committed Dec 11, 2023
1 parent a88166b commit db7c56b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ if(DEFINED CMAKE_C_FLAGS_DEBUG)
else()
set(CMAKE_C_FLAGS_DEBUG "-O0 -Wextra")
endif()
if(DEFINED CMAKE_C_FLAGS)
string(APPEND CMAKE_C_FLAGS " -Wall -Werror")
else()
set(CMAKE_C_FLAGS "-Wall -Werror")
if(NOT DEFINED CMAKE_C_FLAGS)
set(CMAKE_C_FLAGS "")
endif()
string(APPEND CMAKE_C_FLAGS
" -DG_LOG_DOMAIN=\\\"${PROJECT_NAME}\\\" -Wall -Werror")

set(CMAKE_STATIC_LINKER_FLAGS "-static")

Expand Down
5 changes: 4 additions & 1 deletion src/config.h.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _RIFIUTI2_CONFIG_H
#define _RIFIUTI2_CONFIG_H

#cmakedefine PROJECT_NAME "@PROJECT_NAME@"
#cmakedefine PROJECT_VERSION "@PROJECT_VERSION@"
#cmakedefine PROJECT_DESCRIPTION "@PROJECT_DESCRIPTION@"
Expand All @@ -6,4 +9,4 @@
#cmakedefine PROJECT_TOOL_USAGE_URL "@PROJECT_TOOL_USAGE_URL@"
#cmakedefine PROJECT_GH_PAGE "@PROJECT_GH_PAGE@"

#define G_LOG_DOMAIN PROJECT_NAME
#endif

0 comments on commit db7c56b

Please sign in to comment.