[CMake] bug in FindwxWidget.cmake (patch proposed)
Hi all, As mentioned in my previous post, there is a bug in the cmake module FindwxWidgets.cmake that prevents any library using wxWidgets to cross compile for Windows from Linux. Lines 192 to 198 are concerned by this bug: IF(WIN32 AND NOT CYGWIN AND NOT MSYS) SET(wxWidgets_FIND_STYLE "win32") ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS) IF(UNIX OR MSYS) SET(wxWidgets_FIND_STYLE "unix") ENDIF(UNIX OR MSYS) ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS) The problem is that, when cross compiling from Linux for Windows, the test "WIN32 AND NOT CYGWIN AND NOT MSYS" is true but find style should be "unix", because the Windows-based wxWidget library is installed in a unix environment. Therefore, the following line replacement corrects this bug: IF(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING) SET(wxWidgets_FIND_STYLE "win32") ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING) IF(UNIX OR MSYS OR CMAKE_CROSSCOMPILING) SET(wxWidgets_FIND_STYLE "unix") ENDIF(UNIX OR MSYS OR CMAKE_CROSSCOMPILING) ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING) The modified FindwxWidget.cmake module runs fine with the following toolchain cmake file: SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_C_COMPILER /usr/bin/i686-pc-mingw32-gcc) SET(CMAKE_CXX_COMPILER /usr/bin/i686-pc-mingw32-g++) SET(CMAKE_FIND_ROOT_PATH /usr/i686-pc-mingw32) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) Could this "patch" be applied in cmake svn, please? All the best, Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] Finding wxwidgets for cross compilation under linux
Hi, I am trying to build a wxWidgets-based application on linux for a win32 host. The win32 wxWidgets library is installed in /usr/i686-pc-mingw32/usr/local . I have q symlink from /usr/i686-pc-mingw32/usr/bin/wx-config to /usr/i686-pc-mingw32/usr/local/bin/wx-config . The cmake macro FIND_PACKAGE (wxWidgets COMPONENTS base core aui xml REQUIRED) does not find the win32 cmake. My toolchain file is: SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_C_COMPILER /usr/bin/i686-pc-mingw32-gcc) SET(CMAKE_CXX_COMPILER /usr/bin/i686-pc-mingw32-g++) SET(CMAKE_FIND_ROOT_PATH /usr/i686-pc-mingw32) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) If I comment the first line SET(CMAKE_SYSTEM_NAME Windows), cmake can find wxwidgets but then it is unable to link my program with the correct mingw tools (for instance, cmake uses /usr/bin/ar instead of /usr/bin/i686-pc-mingw32-ar). Explicitly setting the i686-pc-mingw32-ar command in the toolchain file does not help. Looking at the FindWxWidgets.cmake file, it seems that cmake switches to the win32 find style, what should nevertheless be the unix find style for cross compilation, shouldn't it? Thank you very much in advance, Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] Finding wxwidgets for cross compilation under linux
Hi, I am trying to build a wxWidgets-based application on linux for a win32 host. The win32 wxWidgets library is installed in /usr/i686-pc-mingw32/usr/local . I have q symlink from /usr/i686-pc-mingw32/usr/bin/wx-config to /usr/i686-pc-mingw32/usr/local/bin/wx-config . The cmake macro FIND_PACKAGE (wxWidgets COMPONENTS base core aui xml REQUIRED) does not find the win32 cmake. My toolchain file is: SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_C_COMPILER /usr/bin/i686-pc-mingw32-gcc) SET(CMAKE_CXX_COMPILER /usr/bin/i686-pc-mingw32-g++) SET(CMAKE_FIND_ROOT_PATH /usr/i686-pc-mingw32) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) If I comment the first line SET(CMAKE_SYSTEM_NAME Windows), cmake can find wxwidgets but then it is unable to link my program with the correct mingw tools (for instance, cmake uses /usr/bin/ar instead of /usr/bin/i686-pc-mingw32-ar). Explicitly setting the i686-pc-mingw32-ar command in the toolchain file does not help. Looking at the FindWxWidgets.cmake file, it seems that cmake switches to the win32 find style, what should nevertheless be the unix find style for cross compilation, shouldn't it? Thank you very much in advance, Florent Teichteil. ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Building with CMake on MinGW/MSYS
Le 19/02/2010 12:09, Hendrik Sattler a écrit : > Zitat von Florent Teichteil : >> I am trying to build the OpenJPEG library, that uses CMake to generate >> Makefiles, on MSYS with MinGW's gcc compiler. >> >> Some files of the library include system-dependent headers depending on >> the host system: >> >> #ifdef WIN32 >> #include >> #else >> #include >> #include >> #include >> #endif /* WIN32 */ >> >> However, the compilation of these files fails because the variable >> "WIN32" is (very strangely) not defined, so that gcc goes inside the >> "#else" statement and does not find the headers under the "sys" >> directory (which do not exist on windows). As I am compiling on a >> windows platform on MSYS, shouldn't I expect the variable "WIN32" to be >> defined? I tried the "MSYS" and "Unix" makefile generators, but none of >> them works. > > The pre-processor symbol is called _WIN32, not WIN32 (not the leading > underscore): > http://predef.sourceforge.net/preos.html#sec24 > > HS > > Is _WIN32 a standard macro or only defined by cmake? I'd like to know in order to inform openjpeg's authors about it so that they can modify their code at best in their mind. Thanks Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] Building with CMake on MinGW/MSYS
Hi all, I am trying to build the OpenJPEG library, that uses CMake to generate Makefiles, on MSYS with MinGW's gcc compiler. Some files of the library include system-dependent headers depending on the host system: #ifdef WIN32 #include #else #include #include #include #endif /* WIN32 */ However, the compilation of these files fails because the variable "WIN32" is (very strangely) not defined, so that gcc goes inside the "#else" statement and does not find the headers under the "sys" directory (which do not exist on windows). As I am compiling on a windows platform on MSYS, shouldn't I expect the variable "WIN32" to be defined? I tried the "MSYS" and "Unix" makefile generators, but none of them works. Thanks for your help, Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] FindxxWidgets.cmake: wrong wxWidgets_INCLUDE_DIRS on UNIX
Tyler Roscoe a écrit : On Wed, Jul 01, 2009 at 07:23:27PM +0200, Florent Teichteil wrote: // BEGINNING OF CMakeLists.txt set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) find_package(wxWidgets COMPONENTS base core REQUIRED) include_directories(${wxWidgets_INCLUDE_DIRS}) add_definitions(${wxWidgets_DEFINITIONS}) message(STATUS ${wxWidgets_INCLUDE_DIRS}) // END OF CMakeLists.txt When I run "cmake ." in a terminal window, I get the following output: Don't do in-source builds, for they lead to suffering. Check the FAQ for details. -- /usr/lib/wx/include/gtk2-unicode-release-2.8/usr/include/wx-2.8 -- Configuring done -- Generating done The first line gives the value of "wxWidgets_INCLUDE_DIRS" which is obviously wrong. It seems 2 paths have been concatenated without white space. I think it should be something like "/usr/lib/wx/include/gtk2-unicode-release-2.8 /usr/include/wx-2.8". Try message(STATUS "${wxWidgets_INCLUDE_DIRS}"). My guess is that variable is a list and the way you are using it in message() is flattening that list. I've just found the error I made. I defined another CMakeLists.txt file in a sub-directory containing the source code. Unfortunately, I declared it in the root CMakeLists.txt file (using the command add_subdirectory) after the wxwidgets macros, because I thought that it would be processed after the main file. But this is not the case: it seems the add_subdirectory command immediately processes the sub-directory's CMakeLists.txt file, so that the wxwidgets include paths were not defined in the sub-directory's generated Makefile. Thank you all very much for your help, Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] FindxxWidgets.cmake: wrong wxWidgets_INCLUDE_DIRS on UNIX
Miguel A. Figueroa-Villanueva a écrit : On Wed, Jul 1, 2009 at 2:02 PM, Tyler Roscoe wrote: On Wed, Jul 01, 2009 at 07:23:27PM +0200, Florent Teichteil wrote: // BEGINNING OF CMakeLists.txt set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) find_package(wxWidgets COMPONENTS base core REQUIRED) include_directories(${wxWidgets_INCLUDE_DIRS}) add_definitions(${wxWidgets_DEFINITIONS}) message(STATUS ${wxWidgets_INCLUDE_DIRS}) // END OF CMakeLists.txt When I run "cmake ." in a terminal window, I get the following output: Don't do in-source builds, for they lead to suffering. Check the FAQ for details. This is very good advice, of course... -- /usr/lib/wx/include/gtk2-unicode-release-2.8/usr/include/wx-2.8 -- Configuring done -- Generating done The first line gives the value of "wxWidgets_INCLUDE_DIRS" which is obviously wrong. It seems 2 paths have been concatenated without white space. I think it should be something like "/usr/lib/wx/include/gtk2-unicode-release-2.8 /usr/include/wx-2.8". Try message(STATUS "${wxWidgets_INCLUDE_DIRS}"). My guess is that variable is a list and the way you are using it in message() is flattening that list. This is most likely the case. Thanks Tyler. Also, Florent, do you actually have a problem? I mean besides the output line not matching what you expect; can you build a simple app? Thank you for advices! I tried message(STATUS "${wxWidgets_INCLUDE_DIRS}") that adds a semicolon between the paths. I'm not sure that gcc is able to parse include paths separated by semicolons. Anyway, when I try to make the project, gcc complains it can't find wxwidgets headers. For instance, the compilation of a source file containing the line "#include " gives the following error message (in French): "erreur: wx/wx.h : Aucun fichier ou dossier de ce type". It means that gcc can't find the include file. Thanks again, guys! Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] FindxxWidgets.cmake: wrong wxWidgets_INCLUDE_DIRS on UNIX
Hi, I am trying to write a CMakeLists.txt file on a Linux Ubuntu 9.04 platform. I'd like to test the presence of wxwidgets on the system, and use the include files of wxwidgets. This file is very simple at the moment: // BEGINNING OF CMakeLists.txt set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) find_package(wxWidgets COMPONENTS base core REQUIRED) include_directories(${wxWidgets_INCLUDE_DIRS}) add_definitions(${wxWidgets_DEFINITIONS}) message(STATUS ${wxWidgets_INCLUDE_DIRS}) // END OF CMakeLists.txt When I run "cmake ." in a terminal window, I get the following output: -- /usr/lib/wx/include/gtk2-unicode-release-2.8/usr/include/wx-2.8 -- Configuring done -- Generating done The first line gives the value of "wxWidgets_INCLUDE_DIRS" which is obviously wrong. It seems 2 paths have been concatenated without white space. I think it should be something like "/usr/lib/wx/include/gtk2-unicode-release-2.8 /usr/include/wx-2.8". All the best, Florent ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake