I am building an app using CMake and wxwidgets. The issue I am facing is that I can’t compile my app in release mode because is using the debug libs. I don’t know how to set the directories to look for in different places depending on the compiling mode.
My current CMake is:
cmake_minimum_required(VERSION 3.18)
message(STATUS "Building SUN")
set(wxWidgets_USE_DEBUG ON)
set(wxWidgets_USE_UNICODE ON)
set(wxWidgets_ROOT_DIR C:/wx314_install/Debug)
set(wxWidgets_LIB_DIR C:/wx314_install/Debug/lib/vc_x64_lib)
set(wxWidgets_INCLUDE_DIRS C:/wx314_install/Debug/include)
message(STATUS "${wxWidgets_ROOT_DIR}")
# Note that for MinGW users the order of libs is important!
find_package(wxWidgets REQUIRED net gl core base)
include(${wxWidgets_USE_FILE})
add_executable(app WIN32)
target_sources(app PRIVATE
src/app.cpp)
target_link_libraries(app PRIVATE ${wxWidgets_LIBRARIES})
As you can see, I have the wxwidgets directories links to the Debug folder, I have another folder called Release where I have the release binaries of CMake.
How can I set the different wxwidgets variables to use one or other binaries to compile my project?
I am doing the exact same thing with OpenCV. That was one hell of a job because I am using many libraries for different executables and libraries and trying to identify all of them was a bit tuff.
Here is the example:
That is done for each .lib file. The example that you wrote it’s for a whole directory instead? I would like to avoid doing 100 lines in CMake to populate each .lib.
No, my example is per-library. However, OpenCV uses CMake and should be installing its own opencv-config.cmake file that you can use directly with find_package(OpenCV).
Yes, same as wxWidgets, but currently the setup that was made by a another guy that is not here, it was badly done. So I am refactoring the whole project setup at the moment.