-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Hey!
I have this in my CMake files:
include(FetchContent)
FetchContent_Declare(
printf_library
GIT_REPOSITORY https://github.com/eyalroz/printf.git
GIT_TAG dd63281
)
set(BUILD_SHARED_LIBS OFF)
set(SUPPORT_EXPONENTIAL_SPECIFIERS OFF)
set(SUPPORT_MSVC_STYLE_INTEGER_SPECIFIERS OFF)
set(SUPPORT_LONG_LONG OFF)
set(USE_DOUBLE_INTERNALLY OFF)
set(SUPPORT_WRITEBACK_SPECIFIER OFF)
set(CHECK_FOR_NUL_IN_FORMAT_SPECIFIER ON)
set(ALIAS_STANDARD_FUNCTION_NAMES "SOFT")
FetchContent_MakeAvailable(printf_library)
Now when I include "printf/printf.h" in my code, the aliases are not working as expected. I have set the ALIAS_STANDARD_FUNCTION_NAMES to "SOFT", so I expected the aliasing to work in my code.
The problem is that "printf/printf.h" has this code:
#ifdef PRINTF_INCLUDE_CONFIG_H
#include "printf_config.h"
#endif
This works well when compiling the source file "printf/printf.c", since the CMakeLists.txt has the following line:
target_compile_definitions(printf PRIVATE PRINTF_INCLUDE_CONFIG_H)
However, this define does not carry over to my main project. That means that the "printf_config.h" will not be taken into account when I include "printf/printf.h". I think this is bad, since the library uses a different header internally compared to the header we can include in our projects. I tried solving it by defining PRINTF_INCLUDE_CONFIG_H in the main project, but then I get this error:
[build] In file included from C:/Users/mathi/Documents/kw/boomboard/cmake/stm32cubemx/../../Core/Inc/printer.h:2,
[build] from C:/Users/mathi/Documents/kw/boomboard/Core/Src/perf.cpp:4:
[build] C:/Users/mathi/Documents/kw/boomboard/build/Debug/_deps/printf_library-src/src/printf/printf.h:43:10: fatal error: printf_config.h: No such file or directory
[build] 43 | #include "printf_config.h"
[build] | ^~~~~~~~~~~~~~~~~
[build] compilation terminated.
What fixed it for me was defining PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_SOFT.
I think "printf_config.h" should be able to be included by the users. Or if the manual definition is the intended way the documentation should be made more clear.