vmagnin / gtk-fortran

A GTK / Fortran binding. The documentation is in the Wiki tab.
GNU General Public License v3.0
250 stars 43 forks source link

CMake Build System #23

Closed hornekyle closed 11 years ago

hornekyle commented 13 years ago

I have created a CMake build system for gtk-fortran, and successfully used in on the Debian (wheezy) system to build the examples. CMake provides many features that could be useful to the project. I can be contacted at the following address: horne \dot kyle \at gmail \dot com

jtappin commented 13 years ago

Hi Horne, I agree that cmake is probably our best bet (I was actually starting to try to figure out the documentation yesterday).

If you paste the cmake files into this issue thread, I will copy them into my tree and test them out and then commit them.

hornekyle commented 13 years ago

Here is the directory structure for the CMake enabled package, with the contents of the CMakelist.txt files following:

. |-- cfwrapper.py |-- cmake | -- cmake_uninstall.cmake.in |-- CMakeLists.txt |-- Doxyfile |-- examples | |-- bazaar.f90 | |-- cairo-basics.f90 | |-- cairo-tests.f90 | |-- CMakeLists.txt | |-- gtkbuilder2.f90 | |-- gtkbuilder.f90 | |-- gtkbuilder.glade | |-- gtkhello2.f90 | |-- hl_choosers.f90 | |-- hl_combo.f90 | |-- hl_containers.f90 | |-- hl_dialog.f90 | |-- hl_list1.f90 | |-- hl_list_n.f90 | |-- hl_menu.f90 | |-- hl_pbar.f90 | |-- hl_pbar_p.f90 | |-- hl_radio.f90 | |-- hl_sliders.f90 | |-- hl_textview.f90 | |-- hl_tree.f90 | |-- julia_pixbuf.f90 | |-- list_demo.f90 | |-- mandelbrot.f90 | |-- mandelbrot_pixbuf.f90 | |-- menu.f90 |-- notebooks.f90 |-- gtk-fortran-logo.svg |-- README |-- README-high-level |-- src | |-- atk-auto.f90 | |-- cairo-auto.f90 | |-- CMakeLists.txt | |-- gdk-auto.f90 | |-- gdk-pixbuf-auto.f90 | |-- glib-auto.f90 | |-- gtk-auto.f90 | |-- gtkenums-auto.f90 | |-- gtk.f90 | |-- gtk-hl.f90 | |-- gtk-sup.f90 | -- pango-auto.f90 |-- tests | |-- CMakeLists.txt |-- tests.f90 `-- usemodules.py

!====================! != ./CMakelist.txt: =! !====================!

cmake_minimum_required(VERSION 2.6) project(gtk-fortran C Fortran)

set(CMAKE_Fortran_FLAGS_DEBUG "-g -pthread -Wall -Wtabs -fcheck-array-temporaries -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow") set(CMAKE_Fortran_FLAGS_RELEASE "-pthread -O3 -mtune=native -march=native")

set(CPACK_PACKAGE_VERSION "0.1.0") set(CPACK_PACKAGE_INSTALL_DIRECTORY "gtk-fortran") set(CPACK_GENERATOR "STGZ;TGZ") set(CPACK_SOURCE_GENERATOR "STGZ;TGZ") include(CPack)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

uninstall target

configure_file( "${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

enable_testing()

find_package(GTK2 COMPONENTS gtk) set(GTK_INCLUDES ${GTK2_ATK_INCLUDE_DIR} ${GTK2_CAIRO_INCLUDE_DIR} ${GTK2_GDK_INCLUDE_DIR} ${GTK2_GDK_PIXBUF_INCLUDE_DIR} ${GTK2_GLIB_INCLUDE_DIR} ${GTK2_GOBJECT_INCLUDE_DIR} ${GTK2_GTK_INCLUDE_DIR} ${GTK2_PANGO_INCLUDE_DIR} CACHE STRING "" FORCE) set(GTK_LIBRARIES ${GTK2_ATK_LIBRARY} ${GTK2_CAIRO_LIBRARY} ${GTK2_GDK_LIBRARY} ${GTK2_GDK_PIXBUF_LIBRARY} ${GTK2_GLIB_LIBRARY} ${GTK2_GOBJECT_LIBRARY} ${GTK2_GTK_LIBRARY} ${GTK2_PANGO_LIBRARY} CACHE STRING "" FORCE)

configure_file("${PROJECT_SOURCE_DIR}/Doxyfile" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" IMMEDIATE)

find_package(Doxygen) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "latex" "html") add_custom_target(doxygen COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Writing documentation..." WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_custom_target(doc) add_dependencies(doc doxygen)

add_subdirectory(src) add_subdirectory(tests) add_subdirectory(examples)

!========================! != ./src/CMakelist.txt: =! !========================!

set(sources "atk-auto.f90" "cairo-auto.f90" "gdk-auto.f90" "gdk-pixbuf-auto.f90" "glib-auto.f90" "gtk.f90" "gtk-hl.f90" "gtk-sup.f90" "pango-auto.f90")

include_directories("/usr/include") include_directories(${GTK_INCLUDES})

add_library(gtk-fortran_static STATIC ${sources}) add_library(gtk-fortran_shared SHARED ${sources}) target_link_libraries(gtk-fortran_shared ${GTK_LIBRARIES})

set_target_properties(gtk-fortran_static gtk-fortran_shared PROPERTIES OUTPUT_NAME gtk-fortran) set_target_properties(gtk-fortran_static gtk-fortran_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)

set_target_properties(gtk-fortran_static gtk-fortran_shared PROPERTIES VERSION "0.1") set_target_properties(gtk-fortran_static gtk-fortran_shared PROPERTIES VERSION "0.1") set_target_properties(gtk-fortran_static gtk-fortran_shared PROPERTIES SOVERSION "0.1")

install(TARGETS gtk-fortran_static ARCHIVE DESTINATION lib) install(TARGETS gtk-fortran_shared LIBRARY DESTINATION lib) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/atk.mod" "${CMAKE_CURRENT_BINARY_DIR}/cairo.mod" "${CMAKE_CURRENT_BINARY_DIR}/gdk.mod" "${CMAKE_CURRENT_BINARY_DIR}/gdk_pixbuf.mod" "${CMAKE_CURRENT_BINARY_DIR}/g.mod" "${CMAKE_CURRENT_BINARY_DIR}/gtk.mod" "${CMAKE_CURRENT_BINARY_DIR}/gtk_hl.mod" "${CMAKE_CURRENT_BINARY_DIR}/gtk_sup.mod" "${CMAKE_CURRENT_BINARY_DIR}/pango.mod" DESTINATION include)

!=============================! != ./examples/CMakelist.txt: =! !=============================!

include_directories("/usr/include") include_directories("/usr/local/include") include_directories("${CMAKE_BINARY_DIR}/src") include_directories(${GTK_INCLUDES})

add_executable(bazaar "bazaar.f90") target_link_libraries(bazaar gtk-fortran_static ${GTK_LIBRARIES})

add_executable(cairo-tests "cairo-tests.f90") target_link_libraries(cairo-tests gtk-fortran_static ${GTK_LIBRARIES})

add_executable(gtkhello2 "gtkhello2.f90") target_link_libraries(gtkhello2 gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_choosers "hl_choosers.f90") target_link_libraries(hl_choosers gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_combo "hl_combo.f90") target_link_libraries(hl_combo gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_containers "hl_containers.f90") target_link_libraries(hl_containers gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_dialog "hl_dialog.f90") target_link_libraries(hl_dialog gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_list1 "hl_list1.f90") target_link_libraries(hl_list1 gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_list_n "hl_list_n.f90") target_link_libraries(hl_list_n gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_menu "hl_menu.f90") target_link_libraries(hl_menu gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_pbar "hl_pbar.f90") target_link_libraries(hl_pbar gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_pbar_p "hl_pbar_p.f90") target_link_libraries(hl_pbar_p gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_radio "hl_radio.f90") target_link_libraries(hl_radio gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_sliders "hl_sliders.f90") target_link_libraries(hl_sliders gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_textview "hl_textview.f90") target_link_libraries(hl_textview gtk-fortran_static ${GTK_LIBRARIES})

add_executable(hl_tree "hl_tree.f90") target_link_libraries(hl_tree gtk-fortran_static ${GTK_LIBRARIES})

add_executable(julia_pixbuf "julia_pixbuf.f90") target_link_libraries(julia_pixbuf gtk-fortran_static ${GTK_LIBRARIES})

add_executable(list_demo "list_demo.f90") target_link_libraries(list_demo gtk-fortran_static ${GTK_LIBRARIES})

add_executable(mandelbrot "mandelbrot.f90") target_link_libraries(mandelbrot gtk-fortran_static ${GTK_LIBRARIES})

add_executable(mandelbrot_pixbuf "mandelbrot_pixbuf.f90") target_link_libraries(mandelbrot_pixbuf gtk-fortran_static ${GTK_LIBRARIES})

add_executable(menu "menu.f90") target_link_libraries(menu gtk-fortran_static ${GTK_LIBRARIES})

add_executable(notebooks "notebooks.f90") target_link_libraries(notebooks gtk-fortran_static ${GTK_LIBRARIES})

!==========================! != ./tests/CMakelist.txt: =! !==========================!

include_directories("/usr/include") include_directories("/usr/local/include") include_directories("${CMAKE_BINARY_DIR}/src") include_directories(${GTK_INCLUDES})

add_executable(tests "tests.f90") target_link_libraries(tests gtk-fortran_static ${GTK_LIBRARIES}) add_test(tests ${EXECUTABLE_OUTPUT_PATH}/tests)

!=====================================! != ./cmake/cmake_uninstall.cmake.in: =! !=====================================!

if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach (file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") if (EXISTS "$ENV{DESTDIR}${file}") execute_process( COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval ) if(NOT ${rm_retval} EQUAL 0) message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") endif (NOT ${rm_retval} EQUAL 0) else (EXISTS "$ENV{DESTDIR}${file}") message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") endif (EXISTS "$ENV{DESTDIR}${file}") endforeach(file)

!===============! != ./Doxyfile: =! !===============!

DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = gtk-fortran PROJECT_NUMBER = OUTPUT_DIRECTORY = CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 3 ALIASES = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = YES OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES TYPEDEF_HIDES_STRUCT = NO SYMBOL_CACHE_SIZE = 0 EXTRACT_ALL = YES EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = NO HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_MEMBERS_CTORS_1ST = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_DIRECTORIES = NO SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = LAYOUT_FILE = QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = INPUT = ${PROJECT_SOURCE_DIR}/src INPUT_ENCODING = UTF-8 FILE_PATTERNS = .c \ .cc \ .cxx \ .cpp \ .c++ \ .d \ .java \ .ii \ .ixx \ .ipp \ .i++ \ .inl \ .h \ .hh \ .hxx \ .hpp \ .h++ \ .idl \ .odl \ .cs \ .php \ .php3 \ .inc \ .m \ .mm \ .dox \ .py \ .f90 \ .f \ .vhd \ .vhdl RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO SOURCE_BROWSER = YES INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES USE_HTAGS = NO VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES HTML_ALIGN_MEMBERS = YES HTML_DYNAMIC_SECTIONS = NO GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project DOCSET_PUBLISHER_ID = org.doxygen.Publisher DOCSET_PUBLISHER_NAME = Publisher GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO CHM_INDEX_ENCODING = BINARY_TOC = NO TOC_EXPAND = NO GENERATE_QHP = NO QCH_FILE = QHP_NAMESPACE = org.doxygen.Project QHP_VIRTUAL_FOLDER = doc QHP_CUST_FILTER_NAME = QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = QHG_LOCATION = GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO USE_INLINE_TREES = NO TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES SEARCHENGINE = YES SERVER_BASED_SEARCH = NO GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO GENERATE_XML = NO XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES GENERATE_AUTOGEN_DEF = NO GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = NO MSCGEN_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES DOT_NUM_THREADS = 0 DOT_FONTNAME = FreeSans.ttf DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = YES CALLER_GRAPH = YES GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES

jtappin commented 13 years ago

Many thanks for that. I'll download it and give it a test run this evening.

jtappin commented 13 years ago

Just to let folks know that it works on my system.

I need to go through the files and make sure I understand at least approximately what the different bits do. I'll probably have a few questions in a day or so.

jtappin commented 13 years ago

I guess there are just a few issues to be resolved

  1. cmake doesn't yet support GTK3 out of the box. I have made a FindGTK3.cmake by hacking at the GTK2 version. It works on Debian Sid. (The modified cmake file is appended at the end of this posting). There is a warning message that appears to be harmless:

     -- Some or all of the gtk libraries were not found. (missing:  GTK3_GDKCONFIG_INCLUDE_DIR) 
  2. Do we need the Doxygen stuff? It does produce quite a convenient listing of the API, but it's quite a bit of baggage. (Vincent, Jerry -- any thoughts here).
  3. I have added a GPL 3 copyright statement to the various CMake scripts. -- Is that OK?

FindGTK3.cmake

To build the Gtk3 branch this needs to in the cmake search path.

# - FindGTK3.cmake
# This module can find the GTK3 widget libraries and several of its other
# optional components like gtkmm, glade, and glademm.
#
# NOTE: If you intend to use version checking, CMake 2.6.2 or later is
#       required.
#
# Specify one or more of the following components
# as you call this find module. See example below.
#
#   gtk
#   gtkmm
#   glade
#   glademm
#
# The following variables will be defined for your use
#
#   GTK3_FOUND - Were all of your specified components found?
#   GTK3_INCLUDE_DIRS - All include directories
#   GTK3_LIBRARIES - All libraries
#
#   GTK3_VERSION - The version of GTK3 found (x.y.z)
#   GTK3_MAJOR_VERSION - The major version of GTK3
#   GTK3_MINOR_VERSION - The minor version of GTK3
#   GTK3_PATCH_VERSION - The patch version of GTK3
#
# Optional variables you can define prior to calling this module:
#
#   GTK3_DEBUG - Enables verbose debugging of the module
#   GTK3_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced
#   GTK3_ADDITIONAL_SUFFIXES - Allows defining additional directories to
#                              search for include files
#
#=================
# Example Usage:
#
#   Call find_package() once, here are some examples to pick from:
#
#   Require GTK 3.0 or later
#       find_package(GTK3 3.0 REQUIRED gtk)
#
#   if(GTK3_FOUND)
#      include_directories(${GTK3_INCLUDE_DIRS})
#      add_executable(mygui mygui.cc)
#      target_link_libraries(mygui ${GTK3_LIBRARIES})
#   endif()
#

#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2008-2009 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)

# Version 0.1 (5/13/2011)
#   * First cut at a GTK3 version (Heavily derived from 
#     FindGTK2.cmake)

#=============================================================
# _GTK3_GET_VERSION
# Internal function to parse the version number in gtkversion.h
#   _OUT_major = Major version number
#   _OUT_minor = Minor version number
#   _OUT_micro = Micro version number
#   _gtkversion_hdr = Header file to parse
#=============================================================
function(_GTK3_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr)
    file(READ ${_gtkversion_hdr} _contents)
    if(_contents)
        string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}")
        string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}")
        string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}")

        if(NOT ${_OUT_major} MATCHES "[0-9]+")
            message(FATAL_ERROR "Version parsing failed for GTK3_MAJOR_VERSION!")
        endif()
        if(NOT ${_OUT_minor} MATCHES "[0-9]+")
            message(FATAL_ERROR "Version parsing failed for GTK3_MINOR_VERSION!")
        endif()
        if(NOT ${_OUT_micro} MATCHES "[0-9]+")
            message(FATAL_ERROR "Version parsing failed for GTK3_MICRO_VERSION!")
        endif()

        set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
        set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
        set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
    else()
        message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist")
    endif()
endfunction()

#=============================================================
# _GTK3_FIND_INCLUDE_DIR
# Internal function to find the GTK include directories
#   _var = variable to set
#   _hdr = header file to look for
#=============================================================
function(_GTK3_FIND_INCLUDE_DIR _var _hdr)

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] "
                       "_GTK3_FIND_INCLUDE_DIR( ${_var} ${_hdr} )")
    endif()

    set(_relatives
        # If these ever change, things will break.
        ${GTK3_ADDITIONAL_SUFFIXES}
        glibmm-2.0
        glib-2.0
        atk-1.0
        atkmm-1.0
        cairo
        cairomm-1.0
        gdk-pixbuf-2.0
        gdkmm-2.4
        giomm-2.4
        gtk-3.0
        gtkmm-2.4
        libglade-2.0
        libglademm-2.4
        pango-1.0
        pangomm-1.4
        sigc++-2.2
    gtk-unix-print-2.0
    )

    set(_suffixes)
    foreach(_d ${_relatives})
        list(APPEND _suffixes ${_d})
        list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include
    endforeach()

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
                       "include suffixes = ${_suffixes}")
    endif()

    find_path(${_var} ${_hdr}
        PATHS
            /usr/local/lib64
            /usr/local/lib
            /usr/lib64
            /usr/lib
            /opt/gnome/include
            /opt/gnome/lib
            /opt/openwin/include
            /usr/openwin/lib
            /sw/include
            /sw/lib
            /opt/local/include
            /opt/local/lib
            $ENV{GTKMM_BASEPATH}/include
            $ENV{GTKMM_BASEPATH}/lib
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
        PATH_SUFFIXES
            ${_suffixes}
    )

    if(${_var})
        set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE)
        if(NOT GTK3_SKIP_MARK_AS_ADVANCED)
            mark_as_advanced(${_var})
        endif()
    endif()

endfunction(_GTK3_FIND_INCLUDE_DIR)

#=============================================================
# _GTK3_FIND_LIBRARY
# Internal function to find libraries packaged with GTK3
#   _var = library variable to create
#=============================================================
function(_GTK3_FIND_LIBRARY _var _lib _expand_vc _append_version)

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] "
                       "_GTK3_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )")
    endif()

    # Not GTK versions per se but the versions encoded into Windows
    # import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example)
    # Also the MSVC libraries use _ for . (this is handled below)
    # ********* SOMEONE WITH WINDOWS NEEDS TO CHECK THIS BIT FOR V3 *********
    # ********* the plain 3 is needed to get Debian Sid to find the libraries
     set(_versions 3.0 3 2.20 2.18 2.16 2.14 2.12
                   2.10  2.8  2.6  2.4  2.2 2.0
                   1.20 1.18 1.16 1.14 1.12
                   1.10  1.8  1.6  1.4  1.2 1.0)

    set(_library)
    set(_library_d)

    set(_library ${_lib})

    if(_expand_vc AND MSVC)
        # Add vc80/vc90/vc100 midfixes
        if(MSVC80)
            set(_library   ${_library}-vc80)
        elseif(MSVC90)
            set(_library   ${_library}-vc90)
        elseif(MSVC10)
            set(_library ${_library}-vc100)
        endif()
        set(_library_d ${_library}-d)
    endif()

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
                       "After midfix addition = ${_library} and ${_library_d}")
    endif()

    set(_lib_list)
    set(_libd_list)
    if(_append_version)
        foreach(_ver ${_versions})
            list(APPEND _lib_list  "${_library}-${_ver}")
            list(APPEND _libd_list "${_library_d}-${_ver}")
        endforeach()
    else()
        set(_lib_list ${_library})
        set(_libd_list ${_library_d})
    endif()

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
                       "library list = ${_lib_list} and library debug list = ${_libd_list}")
    endif()

    # For some silly reason the MSVC libraries use _ instead of .
    # in the version fields
    if(_expand_vc AND MSVC)
        set(_no_dots_lib_list)
        set(_no_dots_libd_list)
        foreach(_l ${_lib_list})
            string(REPLACE "." "_" _no_dots_library ${_l})
            list(APPEND _no_dots_lib_list ${_no_dots_library})
        endforeach()
        # And for debug
        set(_no_dots_libsd_list)
        foreach(_l ${_libd_list})
            string(REPLACE "." "_" _no_dots_libraryd ${_l})
            list(APPEND _no_dots_libd_list ${_no_dots_libraryd})
        endforeach()

        # Copy list back to original names
        set(_lib_list ${_no_dots_lib_list})
        set(_libd_list ${_no_dots_libd_list})
    endif()

    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
                       "While searching for ${_var}, our proposed library list is ${_lib_list}")
    endif()

    find_library(${_var} 
        NAMES ${_lib_list}
        PATHS
            /opt/gnome/lib
            /opt/gnome/lib64
            /usr/openwin/lib
            /usr/openwin/lib64
            /sw/lib
            $ENV{GTKMM_BASEPATH}/lib
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
        )

    if(_expand_vc AND MSVC)
        if(GTK3_DEBUG)
            message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}]     "
                           "While searching for ${_var}_DEBUG our proposed library list is ${_libd_list}")
        endif()

        find_library(${_var}_DEBUG
            NAMES ${_libd_list}
            PATHS
            $ENV{GTKMM_BASEPATH}/lib
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
        )

        if(${_var} AND ${_var}_DEBUG)
            if(NOT GTK3_SKIP_MARK_AS_ADVANCED)
                mark_as_advanced(${_var}_DEBUG)
            endif()
            set(GTK3_LIBRARIES ${GTK3_LIBRARIES} optimized ${${_var}} debug ${${_var}_DEBUG})
            set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE)
        endif()
    else()
        if(NOT GTK3_SKIP_MARK_AS_ADVANCED)
            mark_as_advanced(${_var})
        endif()
        set(GTK3_LIBRARIES ${GTK3_LIBRARIES} ${${_var}})
        set(GTK3_LIBRARIES ${GTK3_LIBRARIES} PARENT_SCOPE)
        # Set debug to release
        set(${_var}_DEBUG ${${_var}})
        set(${_var}_DEBUG ${${_var}} PARENT_SCOPE)
    endif()
endfunction(_GTK3_FIND_LIBRARY)

#=============================================================

#
# main()
#

set(GTK3_FOUND)
set(GTK3_INCLUDE_DIRS)
set(GTK3_LIBRARIES)

if(NOT GTK3_FIND_COMPONENTS)
    # Assume they only want GTK
    set(GTK3_FIND_COMPONENTS gtk)
endif()

#
# If specified, enforce version number
#
if(GTK3_FIND_VERSION)
    cmake_minimum_required(VERSION 2.6.2)
    set(GTK3_FAILED_VERSION_CHECK true)
    if(GTK3_DEBUG)
        message(STATUS "[FindGTK3.cmake:${CMAKE_CURRENT_LIST_LINE}] "
                       "Searching for version ${GTK3_FIND_VERSION}")
    endif()
    _GTK3_FIND_INCLUDE_DIR(GTK3_GTK_INCLUDE_DIR gtk/gtk.h)
    if(GTK3_GTK_INCLUDE_DIR)
        _GTK3_GET_VERSION(GTK3_MAJOR_VERSION
                          GTK3_MINOR_VERSION
                          GTK3_PATCH_VERSION
                          ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
        set(GTK3_VERSION
            ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION})
        if(GTK3_FIND_VERSION_EXACT)
            if(GTK3_VERSION VERSION_EQUAL GTK3_FIND_VERSION)
                set(GTK3_FAILED_VERSION_CHECK false)
            endif()
        else()
            if(GTK3_VERSION VERSION_EQUAL   GTK3_FIND_VERSION OR
               GTK3_VERSION VERSION_GREATER GTK3_FIND_VERSION)
                set(GTK3_FAILED_VERSION_CHECK false)
            endif()
        endif()
    else()
        # If we can't find the GTK include dir, we can't do version checking
        if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY)
            message(FATAL_ERROR "Could not find GTK3 include directory")
        endif()
        return()
    endif()

    if(GTK3_FAILED_VERSION_CHECK)
        if(GTK3_FIND_REQUIRED AND NOT GTK3_FIND_QUIETLY)
            if(GTK3_FIND_VERSION_EXACT)
                message(FATAL_ERROR "GTK3 version check failed.  Version ${GTK3_VERSION} was found, version ${GTK3_FIND_VERSION} is needed exactly.")
            else()
                message(FATAL_ERROR "GTK3 version check failed.  Version ${GTK3_VERSION} was found, at least version ${GTK3_FIND_VERSION} is required")
            endif()
        endif()    

        # If the version check fails, exit out of the module here
        return()
    endif()
endif()

#
# Find all components
#

find_package(Freetype)
list(APPEND GTK3_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
list(APPEND GTK3_LIBRARIES ${FREETYPE_LIBRARIES})

foreach(_GTK3_component ${GTK3_FIND_COMPONENTS})
    if(_GTK3_component STREQUAL "gtk")
        _GTK3_FIND_INCLUDE_DIR(GTK3_GLIB_INCLUDE_DIR glib.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GLIBCONFIG_INCLUDE_DIR glibconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GLIB_LIBRARY glib false true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GOBJECT_INCLUDE_DIR gobject/gobject.h)
        _GTK3_FIND_LIBRARY    (GTK3_GOBJECT_LIBRARY gobject false true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h)
        _GTK3_FIND_LIBRARY    (GTK3_GDK_PIXBUF_LIBRARY gdk_pixbuf false true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GDK_INCLUDE_DIR gdk/gdk.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GDKCONFIG_INCLUDE_DIR gdkconfig.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GTK_INCLUDE_DIR gtk/gtk.h)

 # ********* At least on Debian the gdk & gtk libraries
 # ********* don't have the -x11 suffix.
        if(UNIX)
            _GTK3_FIND_LIBRARY    (GTK3_GDK_LIBRARY gdk false true)
            _GTK3_FIND_LIBRARY    (GTK3_GTK_LIBRARY gtk false true)
        else()
            _GTK3_FIND_LIBRARY    (GTK3_GDK_LIBRARY gdk-win32 false true)
            _GTK3_FIND_LIBRARY    (GTK3_GTK_LIBRARY gtk-win32 false true)
        endif()

        _GTK3_FIND_INCLUDE_DIR(GTK3_CAIRO_INCLUDE_DIR cairo.h)
        _GTK3_FIND_LIBRARY    (GTK3_CAIRO_LIBRARY cairo false false)

        _GTK3_FIND_INCLUDE_DIR(GTK3_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)

        _GTK3_FIND_INCLUDE_DIR(GTK3_PANGO_INCLUDE_DIR pango/pango.h)
        _GTK3_FIND_LIBRARY    (GTK3_PANGO_LIBRARY pango false true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_ATK_INCLUDE_DIR atk/atk.h)
        _GTK3_FIND_LIBRARY    (GTK3_ATK_LIBRARY atk false true)

    elseif(_GTK3_component STREQUAL "gtkmm")

        _GTK3_FIND_INCLUDE_DIR(GTK3_GLIBMM_INCLUDE_DIR glibmm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GLIBMM_LIBRARY glibmm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GDKMM_INCLUDE_DIR gdkmm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GDKMM_LIBRARY gdkmm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GTKMM_INCLUDE_DIR gtkmm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GTKMM_LIBRARY gtkmm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_CAIROMM_INCLUDE_DIR cairomm/cairomm.h)
        _GTK3_FIND_LIBRARY    (GTK3_CAIROMM_LIBRARY cairomm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_PANGOMM_INCLUDE_DIR pangomm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_PANGOMM_LIBRARY pangomm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_SIGC++_INCLUDE_DIR sigc++/sigc++.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_SIGC++CONFIG_INCLUDE_DIR sigc++config.h)
        _GTK3_FIND_LIBRARY    (GTK3_SIGC++_LIBRARY sigc true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_GIOMM_INCLUDE_DIR giomm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GIOMMCONFIG_INCLUDE_DIR giommconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GIOMM_LIBRARY giomm true true)

        _GTK3_FIND_INCLUDE_DIR(GTK3_ATKMM_INCLUDE_DIR atkmm.h)
        _GTK3_FIND_LIBRARY    (GTK3_ATKMM_LIBRARY atkmm true true)

    elseif(_GTK3_component STREQUAL "glade")

        _GTK3_FIND_INCLUDE_DIR(GTK3_GLADE_INCLUDE_DIR glade/glade.h)
        _GTK3_FIND_LIBRARY    (GTK3_GLADE_LIBRARY glade false true)

    elseif(_GTK3_component STREQUAL "glademm")

        _GTK3_FIND_INCLUDE_DIR(GTK3_GLADEMM_INCLUDE_DIR libglademm.h)
        _GTK3_FIND_INCLUDE_DIR(GTK3_GLADEMMCONFIG_INCLUDE_DIR libglademmconfig.h)
        _GTK3_FIND_LIBRARY    (GTK3_GLADEMM_LIBRARY glademm true true)

    else()
        message(FATAL_ERROR "Unknown GTK3 component ${_component}")
    endif()
endforeach()

#
# Solve for the GTK3 version if we haven't already
#
if(NOT GTK3_FIND_VERSION AND GTK3_GTK_INCLUDE_DIR)
    _GTK3_GET_VERSION(GTK3_MAJOR_VERSION
                      GTK3_MINOR_VERSION
                      GTK3_PATCH_VERSION
                      ${GTK3_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
    set(GTK3_VERSION ${GTK3_MAJOR_VERSION}.${GTK3_MINOR_VERSION}.${GTK3_PATCH_VERSION})
endif()

#
# Try to enforce components
#

set(_GTK3_did_we_find_everything true)  # This gets set to GTK3_FOUND

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)

foreach(_GTK3_component ${GTK3_FIND_COMPONENTS})
    string(TOUPPER ${_GTK3_component} _COMPONENT_UPPER)

    if(_GTK3_component STREQUAL "gtk")
        FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found."
            GTK3_GTK_LIBRARY
            GTK3_GTK_INCLUDE_DIR

            GTK3_GLIB_INCLUDE_DIR
            GTK3_GLIBCONFIG_INCLUDE_DIR
            GTK3_GLIB_LIBRARY

            GTK3_GDK_INCLUDE_DIR
            GTK3_GDKCONFIG_INCLUDE_DIR
            GTK3_GDK_LIBRARY
        )
    elseif(_GTK3_component STREQUAL "gtkmm")
        FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found."
            GTK3_GTKMM_LIBRARY
            GTK3_GTKMM_INCLUDE_DIR
            GTK3_GTKMMCONFIG_INCLUDE_DIR

            GTK3_GLIBMM_INCLUDE_DIR
            GTK3_GLIBMMCONFIG_INCLUDE_DIR
            GTK3_GLIBMM_LIBRARY

            GTK3_GDKMM_INCLUDE_DIR
            GTK3_GDKMMCONFIG_INCLUDE_DIR
            GTK3_GDKMM_LIBRARY
        )
    elseif(_GTK3_component STREQUAL "glade")
        FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "The glade library was not found."
            GTK3_GLADE_LIBRARY
            GTK3_GLADE_INCLUDE_DIR
        )
    elseif(_GTK3_component STREQUAL "glademm")
        FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3_${_COMPONENT_UPPER} "The glademm library was not found."
            GTK3_GLADEMM_LIBRARY
            GTK3_GLADEMM_INCLUDE_DIR
            GTK3_GLADEMMCONFIG_INCLUDE_DIR
        )
    endif()

    if(NOT GTK3_${_COMPONENT_UPPER}_FOUND)
        set(_GTK3_did_we_find_everything false)
    endif()
endforeach()

if(_GTK3_did_we_find_everything AND NOT GTK3_VERSION_CHECK_FAILED)
    set(GTK3_FOUND true)
else()
    # Unset our variables.
    set(GTK3_FOUND false)
    set(GTK3_VERSION)
    set(GTK3_VERSION_MAJOR)
    set(GTK3_VERSION_MINOR)
    set(GTK3_VERSION_PATCH)
    set(GTK3_INCLUDE_DIRS)
    set(GTK3_LIBRARIES)
endif()

if(GTK3_INCLUDE_DIRS)
   list(REMOVE_DUPLICATES GTK3_INCLUDE_DIRS)
endif()
hornekyle commented 13 years ago

So to reply to your issues in order:

  1. So long as the FindGTK3 seems to work, I think that it will be a find stopgap until an official module is released for GTK3. It is pretty normal for cmake to need a few modules.
  2. I'm not really sure what you mean by calling the Doxygen stuff lots of baggage, since it's a single file and a few lines of code, but ultimately it's inclusion and or exclusion is not a big deal. I like to see projects with Doxygen output, but that is my own preference.
  3. The GPL3 is just fine, so long as its compatible with the rest of the code.

Kyle Horne

jtappin commented 13 years ago

My comments on doxygen and baggage were more related to the need to install extra packages, and also the fact that generating the doxygen html produces more than 10,000 files.

If there were a convenient way to merge the doxygen output into the Wiki it would definitely be worthwhile (and more convenient than my RYO documentation tool for the high-level stuff), but as yet the only way I've found to get anything into the Wiki from a file on my system is to copy & paste.

jtappin commented 13 years ago

Now I'm seeing an error with both gtkbuilder & gtkbuilder2 that does not occur with either my hand-rolled Makefiles nor with the tests.sh script (both of which make use of pkg_config), and that is that the gtk_builder_get_object(builder, "window"//cnull) call is not returning a valid window.

This happens with both the Gtk2 and Gtk3 versions. So I'm not sure if there's a library that's needed.

Also on Gtk3 only, when I enabled the debug options all the examples fail with a floating-point exception as soon as I move the cursor over the widget.

jtappin commented 13 years ago

D'Oh!

I realized that by doing an out of source build, I've not copied the .glade file.

Is there an easy way in cmake to specify a target that just to be copied from one place to another?

jtappin commented 13 years ago

I've committed the Gtk2 version to the master branch.

There's still a bit of code tidying to do before I can commit the Gtk3 version.

hornekyle commented 13 years ago

What kinds of things can I help with now? I have been considering writing a DISLIN replacement using gtk-fortran as a foundation. DISLIN is capable, but very old and lack some nicer features that I could put into a new plotting package. This would be along the lines of the high level routines, and intended to ease the development of scientific software, which is what I write most of the time.

Kyle Horne

jtappin commented 13 years ago

I've now uploaded the Gtk3 version.

N.B. There is an error where all examples fail with a floating-point exception if built with the debug option.

vmagnin commented 13 years ago

Hi Kyle, yes a plotting package built on gtk-fortran would be great. Jerry D. told me he began working on a plotting class but I have no news. You can send him a message. We have also considered GtkExtra, but it seems it is not maintained continuously and it is not packaged in distributions (see https://github.com/jerryd/gtk-fortran/issues/11). With Cairo and GdkPixbuf, nice plots could probably be made. I have currently no time to deepen my exploration of those libraries. But if you are motivated it would be a major contribution.

vmagnin commented 13 years ago

Hi Kyle and James, I am now learning to use CMake but have encountered two problems:

1) The following messages:

-- Some or all of the gtk libraries were not found. (missing:  GTK2_GLIBCONFIG_INCLUDE_DIR) 
...
-- Configuring incomplete, errors occurred!

2) CMake is using gfortran 4.5 (the official Ubuntu package) instead of the gfortran 4.6 I have installed beside. And so the make command fails because of the 4.5 bug.

Concerning Doxygen I will look at it when I will be OK with CMake.

Vincent Ubuntu 11.04 - 32 bits

vmagnin commented 13 years ago

On a PC with Ubuntu 11.04 - 64 bits, I successfully launched cmake and make. But when I try to run an example, I get the following message:

./mandelbrot_pixbuf: error while loading shared libraries: libquadmath.so.0: cannot open shared object file: No such file or directory

On my 32 bits PCs, after cleaning the build directory, the "Configuring incomplete, errors occurred!" message disappeared, but I still have the gfortran 4.5 problem.

vmagnin commented 13 years ago

Under Fedora 15 - 32 bits, everything is OK (gtk3 branch). No problem with gfortran because Fedora 15 comes natively with GCC 4.6.

jtappin commented 13 years ago

Hi Vincent, I'm not quite sure what is the correct solution to the libquadmath issue -- I think it's really a bug in the gfortran 64-bit snapshots. The work-around is to add /opt/gcc-trunk/lib64 (or wherever you have your snapshot installed) to the library search path, either with LD_LIBRARY_PATH or a link option. I thought that if that was set when cmake was invoked it was added to the makefiles but this does not appear to be the case. The problem is that because we are using snapshots on some systems and regular installs on others, there's no really portable fix that I can see, I did try renaming lib as lib32 and lib64 as lib but then the compiler wouldn't run.

Likewise with the compiler, the Fortran search (at least as far as I understand it -- which isn't very far) looks for the various commercial Fortran compilers and then the free ones -- on all my systems, provided I have 4.6 ahead of 4.(<6) in my PATH at the time cmake is invoked it works, as cmake puts a full path to the Fortran compiler in the makefiles. If it has the wrong version, you may need to clean out the build dir to correct it (one of the main arguments for an out-of-source build).

I think the GTK2_GLIBCONFIG_INCLUDE_DIR problem looks like one of a number of issues where things aren't as clean as they ought to be when the underlying system changes (and I really don't have much feel for whether that is a problem with our build files or cmake itself). Another that I'm aware of is that if I have gtk-fortran installed and then add something to the high-level interface, I have to either uninstall or do a make and reinstall between modifying the library and adding the feature into the examples.

I think that's about as far as I can get, Kyle do you have any more insights?

vmagnin commented 13 years ago

Hi James, I will make some tests.

Anyway, I think Kyle has brought us a great tool ! In particular, the pkg-config file is very useful. Note that under Fedora 15 I was obliged to export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Concerning Doxygen, it seems the big stuff comes from the Latex docs. And what are the basics to use Doxygen ? (I have found nothing interesting in the build/CMakeFiles/doxygen.dir directory).