I compiled and installed in Ubuntu 22.04 WebKitGTK : BuildingGtk – WebKit
Now I would like to do the same with find_package and FetchContent in another CmakeLists.txt in order to download it and build it locally:
cmake_minimum_required(VERSION 3.21)
project(my_application LANGUAGES CXX)
find_package(webkit2 QUIET)
if (NOT webkit2_FOUND)
message("webkit2 could not be located in CMake module search path. Downloading it,
and building it locally")
include(FetchContent)
FetchContent_Declare(
WebKit2
URL https://webkitgtk.org/releases/webkitgtk-2.42.3.tar.xz
)
FetchContent_MakeAvailable(webkit2)
endif(NOT webkit2_FOUND)
But I get this error:
cmake -B build
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
webkit2 could not be located in CMake module search path. Downloading it, and building it locally
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at build/_deps/webkit2-src/CMakeLists.txt:21 (include):
include could not find requested file:
WebKitCommon
CMake Error at build/_deps/webkit2-src/Source/bmalloc/CMakeLists.txt:698 (WEBKIT_FRAMEWORK_DECLARE):
Unknown CMake command "WEBKIT_FRAMEWORK_DECLARE".
-- Configuring incomplete, errors occurred!
See also "build/CMakeFiles/CMakeOutput.log"
/build/_deps
folder :
build/_deps$ ls -lah
total 20K
drwxrwxr-x 5 raphy raphy 4,0K dic 15 21:18 .
drwxrwxr-x 4 raphy raphy 4,0K dic 15 21:18 ..
drwxrwxr-x 4 raphy raphy 4,0K dic 15 21:18 webkit2-build
drwxrwxr-x 5 raphy raphy 4,0K dic 15 21:18 webkit2-src
drwxrwxr-x 4 raphy raphy 4,0K dic 15 21:18 webkit2-subbuild
The /build/_deps/webkit2-src/CMakeLists.txt
file contains the same include(WebKitCommon)
that is included in the CmakeLists.txt file of the https://webkitgtk.org/releases/webkitgtk-2.42.3.tar.xz
:
build/_deps/webkit2-src/CMakeLists.txt
:
cat build/_deps/webkit2-src/CMakeLists.txt
# -----------------------------------------------------------------------------
# Determine CMake version and build type.
# -----------------------------------------------------------------------------
# NOTE: cmake_minimum_required() and project() *MUST* be the two first commands
# used, see https://cmake.org/cmake/help/v3.3/command/project.html -- the
# latter in particular handles loading a bunch of shared CMake definitions
# and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
cmake_minimum_required(VERSION 3.16)
project(WebKit)
# Remove this cmake_policy() after upgrading cmake_minimum_required() to 3.20.
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
cmake_policy(SET CMP0116 OLD)
endif ()
# -----------------------------------------------------------------------------
# Common configuration
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
include(WebKitCommon)
# -----------------------------------------------------------------------------
# Enable API unit tests and create a target for the test runner
# -----------------------------------------------------------------------------
if (ENABLE_API_TESTS)
enable_testing()
endif ()
# -----------------------------------------------------------------------------
# Add module directories
# -----------------------------------------------------------------------------
add_subdirectory(Source)
# -----------------------------------------------------------------------------
# Add tools
# -----------------------------------------------------------------------------
if (ENABLE_TOOLS)
add_subdirectory(Tools)
endif ()
if (DEVELOPER_MODE)
add_subdirectory(PerformanceTests)
endif ()
# -----------------------------------------------------------------------------
# Print the features list last, for maximum visibility.
# -----------------------------------------------------------------------------
PRINT_WEBKIT_OPTIONS()
webkitgtk-2.42.3/CMakeLists.txt
:
raphy@raohy:~/webkitgtk-2.42.3$ cat CMakeLists.txt
# -----------------------------------------------------------------------------
# Determine CMake version and build type.
# -----------------------------------------------------------------------------
# NOTE: cmake_minimum_required() and project() *MUST* be the two first commands
# used, see https://cmake.org/cmake/help/v3.3/command/project.html -- the
# latter in particular handles loading a bunch of shared CMake definitions
# and loading the cross-compilation settings from CMAKE_TOOLCHAIN_FILE.
cmake_minimum_required(VERSION 3.16)
project(WebKit)
# Remove this cmake_policy() after upgrading cmake_minimum_required() to 3.20.
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20")
cmake_policy(SET CMP0116 OLD)
endif ()
# -----------------------------------------------------------------------------
# Common configuration
#------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")
include(WebKitCommon)
# -----------------------------------------------------------------------------
# Enable API unit tests and create a target for the test runner
# -----------------------------------------------------------------------------
if (ENABLE_API_TESTS)
enable_testing()
endif ()
# -----------------------------------------------------------------------------
# Add module directories
# -----------------------------------------------------------------------------
add_subdirectory(Source)
# -----------------------------------------------------------------------------
# Add tools
# -----------------------------------------------------------------------------
if (ENABLE_TOOLS)
add_subdirectory(Tools)
endif ()
if (DEVELOPER_MODE)
add_subdirectory(PerformanceTests)
endif ()
# -----------------------------------------------------------------------------
# Print the features list last, for maximum visibility.
# -----------------------------------------------------------------------------
PRINT_WEBKIT_OPTIONS()
This is the build/CMakeFiles/CMakeOutput.log
: CMakeOutput-log.txt - Google Drive
What do I have to do to correctly include webkitgtk in another CmakeLists.txt in order to download it and build it locally?