From 9b09abe274cbe8e31d673236ff6982f3dc931c83 Mon Sep 17 00:00:00 2001 From: Bertrand Darbon Date: Tue, 28 Sep 2021 13:55:30 +0200 Subject: [PATCH] fix(cmake): error in FindFilesystem (#1035) When building an application on Windows using Drogon as a dependency and with warnings treated as errors, the FindFilesystem.cmake generates this error (in CMakeError.log): ``` src.cxx(6): error C2220: the following warning is treated as an error src.cxx(6): warning C4477: 'printf' : format string '%s' requires an argument of type 'char *', but variadic argument 1 has type 'const std::filesystem::path::value_type *' src.cxx(6): note: consider using '%ls' in the format string src.cxx(6): note: consider using '%lls' in the format string src.cxx(6): note: consider using '%Ls' in the format string src.cxx(6): note: consider using '%ws' in the format string ``` Documentation of std::filesystem::path: value_type: character type used by the native encoding of the filesystem: char on POSIX, wchar_t on Windows Using generic_string() fixes this warning --- cmake_modules/FindFilesystem.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_modules/FindFilesystem.cmake b/cmake_modules/FindFilesystem.cmake index 4f51b53f..c8d9a57f 100644 --- a/cmake_modules/FindFilesystem.cmake +++ b/cmake_modules/FindFilesystem.cmake @@ -199,7 +199,7 @@ if(CXX_FILESYSTEM_HAVE_FS) int main() { auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path(); - printf("%s", cwd.c_str()); + printf("%s", cwd.generic_string().c_str()); return EXIT_SUCCESS; } ]] code @ONLY)