Dieses kleine Howto soll beschreiben, wie man mit wxWidget und C++ geschriebene Programme mithilfe von CMake von Kitware kompiliert. Bewogen dazu hat mich die Tatsache, dass man im Wiki-Bereich von www.wxwidgets.org ohne Anmeldung keine Veränderungen machen kann. Und wie man sich anmeldet habe ich auf die Kürze auch nicht herausgefunden. Da das dort angebotene Skript meines Wissens entweder falsch oder veraltet ist, poste ich hier das Skript, mit dem zumindest CMake Version 2.4 unter Debian/amd64 klar kommt.

Diese Skript bezieht sich auf das Beispielprogramm "minimal" welches mit dem wxWidgets-Quellcode zum selber kompilieren mitgeliefert wird.(Im Verzeichnis "samples")

Den großteil habe ich einfach auf Englisch stehen gelassen, ich hoffe das nimmt mir niemand übel.


Code:
##---------------------------------------------------------------------------
## $RCSfile: CMakeLists.txt $
## $Source: CMakeLists.txt $
## $Revision: 1.48 $
## $Date: Feb 26, 2006 10:39:43 PM $
##---------------------------------------------------------------------------
## Author:      Jorgen Bodde
## Copyright:   (c) Jorgen Bodde
## Modified:    by Christian Lohr
## License:     wxWidgets License
##---------------------------------------------------------------------------
 
##---------------------------------------------------
## Please set your wxWidgets configuration here
##--------------------------------------------------- 

# MODIFICATION #1
# Hier habe ich den Verweis, auf die schon mit cmake mitgelieferten
# Skripts, welche die wxWidgets-Bibliotheken aufspüren und nutzen sollen.

INCLUDE (${CMAKE_ROOT}/Modules/FindwxWidgets.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/UsewxWidgets.cmake)

 
# Here you can define what libraries of wxWidgets you need for your
# application. You can figure out what libraries you need here;
# http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html

# Diese Zeile habe ich auskommentiert, weil diese libs bei mir nicht
# gefunden wurden, und es zu einer Fehlermeldung kam. Brauchte ich bei
# dem simplen Beispiel auch nicht.
# SET(wxWidgets_USE_LIBS base core gl net)

 
# We need the Find package for wxWidgets to work
FIND_PACKAGE(wxWidgets)
 
##---------------------------------------------------
## Actual config file starts here
##--------------------------------------------------- 
 
# Did we find wxWidgets ? This condition will fail
# for as long as the internal vars do not point to
# the proper wxWidgets configuration
IF(wxWidgets_FOUND)
     
    # Include wxWidgets macros
    INCLUDE(${wxWidgets_USE_FILE})
 
    # Our project is called 'minimal' this is how it will be called in
    # visual studio, and in our makefiles. 
    PROJECT( minimal )
 
    # We define the include paths here, our minimal source dir is one, 
    # and also the include dirs defined by wxWidgets
    INCLUDE_DIRECTORIES(${minimal_SOURCE_DIR}
                        ${wxWidgets_INCLUDE_DIRS} )
    # Normalerweise wird die obige Zeile in dem Beispiel nicht unbedingt benötigt
 
    # For convenience we define the sources as a variable. You can add 
    # header files and cpp / c files and CMake will sort them out
    SET(SRCS minimal.cpp )
 
    # If we build for windows systems, we also include the resource file
    # containing the manifest, icon and other resources
    IF(WIN32)
        SET(SRCS ${SRCS} minimal.rc)
    ENDIF(WIN32)
 
    # Here we define the executable minimal.exe or minimal on other systems
    # the above paths and defines will be used in this build
    ADD_EXECUTABLE(minimal WIN32 ${SRCS})
    
    # We add to our target 'minimal' the wxWidgets libraries. These are
    # set for us by the find script. If you need other libraries, you
    # can add them here as well. 
    TARGET_LINK_LIBRARIES(minimal ${wxWidgets_LIBRARIES} )
 
ELSE(wxWidgets_FOUND)
    # For convenience. When we cannot continue, inform the user
    MESSAGE("wxWidgets not found!")
ENDIF(wxWidgets_FOUND)