Skip to content

Commit 3f56b9c

Browse files
committed
Update CMakeLists.txt for fixes warning -Wundef
Signed-off-by: Yonggang Luo <[email protected]>
1 parent 523ade1 commit 3f56b9c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ add_library("printf::printf" ALIAS printf)
8484
set(GENERATED_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
8585
configure_file("printf_config.h.in" "${GENERATED_INCLUDE_DIR}/printf_config.h" @ONLY)
8686
target_sources(printf PRIVATE src/printf/printf.c "${GENERATED_INCLUDE_DIR}/printf_config.h" src/printf/printf.h)
87-
target_compile_definitions(printf PRIVATE PRINTF_INCLUDE_CONFIG_H)
87+
target_compile_definitions(printf PRIVATE PRINTF_INCLUDE_CONFIG_H=1)
8888
target_include_directories(printf PRIVATE "$<BUILD_INTERFACE:${GENERATED_INCLUDE_DIR}>")
8989

9090
if (BUILD_SHARED_LIBS)
@@ -121,6 +121,7 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
121121
-ansi
122122
-Wno-long-long
123123
-Werror=declaration-after-statement
124+
-Werror=undef
124125
)
125126
set_target_properties(printf PROPERTIES C_STANDARD 90)
126127
set_target_properties(printf PROPERTIES C_STANDARD_REQUIRED ON)

test/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ foreach(tgt ${test_targets})
2525
endif()
2626
endforeach()
2727

28+
target_compile_definitions(autotest PRIVATE PRINTF_INCLUDE_CONFIG_H=0)
2829
add_executable(aliasing "aliasing.c")
30+
target_compile_definitions(aliasing PRIVATE PRINTF_INCLUDE_CONFIG_H=0)
2931
set_target_properties(
3032
${tgt}
3133
PROPERTIES
@@ -88,7 +90,7 @@ if (TARGET test_suite)
8890
# These two lines are necessary, since the test suite does not actually use the
8991
# compiled library - it includes the library's source .c file; and that means we
9092
# need to include the generated config.h file.
91-
target_compile_definitions(test_suite PRIVATE PRINTF_INCLUDE_CONFIG_H)
93+
target_compile_definitions(test_suite PRIVATE PRINTF_INCLUDE_CONFIG_H=1)
9294
target_include_directories(
9395
test_suite
9496
PRIVATE

0 commit comments

Comments
 (0)