I am building a C++ CMake application and I can't get the wxWidgets library to link correctly to the executable.
When I build it in Visual Studio 2022 on Windows, the FFTW3 and SDL2 .dll
files are in the same directory as the executable, however, wxWidgets .dll
files are not. Therefore, after running the executable, an error message appears that wxWidgets .dll
files are missing. They are in their separate /libs/wxWidgets/libs/.../*.dll
directory, but they are not linked to the executable.
I added the libraries as git submodules in my project and I am building them from source. Therefore, I am adding them using add_subdirectory
and include_directories
.
I am relatively new to this and I don't know what I am doing wrong. Any help would be very much appreciated!
This is my CMakeLists.txt file:
cmake_minimum_required(VERSION 3.21)
if (UNIX)
enable_language(OBJCXX)
endif (UNIX)
project(my_app LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(libs/SDL)
include_directories(libs/SDL/include)
add_subdirectory(libs/fftw3)
include_directories(libs/fftw3/api)
add_subdirectory(libs/wxWidgets)
include_directories(libs/wxWidgets/include)
add_executable(my_app WIN32 main.cpp ...)
target_link_libraries(my_app PRIVATE SDL2 fftw3 wx::net wx::core wx::base)