MantisBT - CMake
View Issue Details
0015087CMakeModulespublic2014-08-14 16:172015-11-02 09:13
Richard Shaw 
Richard Shaw 
normalmajoralways
closedfixed 
MSYS2/Mingw-w64Windows7 32bit
CMake 3.0.1 
CMake 3.1CMake 3.1 
0015087: Bug in FindwxWidgets.cmake causes build failure when more than one C flag is used.
FindwxWidgets.cmake parses the output of wx-config and converts it to a list. The definitions and includes seem to be processed appropriately but whatever is left is considered a CXX flag.

If more than one flag remains it is left as a cmake list, i.e.:
"-mthreads;-fpermissive" which gcc chokes on.

On both my Fedora and Fedora mingw-w64 installs only one flag is used and the issue doesn't crop up.
Attempt to build a cmake based project that uses wxWidgets with more than one build flag.
The following patch worked for me but should be reviewed for appropriateness:

diff -Naur cmake-3.0.1.orig/Modules/FindwxWidgets.cmake cmake-3.0.1.wxfix/Modules/FindwxWidgets.cmake
--- cmake-3.0.1.orig/Modules/FindwxWidgets.cmake 2014-07-31 10:03:56.000000000 -0500
+++ cmake-3.0.1.wxfix/Modules/FindwxWidgets.cmake 2014-08-14 12:02:11.604331400 -0500
@@ -792,6 +792,10 @@
           wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
         string(REPLACE "-I" ""
           wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
+
+ # Flags are a string, not a list, fix it here
+ string(REPLACE ";" " "
+ wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")

         DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
         DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
No tags attached.
Issue History
2014-08-14 16:17Richard ShawNew Issue
2014-08-18 16:34Brad KingNote Added: 0036639
2014-08-18 17:01Richard ShawNote Added: 0036640
2014-08-18 17:22Richard ShawNote Added: 0036641
2014-08-19 09:43Brad KingNote Added: 0036643
2014-08-19 12:58Richard ShawNote Added: 0036648
2014-08-19 13:32Brad KingNote Added: 0036649
2014-08-20 09:48Brad KingAssigned To => Richard Shaw
2014-08-20 09:48Brad KingStatusnew => assigned
2014-08-21 14:40Richard ShawNote Added: 0036658
2015-03-29 16:34oltolmNote Added: 0038359
2015-03-30 08:32Brad KingStatusassigned => resolved
2015-03-30 08:32Brad KingResolutionopen => fixed
2015-03-30 08:32Brad KingFixed in Version => CMake 3.1
2015-03-30 08:32Brad KingTarget Version => CMake 3.1
2015-11-02 09:13Robert MaynardNote Added: 0039752
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0036639)
Brad King   
2014-08-18 16:34   
The FindwxWidgets module only sets the value of wxWidgets_CXX_FLAGS. It is up to the project to use it correctly. If one uses the COMPILE_OPTIONS target property to apply the flags then a ;-list is the correct thing. I think this is a documentation issue because the docs do not say how the value is provided w.r.t. multiple flags. Existing projects may already expect a ;-list since that is what is now provided. Rather than changing this behavior, it should simply be documented.

Also the current call to separate_arguments(wxWidgets_CXX_FLAGS) just blindly replaces spaces with semicolons. That will not work with spaces in quoted paths. One needs to use the UNIX_COMMAND option to separate_arguments to get actual command-line parsing.
(0036640)
Richard Shaw   
2014-08-18 17:01   
Hmm... Since a use file is also implemented and recommended, perhaps the place to take care of it is there instead?

UsewxWidgets.cmake starting on line 90:

if (wxWidgets_CXX_FLAGS)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
    MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  endif()

So we could insert separate_arguments(...) before the set command above?
(0036641)
Richard Shaw   
2014-08-18 17:22   
Ok, sorry, I didn't catch what separate_arguments() did... That being the case, should my string(REPLACE...) code move to UsewxWidgets? It seem that there it is expected to be a string.
(0036643)
Brad King   
2014-08-19 09:43   
Re 0015087:0036640, 0015087:0036641: Oh, I forgot about UsewxWidgets. Yes, I think the flag fixup should move there.

Currently these modules have no maintainer:

 http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]

Please let me know if you're interested in volunteering.
(0036648)
Richard Shaw   
2014-08-19 12:58   
Well I need more stuff to maintain like I need a hole in my head but I may be willing.

1. Read cmake-developer (DONE)
2. I've got the mantis bug tracker account obviously (DONE)
3. The link in the wiki for CDash is bad but I found the right place and registered and subscribed to the cmake dashboard. (DONE)
4. The link for the developers mailing list is bad, currently
"http://www.cmake.org/cgi-bin/mailman/listinfo/cmake-developers" [^] needs to be
"http://www.cmake.org/mailman/listinfo/cmake-developers" [^]
Signed up... I'll introduce myself later.

Looks like I need to be "invited" to complete the git part.
(0036649)
Brad King   
2014-08-19 13:32   
Re 0015087:0036648: I fixed the links in the Wiki. They were ancient versions of the URLs and it looks like a recent web server configuration update finally dropped the redirects.
(0036658)
Richard Shaw   
2014-08-21 14:40   
Ok, I just pushed a topic to the staging area. We'll see how it goes :)
(0038359)
oltolm   
2015-03-29 16:34   
This was fixed in http://www.cmake.org/gitweb?p=cmake.git;a=commit;h=e6fa6e60f6330ddf60294a0d9a6ed4cb3f27d4c4 [^] . The commit was in CMake 3.0.2. Please close.
(0039752)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.