Using with Ninja under Windows

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Using with Ninja under Windows

Post by Natane Hoshino » Thu Jul 09, 2020 10:38 am

Hi. I'm beginner in wxWidgets.

I'm tried to using wxWidgets built by myself with Ninja and CMake under Windows.

But, CMake can't found library.

Code: Select all

$ cmake .. -GNinja -DwxWidgets_ROOT_DIR=C:/Dev/lib_mingw64/wxWidgets
-- The CXX compiler identification is Clang 10.0.0
-- Check for working CXX compiler: C:/Dev/msys64/mingw64/bin/clang++.exe
-- Check for working CXX compiler: C:/Dev/msys64/mingw64/bin/clang++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/Dev/msys64/mingw64/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
  wxWidgets_INCLUDE_DIRS)
Call Stack (most recent call first):
  C:/Dev/msys64/mingw64/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
  C:/Dev/msys64/mingw64/share/cmake-3.17/Modules/FindwxWidgets.cmake:1008 (find_package_handle_standard_args)
  CMakeLists.txt:5 (find_package)


-- Configuring incomplete, errors occurred!
See also "D:/Dev/C++/wxwidgets_test/build/CMakeFiles/CMakeOutput.log".
Here is my small project.
https://github.com/SEED264/wxwidgets_te ... b00e644335

In Visual Studio 2019, It works fine.

How can I solve this?

I'm sorry my English isn't so good.
Thanks for advices!

User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Re: Using with Ninja under Windows

Post by Natane Hoshino » Thu Jul 09, 2020 3:21 pm

Here is log of my CMake(
cmake_output.txt
(7.49 KiB) Downloaded 11 times
), build(
ninja_build_log.txt
(89.92 KiB) Downloaded 11 times
), and install(
ninja_install_log.txt
(116.94 KiB) Downloaded 11 times
) wxWidgets with Ninja.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Using with Ninja under Windows

Post by ONEEYEMAN » Thu Jul 09, 2020 4:54 pm

Hi,
Why do you want to build with "as many tools as you want"? ;-)
You said it worked with MSVC - why do you want to reinvent the wheel?

Thank you.

User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Re: Using with Ninja under Windows

Post by Natane Hoshino » Thu Jul 09, 2020 5:32 pm

The reason is I usually use CMake+(Ninja or Makefile) for C++ development.
I use Visual Studio as a sub-tool when I need it separately.

If I couldn't solve this, I'd use Visual Studio when using wxWidget.

Thanks for reply.

User avatar
doublemax
Moderator
Moderator
Posts: 14976
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using with Ninja under Windows

Post by doublemax » Thu Jul 09, 2020 6:36 pm

I don't use cmake, so i'm not sure about this:

Code: Select all

$ cmake .. -GNinja -DwxWidgets_ROOT_DIR=C:/Dev/lib_mingw64/wxWidgets
You're setting the wxWidgets_ROOT_DIR variable, but not wxWidgets_LIBRARIES and wxWidgets_INCLUDE_DIRS.
Use the source, Luke!

User avatar
doublemax
Moderator
Moderator
Posts: 14976
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using with Ninja under Windows

Post by doublemax » Thu Jul 09, 2020 6:46 pm

I just looked into the build logs. The include paths look a little strange to me.

E.g.

Code: Select all

Installing: C:/Dev/lib_mingw64/wxWidgets/include/wx-3.1/wx/xrc/xh_menu.h
I would expect:

Code: Select all

Installing: C:/Dev/lib_mingw64/wxWidgets/include/wx/xrc/xh_menu.h
I don't know if this is normal when using cmake, but it's something you should look into.
Use the source, Luke!

stahta01
Super wx Problem Solver
Super wx Problem Solver
Posts: 365
Joined: Fri Nov 03, 2006 2:00 pm

Re: Using with Ninja under Windows

Post by stahta01 » Fri Jul 10, 2020 10:33 am

It is normal using MSys2 and configure/make.

Tim S.

User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Re: Using with Ninja under Windows

Post by Natane Hoshino » Fri Jul 10, 2020 12:00 pm

