MichaelKim/webview

"Define one of WEBVIEW_WIN, WEBVIEW_MAC, or WEBVIEW_GTK" when compiling on Windows

frabert opened this issue · 1 comments

I receive this error message when compiling on windows.
This is my CMakeLists.txt:

add_library(reacomments SHARED)

if(APPLE)
    target_compile_definitions(reacomments PRIVATE "WEBVIEW_MAC")
    target_compile_options(reacomments PRIVATE "-ObjC++")

    find_library(COCOA_LIBRARY Cocoa)
    find_library(WEBKIT_LIBRARY Webkit)
    target_link_libraries(reacomments PRIVATE ${COCOA_LIBRARY} ${WEBKIT_LIBRARY})
elseif(WIN32)
    target_compile_definitions(reacomments PRIVATE "WEBVIEW_WIN")
    target_link_libraries(reacomments PRIVATE "WindowsApp.lib" "user32.lib" "kernel32.lib")
else()
    target_compile_definitions(reacomments PRIVATE "WEBVIEW_GTK")

    find_package(PkgConfig REQUIRED)
    pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
    pkg_check_modules(WEBKIT2 REQUIRED webkit2gtk-4.0)
    target_include_directories(reacomments PRIVATE ${GTK3_INCLUDE_DIRS} ${WEBKIT2_INCLUDE_DIRS})
    target_link_libraries(reacomments PRIVATE ${GTK3_LIBRARIES} ${WEBKIT2_LIBRARIES})
endif()

target_compile_features(reacomments PRIVATE cxx_std_17)
target_sources(reacomments
    PRIVATE
        ${CMAKE_CURRENT_LIST_DIR}/src/entry.cpp
)

entry.cpp is just #include "webview.hpp"

Odd thing: replacing target_compile_definitions(reacomments PRIVATE "WEBVIEW_WIN") with WEBVIEW_GTK or WEBVIEW_MAC makes the preprocessor error go away, though it will obviously fail to compile. I can't understand why the compiler doesn't seem to recognize the WEBVIEW_WIN definition.
Also, adding a #define WEBVIEW_WIN before the #include generates a warning that the symbol is being redefined, so the definition does make its way to the compiler somehow.

Solved: too many edits on my part :)