diff --git a/CMakeLists.txt b/CMakeLists.txt index 63188366..44507521 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,8 @@ -cmake_minimum_required(VERSION 2.6) +# cmake 2.6 might suffice, but we don't test it (even Debian stable has 2.8.2) +cmake_minimum_required(VERSION 2.8.2) +# system cmake modules take precedence over those in CMAKE_MODULE_PATH +# (makes cmake 2.8.7 happy) +cmake_policy(SET CMP0017 NEW) PROJECT(Fail*) @@ -21,18 +25,16 @@ SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(compilerconfig) #### #OPTION to configure Bochs/OVP #### -OPTION( BUILD_OVP "Build OVP Variant?" OFF) # Defaults to BOCHS ON -OPTION( BUILD_BOCHS "Build Bochs Variant?" ON) +OPTION(BUILD_OVP "Build OVP Variant?" OFF) # Defaults to BOCHS ON +OPTION(BUILD_BOCHS "Build Bochs Variant?" ON) -if(BUILD_OVP) - message(STATUS "[${PROJECT_NAME}] Building OVP variant...") - SET(VARIANT ovp) -else(BUILD_OVP) - message(STATUS "[${PROJECT_NAME}] Building Bochs variant...") +if(BUILD_BOCHS) ## add necessary additional header search paths. - add_definitions(-I${CMAKE_SOURCE_DIR}/simulators/bochs/instrument/stubs/ -I${CMAKE_SOURCE_DIR}/simulators/bochs) - SET(VARIANT bochs) -endif(BUILD_OVP) + #add_definitions(-I${CMAKE_SOURCE_DIR}/simulators/bochs/instrument/stubs/ -I${CMAKE_SOURCE_DIR}/simulators/bochs) + include_directories(simulators/bochs/instrument/stubs simulators/bochs) +elseif(BUILD_OVP) + add_subdirectory(simulators/ovp) +endif(BUILD_BOCHS) ## Additional Compiler flags ## set(CMAKE_C_FLAGS "-g -Wall") @@ -48,10 +50,9 @@ include_directories(${CMAKE_BINARY_DIR}/src/core) ## Add CMakeLists from subdirectories: add_subdirectory(src) -if(BUILD_OVP) - add_subdirectory(simulators/ovp) -else(BUILD_OVP) -endif(BUILD_OVP) +#### Backend-related build system stuff +include(bochs) +include(ovp) ## Just for testing: ## Invoking bochs build via external project diff --git a/cmake/CMakeParseArguments.cmake b/cmake/CMakeParseArguments.cmake new file mode 100644 index 00000000..7ce4c49a --- /dev/null +++ b/cmake/CMakeParseArguments.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS( args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in , and +# a variable composed of the given +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 Alexander Neundorf +# +# 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.) + + +if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach(currentArg) + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake new file mode 100644 index 00000000..f6d9b38a --- /dev/null +++ b/cmake/FindGTK2.cmake @@ -0,0 +1,596 @@ +# - FindGTK2.cmake +# This module can find the GTK2 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 +# +# GTK2_FOUND - Were all of your specified components found? +# GTK2_INCLUDE_DIRS - All include directories +# GTK2_LIBRARIES - All libraries +# +# GTK2_VERSION - The version of GTK2 found (x.y.z) +# GTK2_MAJOR_VERSION - The major version of GTK2 +# GTK2_MINOR_VERSION - The minor version of GTK2 +# GTK2_PATCH_VERSION - The patch version of GTK2 +# +# Optional variables you can define prior to calling this module: +# +# GTK2_DEBUG - Enables verbose debugging of the module +# GTK2_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced +# GTK2_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 2.6 or later +# find_package(GTK2 2.6 REQUIRED gtk) +# +# Require GTK 2.10 or later and Glade +# find_package(GTK2 2.10 REQUIRED gtk glade) +# +# Search for GTK/GTKMM 2.8 or later +# find_package(GTK2 2.8 COMPONENTS gtk gtkmm) +# +# if(GTK2_FOUND) +# include_directories(${GTK2_INCLUDE_DIRS}) +# add_executable(mygui mygui.cc) +# target_link_libraries(mygui ${GTK2_LIBRARIES}) +# endif() +# + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2008-2009 Philip Lowman +# +# 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 1.3 (11/9/2010) (CMake 2.8.4) +# * 11429: Add support for detecting GTK2 built with Visual Studio 10. +# Thanks to Vincent Levesque for the patch. + +# Version 1.2 (8/30/2010) (CMake 2.8.3) +# * Merge patch for detecting gdk-pixbuf library (split off +# from core GTK in 2.21). Thanks to Vincent Untz for the patch +# and Ricardo Cruz for the heads up. +# Version 1.1 (8/19/2010) (CMake 2.8.3) +# * Add support for detecting GTK2 under macports (thanks to Gary Kramlich) +# Version 1.0 (8/12/2010) (CMake 2.8.3) +# * Add support for detecting new pangommconfig.h header file +# (Thanks to Sune Vuorela & the Debian Project for the patch) +# * Add support for detecting fontconfig.h header +# * Call find_package(Freetype) since it's required +# * Add support for allowing users to add additional library directories +# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in +# case the GTK developers change versions on any of the directories in the +# future). +# Version 0.8 (1/4/2010) +# * Get module working under MacOSX fink by adding /sw/include, /sw/lib +# to PATHS and the gobject library +# Version 0.7 (3/22/09) +# * Checked into CMake CVS +# * Added versioning support +# * Module now defaults to searching for GTK if COMPONENTS not specified. +# * Added HKCU prior to HKLM registry key and GTKMM specific environment +# variable as per mailing list discussion. +# * Added lib64 to include search path and a few other search paths where GTK +# may be installed on Unix systems. +# * Switched to lowercase CMake commands +# * Prefaced internal variables with _GTK2 to prevent collision +# * Changed internal macros to functions +# * Enhanced documentation +# Version 0.6 (1/8/08) +# Added GTK2_SKIP_MARK_AS_ADVANCED option +# Version 0.5 (12/19/08) +# Second release to cmake mailing list + +#============================================================= +# _GTK2_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(_GTK2_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 GTK2_MAJOR_VERSION!") + endif() + if(NOT ${_OUT_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK2_MINOR_VERSION!") + endif() + if(NOT ${_OUT_micro} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for GTK2_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() + +#============================================================= +# _GTK2_FIND_INCLUDE_DIR +# Internal function to find the GTK include directories +# _var = variable to set +# _hdr = header file to look for +#============================================================= +function(_GTK2_FIND_INCLUDE_DIR _var _hdr) + + if(GTK2_DEBUG) + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK2_FIND_INCLUDE_DIR( ${_var} ${_hdr} )") + endif() + + set(_relatives + # If these ever change, things will break. + ${GTK2_ADDITIONAL_SUFFIXES} + glibmm-2.4 + glib-2.0 + atk-1.0 + atkmm-1.6 + cairo + cairomm-1.0 + gdk-pixbuf-2.0 + gdkmm-2.4 + giomm-2.4 + gtk-2.0 + gtkmm-2.4 + libglade-2.0 + libglademm-2.4 + pango-1.0 + pangomm-1.4 + sigc++-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(GTK2_DEBUG) + message(STATUS "[FindGTK2.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(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE) + if(NOT GTK2_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}) + endif() + endif() + +endfunction(_GTK2_FIND_INCLUDE_DIR) + +#============================================================= +# _GTK2_FIND_LIBRARY +# Internal function to find libraries packaged with GTK2 +# _var = library variable to create +#============================================================= +function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) + + if(GTK2_DEBUG) + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "_GTK2_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) + set(_versions 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(GTK2_DEBUG) + message(STATUS "[FindGTK2.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(GTK2_DEBUG) + message(STATUS "[FindGTK2.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(GTK2_DEBUG) + message(STATUS "[FindGTK2.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(GTK2_DEBUG) + message(STATUS "[FindGTK2.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 GTK2_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}_DEBUG) + endif() + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} optimized ${${_var}} debug ${${_var}_DEBUG}) + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE) + endif() + else() + if(NOT GTK2_SKIP_MARK_AS_ADVANCED) + mark_as_advanced(${_var}) + endif() + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${${_var}}) + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE) + # Set debug to release + set(${_var}_DEBUG ${${_var}}) + set(${_var}_DEBUG ${${_var}} PARENT_SCOPE) + endif() +endfunction(_GTK2_FIND_LIBRARY) + +#============================================================= + +# +# main() +# + +set(GTK2_FOUND) +set(GTK2_INCLUDE_DIRS) +set(GTK2_LIBRARIES) + +if(NOT GTK2_FIND_COMPONENTS) + # Assume they only want GTK + set(GTK2_FIND_COMPONENTS gtk) +endif() + +# +# If specified, enforce version number +# +if(GTK2_FIND_VERSION) + cmake_minimum_required(VERSION 2.6.2) + set(GTK2_FAILED_VERSION_CHECK true) + if(GTK2_DEBUG) + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "Searching for version ${GTK2_FIND_VERSION}") + endif() + _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) + if(GTK2_GTK_INCLUDE_DIR) + _GTK2_GET_VERSION(GTK2_MAJOR_VERSION + GTK2_MINOR_VERSION + GTK2_PATCH_VERSION + ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK2_VERSION + ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION}) + if(GTK2_FIND_VERSION_EXACT) + if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION) + set(GTK2_FAILED_VERSION_CHECK false) + endif() + else() + if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION OR + GTK2_VERSION VERSION_GREATER GTK2_FIND_VERSION) + set(GTK2_FAILED_VERSION_CHECK false) + endif() + endif() + else() + # If we can't find the GTK include dir, we can't do version checking + if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY) + message(FATAL_ERROR "Could not find GTK2 include directory") + endif() + return() + endif() + + if(GTK2_FAILED_VERSION_CHECK) + if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY) + if(GTK2_FIND_VERSION_EXACT) + message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, version ${GTK2_FIND_VERSION} is needed exactly.") + else() + message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, at least version ${GTK2_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 GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS}) +list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES}) + +foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) + if(_GTK2_component STREQUAL "gtk") + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h) + _GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) + _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) + + if(UNIX) + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) + else() + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + endif() + + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h) + _GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false) + + _GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h) + _GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GIO_INCLUDE_DIR gio.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GIOCONFIG_INCLUDE_DIR gioconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GIO_LIBRARY gio true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h) + _GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true) + + + elseif(_GTK2_component STREQUAL "gtkmm") + + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMM_INCLUDE_DIR glibmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIBMM_LIBRARY glibmm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMM_INCLUDE_DIR gdkmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GDKMM_LIBRARY gdkmm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GTKMM_INCLUDE_DIR gtkmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GTKMM_LIBRARY gtkmm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) + _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG_INCLUDE_DIR sigc++config.h) + _GTK2_FIND_LIBRARY (GTK2_SIGC++_LIBRARY sigc true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMM_INCLUDE_DIR giomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMMCONFIG_INCLUDE_DIR giommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GIOMM_LIBRARY giomm true true) + + _GTK2_FIND_INCLUDE_DIR(GTK2_ATKMM_INCLUDE_DIR atkmm.h) + _GTK2_FIND_LIBRARY (GTK2_ATKMM_LIBRARY atkmm true true) + + elseif(_GTK2_component STREQUAL "glade") + + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADE_INCLUDE_DIR glade/glade.h) + _GTK2_FIND_LIBRARY (GTK2_GLADE_LIBRARY glade false true) + + elseif(_GTK2_component STREQUAL "glademm") + + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMM_INCLUDE_DIR libglademm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMMCONFIG_INCLUDE_DIR libglademmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLADEMM_LIBRARY glademm true true) + + else() + message(FATAL_ERROR "Unknown GTK2 component ${_component}") + endif() +endforeach() + +# +# Solve for the GTK2 version if we haven't already +# +if(NOT GTK2_FIND_VERSION AND GTK2_GTK_INCLUDE_DIR) + _GTK2_GET_VERSION(GTK2_MAJOR_VERSION + GTK2_MINOR_VERSION + GTK2_PATCH_VERSION + ${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h) + set(GTK2_VERSION ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION}) +endif() + +# +# Try to enforce components +# + +set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND + +# CMAKE_CURRENT_LIST_DIR was introduced with cmake 2.8.3 +#include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(cmake/FindPackageHandleStandardArgs.cmake) + +foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) + string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER) + + if(_GTK2_component STREQUAL "gtk") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found." + GTK2_GTK_LIBRARY + GTK2_GTK_INCLUDE_DIR + + GTK2_GLIB_INCLUDE_DIR + GTK2_GLIBCONFIG_INCLUDE_DIR + GTK2_GLIB_LIBRARY + + GTK2_GDK_INCLUDE_DIR + GTK2_GDKCONFIG_INCLUDE_DIR + GTK2_GDK_LIBRARY + ) + elseif(_GTK2_component STREQUAL "gtkmm") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found." + GTK2_GTKMM_LIBRARY + GTK2_GTKMM_INCLUDE_DIR + GTK2_GTKMMCONFIG_INCLUDE_DIR + + GTK2_GLIBMM_INCLUDE_DIR + GTK2_GLIBMMCONFIG_INCLUDE_DIR + GTK2_GLIBMM_LIBRARY + + GTK2_GDKMM_INCLUDE_DIR + GTK2_GDKMMCONFIG_INCLUDE_DIR + GTK2_GDKMM_LIBRARY + ) + elseif(_GTK2_component STREQUAL "glade") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found." + GTK2_GLADE_LIBRARY + GTK2_GLADE_INCLUDE_DIR + ) + elseif(_GTK2_component STREQUAL "glademm") + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glademm library was not found." + GTK2_GLADEMM_LIBRARY + GTK2_GLADEMM_INCLUDE_DIR + GTK2_GLADEMMCONFIG_INCLUDE_DIR + ) + endif() + + if(NOT GTK2_${_COMPONENT_UPPER}_FOUND) + set(_GTK2_did_we_find_everything false) + endif() +endforeach() + +if(_GTK2_did_we_find_everything AND NOT GTK2_VERSION_CHECK_FAILED) + set(GTK2_FOUND true) +else() + # Unset our variables. + set(GTK2_FOUND false) + set(GTK2_VERSION) + set(GTK2_VERSION_MAJOR) + set(GTK2_VERSION_MINOR) + set(GTK2_VERSION_PATCH) + set(GTK2_INCLUDE_DIRS) + set(GTK2_LIBRARIES) +endif() + +if(GTK2_INCLUDE_DIRS) + list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS) +endif() + diff --git a/cmake/FindLibPCL.cmake b/cmake/FindLibPCL.cmake new file mode 100644 index 00000000..b6337c19 --- /dev/null +++ b/cmake/FindLibPCL.cmake @@ -0,0 +1,21 @@ +# - Try to find PCL library (Portable Coroutine Library, libpcl1) +# Once done this will define +# +# LIBPCL_FOUND - system has libPCL +# LIBPCL_INCLUDE_DIRS - the libPCL include directory +# LIBPCL_LIBRARIES - Link these to use libPCL +# LIBPCL_DEFINITIONS - Compiler switches required for using libPCL + +FIND_PATH(LIBPCL_INCLUDE_DIRS pcl.h) + +FIND_LIBRARY(LIBPCL_LIBRARIES NAMES pcl + PATHS /usr/lib /usr/local/lib /opt/local/lib + ENV LIBRARY_PATH # PATH and LIB will also work + ENV LD_LIBRARY_PATH) + +# handle the QUIETLY and REQUIRED arguments and set LIBPCL_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(libPCL DEFAULT_MSG LIBPCL_LIBRARIES LIBPCL_INCLUDE_DIRS) + +MARK_AS_ADVANCED(LIBPCL_INCLUDE_DIRS LIBPCL_LIBRARIES) diff --git a/cmake/FindPackageHandleStandardArgs.cmake b/cmake/FindPackageHandleStandardArgs.cmake new file mode 100644 index 00000000..cdcf9ca7 --- /dev/null +++ b/cmake/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,296 @@ +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) +# +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE(). +# It also sets the _FOUND variable. +# The package is considered found if all variables ... listed contain +# valid results, e.g. valid filepaths. +# +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) +# If the variables to are all valid, then _FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS ...] +# [VERSION_VAR ] +# [HANDLE_COMPONENTS] +# [CONFIG_MODE] +# [FAIL_MESSAGE "Custom failure message"] ) +# +# As above, if through are all valid, _FOUND +# will be set to TRUE. +# After REQUIRED_VARS the variables which are required for this package are listed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# If the package supports components, use the HANDLE_COMPONENTS option to enable +# handling them. In this case, find_package_handle_standard_args() will report +# which components have been found and which are missing, and the _FOUND +# variable will be set to FALSE if any of the required components (i.e. not the +# ones listed after OPTIONAL_COMPONENTS) are missing. +# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for +# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set +# to _VERSION and the macro will automatically check whether the +# Config module was found. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# +# Example for mode 1: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of . +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE +# VERSION_VAR BISON_VERSION) +# In this case, BISON is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case. +# Also the version of BISON will be checked by using the version contained +# in BISON_VERSION. +# Since no FAIL_MESSAGE is given, the default messages will be printed. +# +# Another example for mode 2: +# +# FIND_PACKAGE(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE) +# In this case, FindAutmoc4.cmake wraps a call to FIND_PACKAGE(Automoc4 NO_MODULE) +# and adds an additional search directory for automoc4. +# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper +# success/error message. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# 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.) + +INCLUDE(FindPackageMessage) +INCLUDE(CMakeParseArguments) + +# internal helper macro +MACRO(_FPHSA_FAILURE_MESSAGE _msg) + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_msg}") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_msg}") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) +ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg) + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +MACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + IF(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + ELSE(${_NAME}_CONFIG) + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + IF(${_NAME}_CONSIDERED_CONFIGS) + SET(configsText "") + LIST(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + MATH(EXPR configsCount "${configsCount} - 1") + FOREACH(currentConfigIndex RANGE ${configsCount}) + LIST(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + LIST(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + SET(configsText "${configsText} ${filename} (version ${version})\n") + ENDFOREACH(currentConfigIndex) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + ELSE(${_NAME}_CONSIDERED_CONFIGS) + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + ENDIF(${_NAME}_CONSIDERED_CONFIGS) + ENDIF(${_NAME}_CONFIG) +ENDMACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + + +FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + SET(options CONFIG_MODE HANDLE_COMPONENTS) + SET(oneValueArgs FAIL_MESSAGE VERSION_VAR) + SET(multiValueArgs REQUIRED_VARS) + SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + IF(${INDEX} EQUAL -1) + SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + SET(FPHSA_REQUIRED_VARS ${ARGN}) + SET(FPHSA_VERSION_VAR) + ELSE(${INDEX} EQUAL -1) + + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + IF(FPHSA_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + ENDIF(FPHSA_UNPARSED_ARGUMENTS) + + IF(NOT FPHSA_FAIL_MESSAGE) + SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT FPHSA_FAIL_MESSAGE) + ENDIF(${INDEX} EQUAL -1) + +# now that we collected all arguments, process them + + IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + IF(FPHSA_CONFIG_MODE) + LIST(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + LIST(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + SET(FPHSA_VERSION_VAR ${_NAME}_VERSION) + ENDIF(FPHSA_CONFIG_MODE) + + IF(NOT FPHSA_REQUIRED_VARS) + MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + ENDIF(NOT FPHSA_REQUIRED_VARS) + + LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + STRING(TOUPPER ${_NAME} _NAME_UPPER) + STRING(TOLOWER ${_NAME} _NAME_LOWER) + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + SET(MISSING_VARS "") + SET(DETAILS "") + SET(${_NAME_UPPER}_FOUND TRUE) + # check if all passed variables are valid + FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + IF(NOT ${_CURRENT_VAR}) + SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") + ELSE(NOT ${_CURRENT_VAR}) + SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") + ENDIF(NOT ${_CURRENT_VAR}) + ENDFOREACH(_CURRENT_VAR) + + # component handling + UNSET(FOUND_COMPONENTS_MSG) + UNSET(MISSING_COMPONENTS_MSG) + + IF(FPHSA_HANDLE_COMPONENTS) + FOREACH(comp ${${_NAME}_FIND_COMPONENTS}) + IF(${_NAME}_${comp}_FOUND) + + IF(NOT DEFINED FOUND_COMPONENTS_MSG) + SET(FOUND_COMPONENTS_MSG "found components: ") + ENDIF() + SET(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") + + ELSE() + + IF(NOT DEFINED MISSING_COMPONENTS_MSG) + SET(MISSING_COMPONENTS_MSG "missing components: ") + ENDIF() + SET(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") + + IF(${_NAME}_FIND_REQUIRED_${comp}) + SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS "${MISSING_VARS} ${comp}") + ENDIF() + + ENDIF() + ENDFOREACH(comp) + SET(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") + SET(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") + ENDIF(FPHSA_HANDLE_COMPONENTS) + + # version handling: + SET(VERSION_MSG "") + SET(VERSION_OK TRUE) + SET(VERSION ${${FPHSA_VERSION_VAR}} ) + IF (${_NAME}_FIND_VERSION) + + IF(VERSION) + + IF(${_NAME}_FIND_VERSION_EXACT) # exact version required + IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "(found suitable exact version \"${VERSION}\")") + ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + + ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified: + IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "(found suitable version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")") + ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ELSE(VERSION) + + # if the package was not found, but a version was given, add that to the output: + IF(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + ELSE(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ENDIF(VERSION) + ELSE (${_NAME}_FIND_VERSION) + IF(VERSION) + SET(VERSION_MSG "(found version \"${VERSION}\")") + ENDIF(VERSION) + ENDIF (${_NAME}_FIND_VERSION) + + IF(VERSION_OK) + SET(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + ELSE(VERSION_OK) + SET(${_NAME_UPPER}_FOUND FALSE) + ENDIF(VERSION_OK) + + + # print the result: + IF (${_NAME_UPPER}_FOUND) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") + ELSE (${_NAME_UPPER}_FOUND) + + IF(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + ELSE(FPHSA_CONFIG_MODE) + IF(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ELSE(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ENDIF(NOT VERSION_OK) + ENDIF(FPHSA_CONFIG_MODE) + + ENDIF (${_NAME_UPPER}_FOUND) + + SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE) + +ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG) diff --git a/cmake/bochs.cmake b/cmake/bochs.cmake new file mode 100644 index 00000000..436ab2d0 --- /dev/null +++ b/cmake/bochs.cmake @@ -0,0 +1,55 @@ +#### Add some custom targets for the autoconf-based Bochs +if(BUILD_BOCHS) + + message(STATUS "[${PROJECT_NAME}] Building Bochs variant ...") + SET(VARIANT bochs) + + # FIXME: some of these may not be mandatory, depending on the actual Bochs config! + # -L/usr/lib -lSDL -lasound -latk-1.0 -lcairo -lfontconfig -lfreetype -lgdk_pixbuf-2.0 -lgdk-x11-2.0 -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lgtk-x11-2.0 -lICE -lm -lncurses -lpango-1.0 -lpangocairo-1.0 -lpangoft2-1.0 -lrt -lSM -lvga -lvgagl -lwx_baseu-2.8 -lwx_gtk2u_core-2.8 -lX11 -lXpm -lXrandr -pthread) + find_package(SDL REQUIRED) # -lSDL + find_package(ALSA REQUIRED) # -lasoud + find_package(GTK2 COMPONENTS gtk REQUIRED) # -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgdk-x11-2.0 -lglib-2.0 -lgobject-2.0 -lgtk-x11-2.0 -lpango + find_package(Freetype REQUIRED) # -lfreetype + find_package(X11 REQUIRED) # -lICE -lX11 -lXpm -lXrandr -lSM + find_package(Curses REQUIRED) # -lncurses + find_package(wxWidgets REQUIRED) # -lwx_baseu-2.8? -lwx_gtk2u_core-2.8 + + link_directories(${wxWidgets_LIB_DIR}) + + # FIXME: some libraries still need to be located the "cmake way" + set(bochs_library_dependencies ${SDL_LIBRARY} ${ALSA_LIBRARIES} ${GTK2_ATK_LIBRARY} ${GTK2_CAIRO_LIBRARY} ${GTK2_GDK_PIXBUF_LIBRARY} ${GTK2_GDK_LIBRARY} -lfontconfig ${FREETYPE_LIBRARIES} ${GTK2_GLIB_LIBRARY} -lgmodule-2.0 ${GTK2_GOBJECT_LIBRARY} -lgthread-2.0 ${GTK2_GTK_LIBRARY} ${X11_X11_LIB} ${X11_ICE_LIB} ${X11_Xpm_LIB} ${X11_SM_LIB} ${X11_Xrandr_LIB} ${CURSES_LIBRARIES} ${GTK2_PANGO_LIBRARY} -lpangocairo-1.0 -lpangoft2-1.0 -lrt ${X11_SM_LIB} -lvga -lvgagl ${wxWidgets_LIBRARIES} -pthread) + + set(bochs_src_dir ${PROJECT_SOURCE_DIR}/simulators/bochs) + + add_custom_command(OUTPUT "${bochs_src_dir}/libfailbochs.a" + COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${PROJECT_SOURCE_DIR} -I${PROJECT_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" libfailbochs.a + COMMENT "[${PROJECT_NAME}] Building libfailbochs" + ) + + # make sure aspects don't fail to match in entry.cc + include_directories(${PROJECT_SOURCE_DIR}/src/core ${CMAKE_BINARY_DIR}/src/core) + add_executable(fail-client "${bochs_src_dir}/libfailbochs.a") + target_link_libraries(fail-client "${bochs_src_dir}/libfailbochs.a" fail ${bochs_library_dependencies}) + + # a few Bochs-specific passthrough targets: + add_custom_target(bochsclean + COMMAND +make -C ${bochs_src_dir} clean + COMMENT "[${PROJECT_NAME}] Cleaning all up (clean in bochs)" + ) + + add_custom_target(bochsallclean + COMMAND +make -C ${bochs_src_dir} all-clean + COMMENT "[${PROJECT_NAME}] Cleaning all up (all-clean in bochs)" + ) + + add_custom_target(bochsinstall + COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${PROJECT_SOURCE_DIR} -I${PROJECT_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" install + COMMENT "[${PROJECT_NAME}] Installing Bochs ..." + ) + + add_custom_target(bochsuninstall + COMMAND +make -C ${bochs_src_dir} uninstall + COMMENT "[${PROJECT_NAME}] Uninstalling Bochs ..." + ) + +endif(BUILD_BOCHS) diff --git a/cmake/compilerconfig.cmake b/cmake/compilerconfig.cmake index 63ca8599..5cb9ca91 100644 --- a/cmake/compilerconfig.cmake +++ b/cmake/compilerconfig.cmake @@ -1,12 +1,10 @@ - ##### Verbose make #### option( VERBOSE_MAKE "Verbose Makefile output" OFF) # defaults to OFF set(CMAKE_VERBOSE_MAKEFILE ${VERBOSE_MAKE}) -##### Compilers.. ##### +##### Compilers ##### SET( COMPILER "ag++" CACHE STRING "Use clang/gcc/ag++") # Defaults to ag++ -#SET( PARALLELBUILDS "4" CACHE STRING "Parallel builds forc compiling Bochs (-j N)") if(${COMPILER} STREQUAL "clang") set(CMAKE_C_COMPILER "clang") @@ -27,38 +25,3 @@ else(${COMPILER} STREQUAL "clang") endif(${COMPILER} STREQUAL "clang") message(STATUS "[${PROJECT_NAME}] Compiler: ${CMAKE_C_COMPILER}/${CMAKE_CXX_COMPILER}" ) - -#### Add some custom targets for the autoconf-based Bochs -if(BUILD_BOCHS) - - set(bochs_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/simulators/bochs ) - - add_custom_target( bochsclean - COMMAND +make -C ${bochs_src_dir} clean - COMMENT "[${PROJECT_NAME}] Cleaning all up (clean in bochs)" - ) - - add_custom_target( bochsallclean - COMMAND +make -C ${bochs_src_dir} all-clean - COMMENT "[${PROJECT_NAME}] Cleaning all up (all-clean in bochs)" - ) - - add_custom_target( bochs - COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" - COMMENT "[${PROJECT_NAME}] Building Bochs" - ) - add_dependencies(bochs fail) - - - add_custom_target( bochsinstall - COMMAND +make -C ${bochs_src_dir} CXX=\"ag++ -p ${CMAKE_SOURCE_DIR} -I${CMAKE_SOURCE_DIR}/src/core -I${CMAKE_BINARY_DIR}/src/core --real-instances --Xcompiler\" LIBTOOL=\"/bin/sh ./libtool --tag=CXX\" install - COMMENT "[${PROJECT_NAME}] Installing Bochs..." - ) - - add_custom_target( bochsuninstall - COMMAND +make -C ${bochs_src_dir} uninstall - COMMENT "[${PROJECT_NAME}] Uninstalling Bochs..." - ) - -endif(BUILD_BOCHS) - diff --git a/cmake/mergelib.sh b/cmake/mergelib.sh index 98b88c75..8b08e66b 100755 --- a/cmake/mergelib.sh +++ b/cmake/mergelib.sh @@ -1,30 +1,59 @@ #!/bin/bash # -# Merge all static (.a) libraries into $LIBFAIL, and avoid .o naming conflicts. +# Merge a list of static libraries (.a) and standalone objects (.o) into a +# common static library, and avoid .o naming conflicts. # set -e +shopt -s nullglob # expand "*.o" to "" instead of "*.o" if no .o file exists -LIBFAIL=libfail.a +[ -z "$1" ] && echo "usage: $0 output.a input1.a input2.a input3.o ..." >&2 && exit 1 +OUT=$1 +shift -cd "$1" -rm -f $LIBFAIL -ar rc $LIBFAIL +TMPDIR=$(mktemp -d) +COUNT=1 -for lib in *.a +# collect files in tmpdir, assign unique names +for f in "$@" do - [ "$lib" = "$LIBFAIL" ] && continue + if echo "$f"|egrep -vq '\.[ao]' + then + echo "$0: can only merge .a/.o files, ignoring '$f'" >&2 + continue + fi + cp $f $TMPDIR/$(printf %03d $COUNT)$(basename $f) + COUNT=$(($COUNT+1)) +done + +# create empty output lib +rm -f "$OUT" +ar rc "$OUT" + +for lib in $TMPDIR/*.a +do + echo "[FAIL*] Unpacking/merging: $(basename $lib) " >&2 + + EXTRACTDIR=$TMPDIR/"$(basename $lib).dir" + ( # subshell to preserve cwd + mkdir "$EXTRACTDIR" + cd "$EXTRACTDIR" - echo "[FAIL*] Unpacking/merging: $lib "; # unpack .o files to cwd ar x "$lib" # make sure the .o file names are unique for f in *.o do - mv $f ${lib}_$f + mv "$f" $(basename "$lib")_"$f" done + ) # move into merged library - ar r $LIBFAIL *.o - rm -f *.o + ar r "$OUT" "$EXTRACTDIR"/*.o + rm -rf "$EXTRACTDIR" done + +ar r "$OUT" $TMPDIR/*.o + +rm -rf "$TMPDIR" & +ranlib "$OUT" diff --git a/cmake/ovp.cmake b/cmake/ovp.cmake new file mode 100644 index 00000000..d24ce067 --- /dev/null +++ b/cmake/ovp.cmake @@ -0,0 +1,5 @@ +#### OVP-specific stuff +if(BUILD_OVP) + message(STATUS "[${PROJECT_NAME}] Building OVP variant ...") + SET(VARIANT ovp) +endif(BUILD_OVP) diff --git a/scripts/client.sh b/scripts/client.sh index f6eb8411..1c654572 100755 --- a/scripts/client.sh +++ b/scripts/client.sh @@ -20,7 +20,7 @@ while [ ! -e stop ] do #nice -n 19 ./bochs -q 2>&1 | tee log.$$.txt | fgrep Result #nice -n 18 ./bochs -q 2>&1 | fgrep Result - nice -n 18 ./bochs -q >/dev/null 2>&1 + nice -n 18 ./fail-client -q >/dev/null 2>&1 if [ $? -eq 1 ] then break diff --git a/scripts/distribute-experiment.sh b/scripts/distribute-experiment.sh index 48ec3fd3..36c3ab77 100755 --- a/scripts/distribute-experiment.sh +++ b/scripts/distribute-experiment.sh @@ -26,13 +26,13 @@ if [ -n "$1" ]; then cd "$1"; fi [ ! -e client.sh ] && cp -v $SCRIPTDIR/client.sh . [ ! -e multiple-clients.sh ] && cp -v $SCRIPTDIR/multiple-clients.sh . -# add bochs binary if it doesn't exist -if [ -e bochs ] +# add fail-client binary if it doesn't exist +if [ -e fail-client ] then - echo 'Info: Using local "bochs" binary.' >&2 + echo 'Info: Using local "fail-client" binary.' >&2 else - cp -v $(which bochs) . - strip bochs + cp -v $(which fail-client) . + strip fail-client fi # sync everything to experiment hosts diff --git a/scripts/killall-bochs.sh b/scripts/killall-bochs.sh index 7ddb7927..f8a27304 100755 --- a/scripts/killall-bochs.sh +++ b/scripts/killall-bochs.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# killall-bochs.sh +# killall-fail.sh # Kills all remaining FailBochs instances on $FAIL_EXPERIMENT_HOSTS. # # Prerequisites: diff --git a/scripts/multiple-clients.sh b/scripts/multiple-clients.sh index d57717d6..17728946 100755 --- a/scripts/multiple-clients.sh +++ b/scripts/multiple-clients.sh @@ -5,12 +5,12 @@ # clients defaults to #CPUs+1. # # Prerequisites: -# - client.sh and all necessary FailBochs ingredients (bochs binary, bochsrc, -# BIOS/VGA-BIOS, boot image, possibly a saved state) in the current +# - client.sh and all necessary FailBochs ingredients (fail-client binary, +# bochsrc, BIOS/VGA-BIOS, boot image, possibly a saved state) in the current # directory # - tmux installed somewhere in $PATH # - possibly missing dynamic libraries in ~/bochslibs (e.g., for running a -# i386 bochs binary in an x86_64 environment) +# i386 fail-client/bochs binary in an x86_64 environment) # set -e @@ -20,9 +20,9 @@ LIBDIR=~/bochslibs # cleanup earlier failures # (FIXME: you probably don't want this on your local machine!) killall -q client.sh || true -killall -q bochs || true +killall -q fail-client || true sleep .5 -killall -q -9 bochs || true +killall -q -9 fail-client || true # On many machines, ~ is mounted via NFS. To avoid the (severe) performance # penalty, copy all experiment-related stuff to /tmp. @@ -38,7 +38,7 @@ cd $TMP # tmux, please shut up. TMUX='tmux -q' COMMAND=./client.sh -SESSION=failbochs.$$ +SESSION=fail-client.$$ # Calculate number of clients from #processors. PROCESSORS=$(fgrep processor /proc/cpuinfo|wc -l) diff --git a/scripts/rebuild-bochs.sh b/scripts/rebuild-bochs.sh index 41d5312e..154cf3b2 100755 --- a/scripts/rebuild-bochs.sh +++ b/scripts/rebuild-bochs.sh @@ -1,17 +1,16 @@ #!/bin/bash # # - needs to be called from within your build directory -# - "rebuild-bochs.sh": rebuild all of both Fail and Bochs +# - "rebuild-bochs.sh": rebuild all of both Fail* and Bochs # (e.g., possibly necessary if you don't understand what was changed by others) -# - "rebuild-bochs.sh fail": rebuild all of Fail and re-link Bochs +# - "rebuild-bochs.sh fail": rebuild all of Fail* and link fail-client # (e.g., possibly necessary if you changed Fail-affecting aspects or the # build system) -# - "rebuild-bochs.sh bochs": rebuild all of Bochs +# - "rebuild-bochs.sh bochs": rebuild all of Bochs and link fail-client # (e.g., necessary if you changed Bochs-affecting aspects/code that must be # inlined in Bochs) -# - "rebuild-bochs.sh -": rebuild only changed parts of Fail and Bochs +# - "rebuild-bochs.sh -": rebuild only changed parts of Fail* and Bochs # (e.g., sufficient if you only changed experiment code) -# - all of the previous options finally install Bochs # set -e # determine absolute path of this script @@ -30,6 +29,6 @@ fi #export PATH=/fs/staff/hsc/bin/ccache:$PATH -# even if we only rebuilt fail, we need to link and install bochs again -nice make -j$FAIL_BUILD_PARALLEL bochs 2>&1 | $(dirname $0)/colorize.pl 2>&1 -make bochsinstall +nice make -j$FAIL_BUILD_PARALLEL fail-client 2>&1 | $(dirname $0)/colorize.pl 2>&1 +# no need to use Bochs' own installation mechanism +#nice make -j$FAIL_BUILD_PARALLEL bochsinstall diff --git a/simulators/bochs/Makefile.in b/simulators/bochs/Makefile.in index 790ecee4..df7065cb 100644 --- a/simulators/bochs/Makefile.in +++ b/simulators/bochs/Makefile.in @@ -174,13 +174,33 @@ all: @PRIMARY_TARGET@ @PLUGIN_TARGET@ bximage@EXE@ bxcommit@EXE@ @BUILD_DOCBOOK_ @EXTERNAL_DEPENDENCY@ -# DanceOS (added "../../src/libfail.a"): +# DanceOS +# FIXME: *Probably* we could remove this target and use libbochs_cpu.a and the +# module libraries instead. But: Some module libraries may not exist +# (depending on the Bochs configuration), and (at least) the GDB stub is not +# included. +libfailbochs.a: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \ + cpu/libcpu.a memory/libmemory.a gui/libgui.a \ + @DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \ + $(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@ + ../../cmake/mergelib.sh $@ \ + $(BX_OBJS) $(SIMX86_OBJS) \ + @IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \ + @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \ + @GDBSTUB_VAR@ @FPU_VAR@ + echo @NONPLUGIN_GUI_LINK_OPTS@ \ + $(MCH_LINK_FLAGS) \ + $(SIMX86_LINK_FLAGS) \ + $(READLINE_LIB) \ + $(EXTRA_LINK_OPTS) \ + $(LIBS) + bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \ - cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \ + cpu/libcpu.a memory/libmemory.a gui/libgui.a \ @DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \ $(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@ @LINK@ @EXPORT_DYNAMIC@ $(BX_OBJS) $(SIMX86_OBJS) \ - @IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \ + @IODEV_LIB_VAR@ @DEBUGGER_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \ @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \ @GDBSTUB_VAR@ @FPU_VAR@ \ @NONPLUGIN_GUI_LINK_OPTS@ \ @@ -190,25 +210,23 @@ bochs@EXE@: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \ $(EXTRA_LINK_OPTS) \ $(LIBS) -# DanceOS (added ../../src/libfail.a): - # Special make target for cygwin/mingw using dlltool instead of # libtool. This creates a .DEF file, and exports file, an import library, # and then links bochs.exe with the exports file. .win32_dll_plugin_target: @IODEV_LIB_VAR@ @DEBUGGER_VAR@ \ - cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \ + cpu/libcpu.a memory/libmemory.a gui/libgui.a \ @DISASM_VAR@ @INSTRUMENT_VAR@ $(BX_OBJS) \ $(SIMX86_OBJS) @FPU_VAR@ @GDBSTUB_VAR@ @PLUGIN_VAR@ $(DLLTOOL) --export-all-symbols --output-def bochs.def \ $(BX_OBJS) $(SIMX86_OBJS) \ - @IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \ + @IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \ @DEBUGGER_VAR@ @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \ @GDBSTUB_VAR@ @FPU_VAR@ $(DLLTOOL) --dllname bochs.exe --def bochs.def --output-lib dllexports.a $(DLLTOOL) --dllname bochs.exe --output-exp bochs.exp --def bochs.def $(CXX) -o bochs.exe $(CXXFLAGS) $(LDFLAGS) -export-dynamic \ $(BX_OBJS) bochs.exp $(SIMX86_OBJS) \ - @IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a ../../src/libfail.a gui/libgui.a \ + @IODEV_LIB_VAR@ cpu/libcpu.a memory/libmemory.a gui/libgui.a \ @DEBUGGER_VAR@ @DISASM_VAR@ @INSTRUMENT_VAR@ @PLUGIN_VAR@ \ @GDBSTUB_VAR@ @FPU_VAR@ \ $(GUI_LINK_OPTS) \ diff --git a/simulators/bochs/configure b/simulators/bochs/configure index 74cbe5d4..b90ca778 100755 --- a/simulators/bochs/configure +++ b/simulators/bochs/configure @@ -3307,8 +3307,7 @@ case "$target" in ;; *-solaris*) ADD_FLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__" # required for correct function prototypes - LIBS="$LIBS -lsocket -lnsl -lpcl -lprotobuf -lpthread" - + LIBS="$LIBS -lsocket -lnsl" DEFAULT_GUI=x11 ;; *) @@ -5110,7 +5109,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5113 "configure"' > conftest.$ac_ext + echo '#line 5112 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6798,11 +6797,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6801: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6800: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6805: \$? = $ac_status" >&5 + echo "$as_me:6804: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7031,11 +7030,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7034: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7033: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7038: \$? = $ac_status" >&5 + echo "$as_me:7037: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -7098,11 +7097,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7101: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7100: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7105: \$? = $ac_status" >&5 + echo "$as_me:7104: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8888,7 +8887,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:11103: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:11108: \$? = $ac_status" >&5 + echo "$as_me:11107: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -11168,11 +11167,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:11171: $lt_compile\"" >&5) + (eval echo "\"\$as_me:11170: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:11175: \$? = $ac_status" >&5 + echo "$as_me:11174: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12193,7 +12192,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:13116: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13121: \$? = $ac_status" >&5 + echo "$as_me:13120: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -13181,11 +13180,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13184: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13183: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13188: \$? = $ac_status" >&5 + echo "$as_me:13187: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15146,11 +15145,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15149: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15148: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15153: \$? = $ac_status" >&5 + echo "$as_me:15152: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15379,11 +15378,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15382: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15381: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15386: \$? = $ac_status" >&5 + echo "$as_me:15385: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15446,11 +15445,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15449: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15448: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15453: \$? = $ac_status" >&5 + echo "$as_me:15452: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17236,7 +17235,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - LIBS="$LIBS -lm -lpcl -lprotobuf -lpthread" - + LIBS="$LIBS -lm" # use different functions to bypass configure caching have_sin=0 have_ceil=0 diff --git a/simulators/bochs/configure.in b/simulators/bochs/configure.in index 7456c19c..0f547722 100644 --- a/simulators/bochs/configure.in +++ b/simulators/bochs/configure.in @@ -72,8 +72,7 @@ case "$target" in ;; *-solaris*) ADD_FLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__" # required for correct function prototypes - LIBS="$LIBS -lsocket -lnsl -lpcl -lprotobuf -lpthread" - + LIBS="$LIBS -lsocket -lnsl" DEFAULT_GUI=x11 ;; *) @@ -210,8 +209,7 @@ if test "$have_cos" = 1 -a "$have_floor" = 1; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) - LIBS="$LIBS -lm -lpcl -lprotobuf -lpthread" - + LIBS="$LIBS -lm" # use different functions to bypass configure caching have_sin=0 have_ceil=0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5b7c565..7bee7219 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,28 +12,25 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core) add_subdirectory(core) # Here we add all user-defined experiments (which fills the target list) -add_subdirectory(experiments/) +add_subdirectory(experiments) message(STATUS "[${PROJECT_NAME}] Chosen experiment targets:") foreach(experiment_name ${EXPERIMENTS_ACTIVATED}) message(STATUS "[${PROJECT_NAME}] -> ${experiment_name}") endforeach(experiment_name) # Here we add activated plugins -add_subdirectory(plugins/) +add_subdirectory(plugins) message(STATUS "[${PROJECT_NAME}] Chosen plugin targets:") foreach(plugin_name ${PLUGINS_ACTIVATED}) message(STATUS "[${PROJECT_NAME}] -> ${plugin_name}") endforeach(plugin_name) -## Merge all resulting Fail* libs into a single libfail.a and copy it into the fail source directory -add_custom_target(fail - COMMAND ${CMAKE_SOURCE_DIR}/cmake/mergelib.sh ${LIBRARY_OUTPUT_PATH} && ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/libfail.a ${CMAKE_SOURCE_DIR}/src -) -# FIXME: "libfail.a" should not be located in the source-tree...?! +# libfail: dummy library that pulls in all other libraries as dependencies +# (probably there's a smarter way to do that with cmake?) +add_library(fail dummy.cc) ## Setup build dependencies of the Fail* lib ## -> the Fail* targets and user defined experiment targets -add_dependencies(fail sal util cpn efw comm protomessages ${EXPERIMENTS_ACTIVATED} ${PLUGINS_ACTIVATED}) - -# Let make clean also delete libfail.a -set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${LIBRARY_OUTPUT_PATH}/libfail.a) +# start/end-group: ld must iterate over these archives more than once to figure +# out which objects are needed +target_link_libraries(fail -Wl,--start-group ${EXPERIMENTS_ACTIVATED} ${PLUGINS_ACTIVATED} sal cpn efw comm util -Wl,--end-group) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8f5d5ea2..5a3cd6cc 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,11 +1,10 @@ ### Add Boost and Threads find_package(Boost 1.42 COMPONENTS thread REQUIRED) -find_package(Threads) include_directories(${Boost_INCLUDE_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) ### Setup doxygen documentation -# TODO: put into helpers.cmake +# TODO: put into helpers.cmake (?) find_package(Doxygen) if(DOXYGEN_FOUND) # Using a .in file means we can use CMake to insert project settings diff --git a/src/core/comm/CMakeLists.txt b/src/core/comm/CMakeLists.txt index 279d3a09..ab37bcc9 100644 --- a/src/core/comm/CMakeLists.txt +++ b/src/core/comm/CMakeLists.txt @@ -1,8 +1,20 @@ set(SRCS + ExperimentData.hpp + SocketComm.hpp SocketComm.cc ) -add_subdirectory(msg) +## Setup desired protobuf descriptions HERE ## +set(MY_PROTOS + FailControlMessage.proto +) -add_library(comm ${SRCS}) -add_dependencies(comm msg) +#### PROTOBUFS #### +find_package(Protobuf REQUIRED) +include_directories(${PROTOBUF_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MY_PROTOS}) + +add_library(comm ${SRCS} ${PROTO_SRCS} ${PROTO_HDRS}) +target_link_libraries(comm ${PROTOBUF_LIBRARY}) diff --git a/src/core/comm/msg/FailControlMessage.proto b/src/core/comm/FailControlMessage.proto similarity index 100% rename from src/core/comm/msg/FailControlMessage.proto rename to src/core/comm/FailControlMessage.proto diff --git a/src/core/comm/msg/CMakeLists.txt b/src/core/comm/msg/CMakeLists.txt deleted file mode 100644 index 5bd41fad..00000000 --- a/src/core/comm/msg/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -## Setup desired protobuf descriptions HERE ## -set(MY_PROTOS - FailControlMessage.proto -) - -#### PROTOBUFS #### -find_package(Protobuf REQUIRED) -include_directories(${PROTOBUF_INCLUDE_DIRS}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${MY_PROTOS}) - -## Build library -add_library(msg ${PROTO_SRCS} ${PROTO_HDRS}) - diff --git a/src/core/comm/msg/protogen.sh b/src/core/comm/msg/protogen.sh deleted file mode 100755 index 5e6f0fa8..00000000 --- a/src/core/comm/msg/protogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -protoc --cpp_out=. FailControlMessage.proto diff --git a/src/core/cpn/JobServer.cc b/src/core/cpn/JobServer.cc index c61c909f..dc4463e9 100644 --- a/src/core/cpn/JobServer.cc +++ b/src/core/cpn/JobServer.cc @@ -9,7 +9,7 @@ #include #include -#include "comm/msg/FailControlMessage.pb.h" +#include "comm/FailControlMessage.pb.h" #include "comm/SocketComm.hpp" #include "JobServer.hpp" #include "Minion.hpp" diff --git a/src/core/efw/CMakeLists.txt b/src/core/efw/CMakeLists.txt index cbe589d8..b746d30e 100644 --- a/src/core/efw/CMakeLists.txt +++ b/src/core/efw/CMakeLists.txt @@ -1,10 +1,15 @@ set(SRCS + CoroutineManager.hpp CoroutineManager.cc + ExperimentFlow.hpp + JobClient.hpp JobClient.cc ) -# FIXME: Add dependency check for pcl-library here. - add_library(efw ${SRCS}) - add_dependencies(efw comm) + +find_package(LibPCL REQUIRED) +include_directories(${LIBPCL_INCLUDE_DIRS}) +link_directories(${LIBPCL_LINK_DIRS}) +target_link_libraries(efw ${LIBPCL_LIBRARIES}) diff --git a/src/core/efw/JobClient.hpp b/src/core/efw/JobClient.hpp index ec6757b7..c66bbfad 100644 --- a/src/core/efw/JobClient.hpp +++ b/src/core/efw/JobClient.hpp @@ -9,7 +9,7 @@ #include "comm/SocketComm.hpp" #include "comm/ExperimentData.hpp" -#include "comm/msg/FailControlMessage.pb.h" +#include "comm/FailControlMessage.pb.h" #include "config/FailConfig.hpp" namespace fail { diff --git a/src/core/util/CMakeLists.txt b/src/core/util/CMakeLists.txt index ecc8270f..08d607e4 100644 --- a/src/core/util/CMakeLists.txt +++ b/src/core/util/CMakeLists.txt @@ -1,10 +1,24 @@ set(SRCS - SynchronizedCounter.cc - Logger.hpp Logger.cc + Logger.hpp + MemoryMap.hpp ProtoStream.cc + ProtoStream.hpp + SynchronizedCounter.cc + SynchronizedCounter.hpp + SynchronizedMap.hpp + SynchronizedQueue.hpp ) -add_library(util ${SRCS}) +# required by ProtoStream.cc: +find_package(Protobuf REQUIRED) +include_directories(${PROTOBUF_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# FIXME: Add protobuf-dependency (required by ProtoStream.cc@line56) +# required by Synchronized*.cc: +find_package(Boost 1.42 COMPONENTS thread REQUIRED) +include_directories(${Boost_INCLUDE_DIRS}) +link_directories(${Boost_LIBRARY_DIRS}) + +add_library(util ${SRCS}) +target_link_libraries(util ${PROTOBUF_LIBRARY} ${Boost_THREAD_LIBRARY}) diff --git a/src/dummy.cc b/src/dummy.cc new file mode 100644 index 00000000..e69de29b