@@ -50,6 +50,25 @@ endif()
5050
5151include (CMakeDependentOption)
5252
53+ # check linux system libraries
54+ if (LINUX)
55+ find_package (X11 REQUIRED)
56+
57+ # including GTK3.0 and WebKit2Gtk4.x
58+ find_package (PkgConfig REQUIRED)
59+ pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
60+
61+ set (_webkit2gtk_vers "4.1;4.0" )
62+
63+ foreach (_ver ${_webkit2gtk_vers} )
64+ pkg_check_modules(WEBKIT2GTK webkit2gtk-${_ver} )
65+
66+ if (WEBKIT2GTK_LIBRARY_DIRS)
67+ break ()
68+ endif ()
69+ endforeach ()
70+ endif ()
71+
5372set (AX_RENDER_API "auto" CACHE STRING "Specify axmol graphics render API" )
5473set_property (CACHE AX_RENDER_API PROPERTY STRINGS d3d11 d3d12 vk mtl gl)
5574
@@ -406,6 +425,10 @@ ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_VR)
406425ax_config_pred(${_AX_CORE_LIB} AX_CORE_PROFILE)
407426ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_WAYLAND)
408427
428+ if (LINUX AND WEBKIT2GTK_FOUND)
429+ target_compile_definitions (${_AX_CORE_LIB} PUBLIC AX_HAVE_WEBKIT2GTK=1)
430+ endif ()
431+
409432# add base macro define and compile options
410433use_ax_compile_define(${_AX_CORE_LIB} )
411434use_ax_compile_options(${_AX_CORE_LIB} )
@@ -548,29 +571,29 @@ if(ANDROID)
548571 target_link_libraries (${_AX_CORE_LIB} ${AX_LUA_ENGINE} )
549572 endif ()
550573 endif ()
551- endif ()
552-
553- if (LINUX)
554- find_package (X11 REQUIRED)
574+ elseif (LINUX)
555575 target_include_directories (${_AX_CORE_LIB} PUBLIC "${X11_X11_INCLUDE_PATH} " )
556576
557- # X11 gets linked by cmake/Modules/AXLinkHelpers.cmake
558-
559- # including GTK3.0 and WebKit2Gtk4.x
560- find_package (PkgConfig REQUIRED)
561- pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
562-
563- set (_webkit2gtk_vers "4.1;4.0" )
564-
565- foreach (_ver ${_webkit2gtk_vers} )
566- pkg_check_modules(WEBKIT2GTK webkit2gtk-${_ver} )
567-
568- if (WEBKIT2GTK_LIBRARY_DIRS)
569- break ()
577+ # remove system freetype2 due to we already embed freetype
578+ set (_gtk_includes "" )
579+ set (_filtered_freetype FALSE )
580+ foreach (dir IN LISTS GTK3_INCLUDE_DIRS)
581+ if (NOT dir MATCHES "freetype2" )
582+ list (APPEND _gtk_includes "${dir} " )
583+ else ()
584+ set (_filtered_freetype TRUE )
570585 endif ()
571586 endforeach ()
572587
573- target_include_directories (${_AX_CORE_LIB} PUBLIC ${GTK3_INCLUDE_DIRS} ${WEBKIT2GTK_INCLUDE_DIRS} )
574- target_link_directories (${_AX_CORE_LIB} PRIVATE ${GTK3_LIBRARY_DIRS} ${WEBKIT2GTK_LIBRARY_DIRS} )
575- target_link_libraries (${_AX_CORE_LIB} ${GTK3_LIBRARIES} ${WEBKIT2GTK_LIBRARIES} )
576- endif ()
588+ if (_filtered_freetype)
589+ message (STATUS "GTK3: filtered out system freetype include directory" )
590+ endif ()
591+
592+ target_include_directories (${_AX_CORE_LIB} PUBLIC ${_gtk_includes} )
593+ target_link_directories (${_AX_CORE_LIB} PRIVATE ${GTK3_LIBRARY_DIRS} )
594+
595+ if (WEBKIT2GTK_FOUND)
596+ target_include_directories (${_AX_CORE_LIB} PUBLIC ${WEBKIT2GTK_INCLUDE_DIRS} )
597+ target_link_libraries (${_AX_CORE_LIB} ${WEBKIT2GTK_LIBRARIES} )
598+ endif ()
599+ endif ()
0 commit comments