Mingw32 CMake can't find wxWidgets
CMakeList.txt:
SET(myapp1_SRCS main.cpp) set(wxWidgets_CONFIGURATION mswu) find_package( wxWidgets COMPONENTS gl aui adv html core net base xml REQUIRED ) include(${wxWidgets_USE_FILE}) add_executable(${PROJECT_NAME} ${myapp1_SRCS}) target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})
wxWidgets are installed:
mingw32/mingw-w64-i686-wxWidgets 3.0.2-11 [installed] A C++ library that lets developers create applications for Windows, Linux and UNIX (mingw-w64)
Linking manually with wxWidgets works fine:
g++ main.cpp --static `wx-config --libs --static yes` `wx-config --cxxflags --static yes` -o app-static
But CMake's find_package can't find wxWidgets the same time.
Is it MSYS2 bug or I've made something wrong?
Is there any overcome how to make wxWidgets be found by CMake for mingw64-i686 on MSYS2?
You need use "wx-config" to get proper configuration for wxWidgets. Something like:
https://github.com/eranif/codelite/blob/master/CMakeLists.txt#L92
Alexey, thanks for suggestion. I had few more tries and now I'm a bit confused of mixing ming32 and msys.
Previously I ran
cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MinGW Makefiles" ../master
frommingw32_shell.bat
That made sense for me "MinGW Makefiles" in mingw32_shell and I had this error:
When I run
cmake -D CMAKE_CXX_COMPILER=g++.exe -G "MSYS Makefiles" ../master
frommingw32_shell.bat
That doesn't make sense from the first glance to run "MSYS Makefiles" from mingw32 shell.
I get success with CMake wxWidgets finder:
But after sucessful generation of "MSYS Makefiles" mingw32-make can't build the project:
So the strange things:
1) CMake can't generate "MinGW Makefiles" from ming32_shell
2) But it can generate "MSYS Makefiles" from mingw32_shell
3) Generated "MSYS Makefiles" doesn't build with mingw32-make from mingw32_shell
Last edit: Alex Zelid 2015-10-15
Generating "MinGW Makefiles" are needed only when you use "mingw32-make" not "make". Usually it need only when you run cmake from CMD instead MSYS2 shell.
"MinGW Makefiles" use some different syntax than regular Makefiles.
You MUST run "make" not "mingw32-make" for Makefiles generated with "MSYS Makefiles"
Generating CMAke's "MSYS Makefiles" + running "make" instead of "mingw32-make" from mingw32_shell solved all things! Now everything works.
Firstly I thought by mistake that "MSYS Makefiles" or "make" will link with MSYS runtime that I tried to avoid.
Thanks a lot, Alexey!
Last edit: Alex Zelid 2015-10-16
Everything worked... fine to build in msys2 shell. But when you try to use mingw32-make in IDE (to debug your own program that is linked with wxWidgets) - you get the same error again because IDE doesn't understand msys2 shell
Is there any IDE (CodeLite, CLion, Code::Blocks, qtCreator, NetBeans, other...) that can debug project like inside msys2?
Or any other IDE configuration that will allow CMake to find wxWidgets and also allow project to work with any IDE the same time?
Closing due to age. Please file an issue on GitHub if still relevant.