Can't build the minimal sample using CMakeLists.txt on Windows (Issue #22861)

317 views
Skip to first unread message

lszl84

unread,
Oct 10, 2022, 8:35:43 AM10/10/22
to wx-...@googlegroups.com, Subscribed

Description

Clone and build wxWidgets source:

> cd \
> git clone --recurse-submodules https://github.com/wxWidgets/wxWidgets.git 
> cmake -SwxWidgets -Bwx_build -DCMAKE_INSTALL_PREFIX=\wx_install -DwxBUILD_SHARED=OFF -DwxBUILD_SAMPLES=ALL -DwxBUILD_DEMOS=ON
> cmake --build wx_build --target install

This works well. Now:

> cd wxWidgets\samples\minimal

Open CMakeLists.txt in that directory and add these lines before find_package(wxWidgets 3.3 COMPONENTS core base REQUIRED CONFIG) so that Findwxwidgets looks for wxWidgets in our C:\wx_install directory:

set(wxWidgets_LIB_DIR "C:/wx_install/lib")
message(STATUS "The wx lib dir set to: ${wxWidgets_LIB_DIR}")

set(ENV{WX_CONFIG} "C:/wx_install/bin/wx-config")
message(STATUS "The wx config app set to: $ENV{WX_CONFIG}")

set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};C:/wx_install") 
message(STATUS "The prefix path is ${CMAKE_PREFIX_PATH}")

While in the minimal directory, try building the sample using CMake. The configuration step fails:

>cmake -S. -Bbuild
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19044.
-- The wx lib dir set to: C:/wx_install/lib
-- The wx config app set to: C:/wx_install/bin/wx-config
-- The prefix path is ;C:/wx_install
-- Configuring done
CMake Error in CMakeLists.txt:
  Imported target "wx::wxbase" includes non-existent path

    "C:/wx_install/lib/vc_x64_lib/mswu"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

[... the same error repeated a few times]

Expected outcome: the cmake configuration and build should succeed.

Platform and version information

  • wxWidgets version you use: 3.3 main branch 9758c63
  • wxWidgets port you use: wxMSW
  • OS and its version: Windows 10


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861@github.com>

VZ

unread,
Oct 10, 2022, 1:54:12 PM10/10/22
to wx-...@googlegroups.com, Subscribed

Sorry, no idea about what's going on here, AFAICS this directory should have been created during the build. Any help with debugging and/or fixing this would be welcome, TIA.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1273640813@github.com>

lszl84

unread,
Oct 11, 2022, 4:28:44 AM10/11/22
to wx-...@googlegroups.com, Subscribed

Okay, here's what I got after some more experimentation:

Scenario 1: build both Debug and Release wxWidgets

> cmake -SwxWidgets -Bwx_build -DCMAKE_INSTALL_PREFIX=\wx_install -DwxBUILD_SHARED=OFF
> cmake --build wx_build --target install
> cmake --build wx_build --target install --config Release

In this scenario building the minimal sample works. There are both mswu and mswud directories in wx_install\lib\vc_x64_lib and the scripts seem to be very happy about it.

Scenario 2: just Release configuration of wxWidgets

> cmake -SwxWidgets -Bwx_build -DCMAKE_INSTALL_PREFIX=\wx_install -DwxBUILD_SHARED=OFF
> cmake --build wx_build --target install --config Release

I this case when compiling the minimal sample, the scripts complain about missing mswud directory.

Scenario 3: building the default configuration of wxWidgets (Debug, I suppose?) - the original case from this issue

> cmake -SwxWidgets -Bwx_build -DCMAKE_INSTALL_PREFIX=\wx_install -DwxBUILD_SHARED=OFF
> cmake --build wx_build --target install 

Now the scripts complain about missing mswu.

There are a few things I don't understand here:

  1. You mentioned that mswu should have been created when building wxWidgets with cmake --build wx_build --target install, but why? Isn't this command supposed to build just the debug configuration by default?
  2. Why the CMake configuration script looks for both mswud and mswu when building a sample app? Why are both needed at the configuration stage, even though I might choose to build only one configuration at the build stage e.g. cmake --build build --config Release?

Hope this helps!


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1274301741@github.com>

VZ

unread,
Oct 11, 2022, 8:14:17 AM10/11/22
to wx-...@googlegroups.com, Subscribed

I don't actually know how is this supposed to work with CMake, i.e. whether it's supposed to build just one configuration or both/all with the generators supporting multiple configurations, nor which configuration should be the default if none is specified.

But it definitely seems wrong that the sample cmakefile uses a different configuration from the one used by the library cmakefiles by default...


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1274588091@github.com>

lszl84

unread,
Oct 11, 2022, 12:27:42 PM10/11/22
to wx-...@googlegroups.com, Subscribed

I've attached the trace output from cmake -S. -Bbuild --trace > trace.txt 2>&1.

What seems suspicious is that wxWidgetsTargets.cmake script uses the generator expressions to determine if mswu or mswud can be used:

C:/wx_install/lib/cmake/wxWidgets/vc_x64_lib/wxWidgetsTargets.cmake(106):  set_target_properties(wx::wxbase PROPERTIES INTERFACE_COMPILE_DEFINITIONS 
UNICODE;_UNICODE;__WXMSW__ INTERFACE_INCLUDE_DIRECTORIES ${_IMPORT_PREFIX}/lib/vc_x64_lib/mswu\$<\$<CONFIG:Debug>:d>;${_IMPORT_PREFIX}/include 
INTERFACE_LINK_LIBRARIES kernel32;user32;gdi32;comdlg32;winspool;winmm;shell32;shlwapi;comctl32;ole32;oleaut32;uuid;rpcrt4;advapi32;version;ws2_32;wininet;oleacc;u
xtheme;\$<LINK_ONLY:wx::wxzlib>;\$<LINK_ONLY:wx::wxregex> )

The problem is this fails in the generation phase (cmake -S. -Bbuild), not the build phase (cmake --build build), but I only can choose configuration on Windows during the build phase! So why checking $<CONFIG:Debug> earlier?

I have a hunch that this may be the problem, but I have no idea how to investigate further. The wxWidgetsConfig.cmake and wxWidgetsTargets.cmake seem to be pretty new additions to the project. Maybe the person who worked on these can help?

trace.txt


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1274963660@github.com>

Maarten

unread,
Oct 11, 2022, 1:57:29 PM10/11/22
to wx-...@googlegroups.com, Subscribed

Indeed, you have to build and install both Debug and Release configuration of wxWidgets to successfully generate the sample. You can do this with the --config argument.

You use the Visual Studio generator I assume. These generate multi-config solutions, that can be used to build both Debug and Release configurations. So when the solution for the minimal sample is generated, it will check if it can build both the Debug and Release configuration. It doesn't know at generating time that you only want the Debug version.

Afaik using generator expressions is the only way to differentiate between debug and release builds. Maybe a workaround could be to create an empty mswu directory when installing the debug configuration and mswud for the release configuration.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1275070347@github.com>

lszl84

unread,
Oct 11, 2022, 3:34:16 PM10/11/22
to wx-...@googlegroups.com, Subscribed

Alright, so I need to make the ExternalProject_Add (which I'm using to download wxWidgets from GitHub) build both Release and Debug configurations.

It would be nice if we got some more user friendly error message though :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22861/1275178871@github.com>

Reply all
Reply to author
Forward
0 new messages