doublemax wrote:
Thu Jul 09, 2020 6:36 pm
I don't use cmake, so i'm not sure about this:

Code: Select all

$ cmake .. -GNinja -DwxWidgets_ROOT_DIR=C:/Dev/lib_mingw64/wxWidgets
You're setting the wxWidgets_ROOT_DIR variable, but not wxWidgets_LIBRARIES and wxWidgets_INCLUDE_DIRS.
wxWidgets_LIBRARIES and wxWidgets_INCLUDE_DIRS are probably auto configure when wxWidgets found.

Here is help of FindwxWidgets.
https://cmake.org/cmake/help/v3.18/modu ... dgets.html

User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Re: Using with Ninja under Windows

Post by Natane Hoshino » Fri Jul 10, 2020 12:16 pm

doublemax wrote:
Thu Jul 09, 2020 6:46 pm
I just looked into the build logs. The include paths look a little strange to me.

E.g.

Code: Select all

Installing: C:/Dev/lib_mingw64/wxWidgets/include/wx-3.1/wx/xrc/xh_menu.h
I would expect:

Code: Select all

Installing: C:/Dev/lib_mingw64/wxWidgets/include/wx/xrc/xh_menu.h
I don't know if this is normal when using cmake, but it's something you should look into.
I have read install.cmake while few minutes ago.
https://github.com/wxWidgets/wxWidgets/ ... tall.cmake

In this, headers will install to include/wx if using MSVC.
Otherwise, they will install to include/wx-${wxWidgets version}.

Code: Select all

if(MSVC)
    wx_install(
        DIRECTORY "${wxSOURCE_DIR}/include/wx"
        DESTINATION "include")
    wx_install(
        DIRECTORY "${wxSOURCE_DIR}/include/msvc"
        DESTINATION "include")
else()
    wx_install(
        DIRECTORY "${wxSOURCE_DIR}/include/wx"
        DESTINATION "include/wx-${wxMAJOR_VERSION}.${wxMINOR_VERSION}")
endif()

User avatar
Natane Hoshino
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jul 08, 2020 5:10 pm

Re: Using with Ninja under Windows

Post by Natane Hoshino » Tue Jul 14, 2020 2:04 pm

Hi.

After that, I found the cause of problem.

In FindwxWidgets.cmake(https://gitlab.kitware.com/cmake/cmake/ ... cmake#L209), script determinate package find style as win32 when win32 is defined and MSYS, Cygwin system or cross-compile does not used.

Code: Select all

#=====================================================================
# Determine whether unix or win32 paths should be used
#=====================================================================
if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING)
  set(wxWidgets_FIND_STYLE "win32")
else()
  set(wxWidgets_FIND_STYLE "unix")
endif()
In this, Ninja has determinated as win32 style. But Ninja need unix style because it use libraries that built with clang++/g++.

In unix style(https://gitlab.kitware.com/cmake/cmake/ ... cmake#L763), uses wx-config to determine package has been found and set libraries and include paths.

So I edited FindwxWidgets.cmake as first aid like this.

Code: Select all

#=====================================================================
# Determine whether unix or win32 paths should be used
#=====================================================================
#========== Custom ==========
if(CMAKE_MAKE_PROGRAM MATCHES "ninja")
  set(wxWidgets_USING_NINJA true)
endif()
#============================
if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING AND NOT wxWidgets_USING_NINJA)
  set(wxWidgets_FIND_STYLE "win32")
else()
  set(wxWidgets_FIND_STYLE "unix")
endif()
And configured CMake like this, build, and launch.

Code: Select all

$ wxwidgets_root_dir="C:/Dev/lib_mingw64/wxWidgets"
$ cmake .. -GNinja \
>    -DwxWidgets_ROOT_DIR=$wxwidgets_root_dir \
>    -DwxWidgets_CONFIG_EXECUTABLE="${wxwidgets_root_dir}/bin/wx-config"
It works fine.

User avatar
doublemax
Moderator
Moderator
Posts: 14976
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Using with Ninja under Windows

Post by doublemax » Tue Jul 14, 2020 3:36 pm

Thanks for posting the solution, this can be useful for others. =D>
Use the source, Luke!

Post Reply