Closed SohaibImranBhatti closed 3 years ago
In many ways it has still failed to build. Even after changing the cmake file to a compatible version (which so far I think could be the initial error) the built project is still missing some includes and headers due to which it is not being built. It gives compile errors.
This time I built it using VS2019 command prompt
\AddingResources\wxModularApp\build\Win>cmake ../ -G "Visual Studio 16 2019" CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions. -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.14393. -- The C compiler identification is MSVC 19.28.29914.0 -- The CXX compiler identification is MSVC 19.28.29914.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done WARNING: Target "wxModularHost" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "wxModularHost" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "wxNonGuiPluginBase" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "wxNonGuiPluginBase" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleNonGuiPlugin" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleNonGuiPlugin" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "wxGuiPluginBase" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "wxGuiPluginBase" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleGuiPlugin1" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleGuiPlugin1" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleGuiPlugin2" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. WARNING: Target "SampleGuiPlugin2" requests linking to directory "C:/wxWidgets-3.1.4/lib/vc_dll". Targets may link only to libraries. CMake is dropping the item. -- Generating done -- Build files have been written to: /AddingResources/wxModularApp/build/Win
and when I opened the project all the include directories of wxwidgets were not found. Please note I have made many changes to CmakeLists.txt FIles to make it a compatible version (which I think was the error) with latest cmake release (3.19 in this case). Can you guide what might be the issue with the original cmake? why it does not get built?
According to CMake output, it generates the VS projects, so your problem is mostly related to your build environment, not to this project's build scripts.
If VS can't find the wxWidgets include directories then most likely you forgot to add WXWIN environment variable before running CMake, also you need to ensure that it's available from the command prompt where you are running CMake.
Also there are CMake warnings that say that you are trying to link to directory. Are you sure that you have built DLL Debug
and DLL Release
configuration of wxWidgets itself? You need both configurations built first, before running CMake.
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
It means that CMake can't find libs/DLLs of wxwidgets
Are you sure that WXWIN is available from the command prompt where you are running CMake and you have DLL Debug and DLL Release configuration of wxWidgets rebuilt under that path? Try to build both, x64 and x86 versions. If you are running cm.bat
on x64 Windows version, you will need x64 version of wxWidgets libs/DLLs. If you want x86 version then run cm86.bat
Well thanks so much for your reply. Please have a look at the following
When I asks the command prompt to see all variables by using set
the following is the output
Moreover the dlls
I tried to build the project on a different PC after installing wxWidgets and building both the dlls but again enccountered the same issue. Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
Also the project that I was able to build was only by changing the CmakeLists.txt of all folders. That generated project did not successfully built under VS IDE...
Let me try the cm86.bat
as well and get back to you
Wow!!!!!!! I couldn't have figured out unless you wouldn't have helped. I tried to build the cm86.bat and the find library error is gone! Thanks so much. But now I am encountering another issue Its some cmake policy issue I guess.
D:\SohaibProjects\AddingRes\ForumCode\wxModularAppNew\build\Win>cmake ../ -G "Visual Studio 15" -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.14393. -- The C compiler identification is MSVC 19.16.27045.0 -- The CXX compiler identification is MSVC 19.16.27045.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found wxWidgets: debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31ud.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31u.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_core.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_core.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_adv.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_adv.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_aui.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_aui.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31ud_net.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31u_net.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_gl.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_gl.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31ud_xml.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxbase31u_xml.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_propgrid.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_propgrid.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31ud_html.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxmsw31u_html.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxpngd.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxpng.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxtiffd.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxtiff.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxjpegd.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxjpeg.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxzlibd.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxzlib.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxregexud.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxregexu.lib;debug;C:/wxWidgets-3.1.4/lib/vc_dll/wxexpatd.lib;optimized;C:/wxWidgets-3.1.4/lib/vc_dll/wxexpat.lib;opengl32;glu32;winmm;comctl32;oleacc;rpcrt4;shlwapi;version;wsock32 (found version "3.1.4") CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/wxModularHost/CMakeLists.txt:78 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/wxModularCore/CMakeLists.txt:30 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/wxNonGuiPluginBase/CMakeLists.txt:48 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/SampleNonGuiPlugin/CMakeLists.txt:65 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/wxGuiPluginBase/CMakeLists.txt:50 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/SampleGuiPlugin1/CMakeLists.txt:63 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/PCHSupport.cmake:330 (GET_TARGET_PROPERTY): Policy CMP0045 is not set: Error on non-existent target in get_target_property. Run "cmake --help-policy CMP0045" for policy details. Use the cmake_policy command to set the policy and suppress this warning. get_target_property() called with non-existent target "D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/../include/stdwx.cpp". Call Stack (most recent call first): D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/SampleGuiPlugin2/CMakeLists.txt:64 (set_precompiled_header) This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring done -- Generating done -- Build files have been written to: D:/SohaibProjects/AddingRes/ForumCode/wxModularAppNew/build/Win
Hi T-Rex, After a couple of days of debugging into the problem. I successfully generated the Visual Studio project generated by CMake. I just want to sum up how can this be done.
As T-Rex mentioned in another ticket cm86.bat
and cm64.bat
both should have the correct generaor for visual studio. The generator depends on the command prompt one is using.
For example if someone is using VS2017 Native command prompt x64 or x86
the correct generator to be used is 15. And then the command
cmake ../ -G "Visual Studio 15"
or
cmake ../ -G "Visual Studio 15 Win64
in case of cm64.bat
Again as T-Rex has mentioned you need to carefully see which type of .dll (either for x86 or for x64) one has built in lib folder of wxWidgets. In my experience VS2017 Native command prompt x64
prompt will not find the wxWidgets x86 libraries. and generate errors as mentioned above. But I dont know why in my case VS2019 Native command prompt x86
was not able to find the wxWidgets libraries even when I had vc_dll build with x86 configurations?
Last but not the least, The CMakeLists.txt
files provided with the project is written for an older cmake version and the commands
set_precompiled_header(${LIBRARY_NAME} ${PROJECT_ROOT_DIR}/include/stdwx.h ${PROJECT_ROOT_DIR}/include/stdwx.cpp)
gave me an error. I had to replace this command with
target_precompile_headers(${LIBRARY_NAME} PRIVATE ${PROJECT_ROOT_DIR}/include/stdwx.h ${PROJECT_ROOT_DIR}/include/stdwx.cpp)
with the proper parameters for each CMakeLists.txt file in the sub projects / folders to generate the project properly. Lastly this command only works with cmake version 3.12 or above so one needs to make sure it is running 3.12 or above version of cmake in the command prompt. cmake --version
to see version.
Added the corresponding changes mentioned by @sohaibimran-lm to CMakeLists.txt Updated the README with the note that CMake v3.16 is required for target_precompile_headers() call. Tested on x64 build with VS2019 so far.
Hi T-Rex, I ran into this error while trying to build the cm.bat file after correcting the version of visual studio in cmake command
Although WXWIN variable is defined as the environment variable why am I getting such errors?