Page 1 of 1

cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 6:39 am
by futuretrash
I'm trying to use wxWidgets with cmake on mac so I had to build it from sources.

Code: Select all

git clone https://github.com/wxWidgets/wxWidgets
cd wxWidgets
mkdir build-cocoa-osx
cd build-cocoa-osx
../configure --enable-debug
make -j 8
make install
The installation was successful and I was able to build the samples and demos as well.

Code: Select all

./wx-config --cxxflags
  -I/..../wxWidgets/build-cocoa-debug/lib/wx/include/osx_cocoa-unicode-3.1 -I/..../wxWidgets/include -D_FILE_OFFSET_BITS=64 -D__WXMAC__ -D__WXOSX__ -D__WXOSX_COCOA__
wx-config for libs

Code: Select all

./wx-config --libs
-L/..../wxWidgets/build-cocoa-debug/lib   -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework System -framework OpenGL -lwx_osx_cocoau_xrc-3.1 -lwx_osx_cocoau_html-3.1 -lwx_osx_cocoau_qa-3.1 -lwx_osx_cocoau_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1 
In the CMakeLists.txt I added

Code: Select all

find_package(wxWidgets REQUIRED core base HINT ${wxWidgets_ROOT_DIR})
message(STATUS "wxWidgets library:")
But when I run cmake on my project with the following command

Code: Select all

cmake -G "Unix Makefiles" -DwxWidgets_ROOT_DIR=/..../wxWidgets/build-cocoa-osx -DwxWidgets_LIB_DIR=/..../wxWidgets/build-cocoa-osx/lib . -B build
CMake Error at /usr/local/Cellar/cmake/3.17.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.17.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.17.3/share/cmake/Modules/FindwxWidgets.cmake:1008 (find_package_handle_standard_args)
CMakeLists.txt:66 (find_package)

* I used /..../ as simplification for the users folder structure.

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 10:26 am
by doublemax
I don't work under OSX and i know even less about cmake, but are you sure this is right?

Code: Select all

-DwxWidgets_ROOT_DIR=/..../wxWidgets/build-cocoa-osx
Try without the /build-cocoa-osx/

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 11:04 am
by futuretrash
@doublemax: The /..../ is only a simplification of the users folder structure. Or do you pertain on the / in the end?

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 11:31 am
by doublemax
futuretrash wrote:
Thu Jun 18, 2020 11:04 am
@doublemax: The /..../ is only a simplification of the users folder structure. Or do you pertain on the / in the end?
No, i meant the "build-cocoa-osx" part. My suggestion was to try just:

Code: Select all

-DwxWidgets_ROOT_DIR=/..../wxWidgets/

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 11:58 am
by futuretrash
I tried multiple variants for wxWidgets_ROOT:

Code: Select all

-DwxWidgets_ROOT_DIR=/..../wxWidgets/build-cocoa-debug/lib
-DwxWidgets_ROOT_DIR=/..../wxWidgets/build-cocoa-debug
-DwxWidgets_ROOT_DIR=/..../wxWidgets
I tried the same diretories for wxWidgets_LIB_DIR as well.

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 2:09 pm
by futuretrash
For better understanding, I published a sample project with github actions to build wxWidgets for osx:
https://github.com/thebino/HelloWxWidge ... /784521591

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 6:17 pm
by ONEEYEMAN
Hi,
Why not use a standard way of building under OSX - install and use Xcode?

Thank you.

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 7:45 pm
by futuretrash
Building with xcode would force me to one platform, I don't need to use wxWidgets nor c++ for a single platform solution.
One of the biggest features of wxWidgets should be multiplatform support
wxWidgets is a C++ library that lets developers create applications for Windows, macOS, Linux and other platforms with a single code base.
Also it should be included in an already existing project based on cmake. So It has to be build with cmake.

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 7:53 pm
by ONEEYEMAN
Hi,
While wxWidgets is a cross-platform C++ library, you will still suppose to build the library itself and then your code natively on the platform in question.
That's how C++ works comparing to "JAVA".
Are you trying to make the code to compile by the user of the software you're developing?
Or you (and your company) will distribute the binaries?

Thank you.

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 8:00 pm
by futuretrash
Distribute the app as binary either with an installer and shared libs or as linked against static libs.
Right now I'm hesitating to use wxwidgets since these initial compile issues

Re: cmake on mac fails with (missing: wxWidgets_LIBRARIES)

Posted: Thu Jun 18, 2020 8:05 pm
by doublemax
Cmake support in wxWidgets is relatively new and - as far as i can tell - rarely used.

Try posting on the wx-users group where you can reach the core developers. This is a user forum.
https://groups.google.com/forum/#!forum/wx-users