bfabiszewski/libmobi

enabling MOBI_DEBUG on Windows

davesworking opened this issue · 2 comments

I am getting a CMake error if I enable MOBI_DEBUG on Windows (VS 2022):

cl : command line error D8021: invalid numeric argument '/Wextra'

CMake support is experimental and was never tested with msvc.
I can't test it here but I guess following patch should let you go on.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6079fb..6e28bc2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,7 +61,9 @@ endif(USE_XMLWRITER)

 if(MOBI_DEBUG)
     add_definitions(-DMOBI_DEBUG)
-    add_compile_options(-pedantic -Wall -Wextra -Werror)
+    if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+        add_compile_options(-pedantic -Wall -Wextra -Werror)
+    endif()
 endif(MOBI_DEBUG)

 if(MOBI_DEBUG_ALLOC)

Thanks!