-
This commit is contained in:
@@ -4,10 +4,88 @@ project(rktwebview LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(GIT_EXECUTABLE git)
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
include_directories(../webview/core/include)
|
||||
include_directories(../webview/build/Release/_deps/microsoft_web_webview2-src/build/native/include)
|
||||
link_directories(../webview/build/Release/core)
|
||||
set(WEBVIEW_BUILD_STATIC_LIBRARY ON)
|
||||
set(WEBVIEW_WEBKITGTK_API "6.0")
|
||||
#set(WEBVIEW_WEBKITGTK_PREFERRED_API_LIST webkitgtk-6.0)
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(LIBKIND "d")
|
||||
else()
|
||||
set(LIBKIND "r")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(LIBEXT lib)
|
||||
set(LIBPRE )
|
||||
else()
|
||||
set(LIBEXT a)
|
||||
set(LIBPRE lib)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# using Clang
|
||||
add_compile_options(-fPIC)
|
||||
set(CFLAGS_ENV "CFLAGS=-fPIC")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# using GCC
|
||||
add_compile_options(-fPIC)
|
||||
set(CFLAGS_ENV "CFLAGS=-fPIC")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
# using Intel C++
|
||||
set(CFLAGS_ENV "")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
set(CFLAGS_ENV "")
|
||||
endif()
|
||||
|
||||
if(NOT(EXISTS ./deps))
|
||||
file(MAKE_DIRECTORY ./deps)
|
||||
endif()
|
||||
|
||||
function(git_dep dir dep)
|
||||
if(EXISTS ${rktwebview_SOURCE_DIR}/deps/${dir})
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} pull
|
||||
COMMAND_ECHO STDOUT
|
||||
WORKING_DIRECTORY ${rktwebview_SOURCE_DIR}/deps/${dir}
|
||||
)
|
||||
else()
|
||||
message("Executing git clone...")
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} clone ${dep} ${rktwebview_SOURCE_DIR}/deps/${dir}
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
git_dep(webview https://github.com/webview/webview.git)
|
||||
add_subdirectory(deps/webview)
|
||||
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED gtk+-3.0)
|
||||
|
||||
include_directories(${GTK_INCLUDE_DIRS})
|
||||
message("${GTK_INCLUDE_DIRS}")
|
||||
link_directories(${GTK_LIBRARY_DIRS})
|
||||
|
||||
pkg_check_modules(GTKWEBVIEW REQUIRED webkit2gtk-4.1)
|
||||
include_directories(${GTKWEBVIEW_INCLUDE_DIRS})
|
||||
message("${GTKWEBVIEW_INCLUDE_DIRS}")
|
||||
link_directories(${GTKWEBVIEW_LIBRARY_DIRS})
|
||||
endif()
|
||||
|
||||
include_directories(deps/webview/core/include)
|
||||
include_directories(deps/webview/build/Release/_deps/microsoft_web_webview2-src/build/native/include)
|
||||
link_directories(build/Release/deps/webview/core)
|
||||
link_directories(build/Release)
|
||||
|
||||
add_library(rktwebview SHARED
|
||||
@@ -15,18 +93,31 @@ add_library(rktwebview SHARED
|
||||
rktwebview.cpp
|
||||
rktwebview.h
|
||||
|
||||
|
||||
json.h
|
||||
json.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(rktwebview_test
|
||||
main.cpp
|
||||
|
||||
rktwebview_global.h
|
||||
rktwebview.cpp
|
||||
rktwebview.h
|
||||
|
||||
json.h
|
||||
json.cpp
|
||||
)
|
||||
|
||||
#add_dependencies(rktwebview webview)
|
||||
|
||||
target_link_libraries(rktwebview webview_static)
|
||||
target_link_libraries(rktwebview_test rktwebview)
|
||||
target_link_libraries(rktwebview webview_core_static)
|
||||
#target_link_libraries(rktwebview_test rktwebview)
|
||||
target_link_libraries(rktwebview_test webview_core_static)
|
||||
|
||||
target_compile_definitions(rktwebview PRIVATE RKTWEBVIEW_LIBRARY)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
target_link_libraries(rktwebview ${GTK_LIBRARIES} ${GTKWEBVIEW_LIBRARIES})
|
||||
target_link_libraries(rktwebview_test ${GTK_LIBRARIES} ${GTKWEBVIEW_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user