# Could not find a package configuration file provided by "wxWidgets"

**URL:** https://discourse.cmake.org/t/could-not-find-a-package-configuration-file-provided-by-wxwidgets/9777
**Category:** Usage
**Tags:** os:linux, gen:makefiles
**Created:** [January 5, 2024, 2:28pm UTC](https://discourse.cmake.org/t/could-not-find-a-package-configuration-file-provided-by-wxwidgets/9777 "2024-01-05T14:28:32Z")
**Posts on this page:** 2
**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: [January 5, 2024, 2:28pm UTC](https://discourse.cmake.org/t/could-not-find-a-package-configuration-file-provided-by-wxwidgets/9777/1 "2024-01-05T14:28:32Z")

</div>

Hi!

To start using wxWidgets in Ubuntu 23.10, I compiled and built the `minimum` sample : [https://github.com/wxWidgets/wxWidgets/blob/master/samples/minimal/](https://github.com/wxWidgets/wxWidgets/blob/master/samples/minimal/) with wx-config:

```auto
raphy@raohy:~/MyPrj$ g++ `wx-config --cxxflags` -o myprj ./src/*.cpp `wx-config --libs`
raphy@raohy:~/MyPrj$ ./myprj

```

Now I would like to convert this command-line compilation and building into a CMake one

I used the CMakeLists.txt file provided in the `samples` code: [https://github.com/wxWidgets/wxWidgets/blob/master/samples/minimal/CMakeLists.txt](https://github.com/wxWidgets/wxWidgets/blob/master/samples/minimal/CMakeLists.txt) where I added these two lines:  
`set(wxBUILD_SAMPLES ON)`  
and  
` set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr/local/lib/wx)`  
:

```auto
cmake_minimum_required(VERSION 3.24)

if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
    # If no deployment target has been set default to the minimum supported
    # OS version (this has to be set before the first project() call)
    if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
        set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0 CACHE STRING "iOS Deployment Target")
    else()
        set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10 CACHE STRING "macOS Deployment Target")
    endif()
endif()

# Name the project
project(minimal)

set(CMAKE_CXX_STANDARD 11 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr/local/lib/wx)

set(wxBUILD_SAMPLES ON)

# Request the required wxWidgets libs
find_package(wxWidgets 3.3 COMPONENTS core base REQUIRED CONFIG)

# Include the wxWidgets use file to initialize various settings
if(wxWidgets_USE_FILE)
    include(${wxWidgets_USE_FILE})
endif()

# Define a variable containing a list of source files for the project
set(SRC_FILES
    src/minimal.cpp
    )

if(WIN32)
    # Include a RC file for windows
    list(APPEND SRC_FILES ./sample.rc)
elseif(APPLE)
    # Add an icon for the apple .app file
    list(APPEND SRC_FILES ./src/osx/carbon/wxmac.icns)
endif()

# Define the build target for the executable
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE ${SRC_FILES})
# Link required libraries to the executable
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})

if(APPLE)
    set_target_properties(${PROJECT_NAME} PROPERTIES
        RESOURCE "./src/icons/wxmac.icns"
        MACOSX_BUNDLE_ICON_FILE wxmac.icns
        MACOSX_BUNDLE_COPYRIGHT "Copyright wxWidgets"
        MACOSX_BUNDLE_GUI_IDENTIFIER "org.wxwidgets.minimal"
        )
endif()

```

But I get this error:

```auto
raphy@raohy:~/MyPrj$ cmake -B builddir
-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 13.2.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
-- 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
CMake Error at CMakeLists.txt:48 (find_package):
  Could not find a package configuration file provided by "wxWidgets"
  (requested version 3.3) with any of the following names:

    wxWidgetsConfig.cmake
    wxwidgets-config.cmake

  Add the installation prefix of "wxWidgets" to CMAKE_PREFIX_PATH or set
  "wxWidgets_DIR" to a directory containing one of the above files. If
  "wxWidgets" provides a separate development package or SDK, be sure it has
  been installed.

-- Configuring incomplete, errors occurred!

```

How to make it work?

---

<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: [January 5, 2024, 3:11pm UTC](https://discourse.cmake.org/t/could-not-find-a-package-configuration-file-provided-by-wxwidgets/9777/2 "2024-01-05T15:11:18Z")

</div>

I solved jusy modifying the `find_package` line in this way:

`find_package(wxWidgets 3.3 REQUIRED COMPONENTS core base)`  
and setting the cxx\_standard : `set(CMAKE_CXX_STANDARD 11)`

```auto
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/raphy/MyPrj/builddir
raphy@raohy:~/MyPrj$ cmake --build builddir
[50%] Building CXX object CMakeFiles/minimal.dir/src/minimal.cpp.o
[100%] Linking CXX executable minimal
[100%] Built target minimal
raphy@raohy:~/MyPrj$ ./builddir/

```
