# CMake Error: include could not find requested file: WebKitCommon

**URL:** https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645
**Category:** Code
**Tags:** os:linux, gen:makefiles, gen:ninja
**Created:** [December 15, 2023, 8:45pm UTC](https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645 "2023-12-15T20:45:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Raphy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/raphy/32/4087_2.png) [@Raphy](https://discourse.cmake.org/u/Raphy)
#### Post date: [December 15, 2023, 8:45pm UTC](https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645/1 "2023-12-15T20:45:42Z")

</div>

I compiled and installed in Ubuntu 22.04 **WebKitGTK** : [BuildingGtk – WebKit](https://trac.webkit.org/wiki/BuildingGtk#BuildingWebKitGTKfromareleasetarball)

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](https://drive.google.com/file/d/1MBR22aYzs9IdbTZ_eyc02zBPUm41Go6x/view?usp=drive_link)

What do I have to do to correctly include webkitgtk in another CmakeLists.txt in order to download it and build it locally?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 15, 2023, 8:51pm UTC](https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645/2 "2023-12-15T20:51:57Z")

</div>

I see you also posted this question on StackOverflow. See my answer there: [c++ - CMake Error: include could not find requested file: WebKitCommon - Stack Overflow](https://stackoverflow.com/questions/77668705/cmake-error-include-could-not-find-requested-file-webkitcommon/77668761#77668761)

---

<div class="post-metadata">

### Author: ![Raphy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/raphy/32/4087_2.png) [@Raphy](https://discourse.cmake.org/u/Raphy)
#### Post date: [December 15, 2023, 8:58pm UTC](https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645/3 "2023-12-15T20:58:43Z")

</div>

Thank you Craig

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 19, 2023, 3:49am UTC](https://discourse.cmake.org/t/cmake-error-include-could-not-find-requested-file-webkitcommon/9645/4 "2023-12-19T03:49:33Z")

</div>

> [@Raphy](#):
>
> `set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Source/cmake")`

For those too lazy to go to SO, this is the problematic line in WebKitGTK (I picked it out before seeing this was already answered). See the SO link above for details.
