diff options
33 files changed, 574 insertions, 146 deletions
diff --git a/Modules/CMakeGraphVizOptions.cmake b/Modules/CMakeGraphVizOptions.cmake new file mode 100644 index 0000000..e4af54c --- /dev/null +++ b/Modules/CMakeGraphVizOptions.cmake @@ -0,0 +1,83 @@ +##section Variables specific to the graphviz support +##end +##module +# - The builtin graphviz support of CMake. +# CMake can generate graphviz files, showing the dependencies between +# the targets in a project and also external libraries which are linked +# against. +# When CMake is run with the --graphiz=foo option, it will produce +# * a foo.dot file showing all dependencies in the project +# * a foo.dot.<target> file for each target, file showing on which other targets the respective target depends +# * a foo.dot.<target>.dependers file, showing which other targets depend on the respective target +# +# This can result in huge graphs. Using the file CMakeGraphVizOptions.cmake +# the look and content of the generated graphs can be influenced. +# This file is searched first in ${CMAKE_BINARY_DIR} and then in +# ${CMAKE_SOURCE_DIR}. If found, it is read and the variables set in it +# are used to adjust options for the generated graphviz files. +##end +# +##variable +# GRAPHVIZ_GRAPH_TYPE - The graph type +# Mandatory : NO +# Default : "digraph" +##end +##variable +# GRAPHVIZ_GRAPH_NAME - The graph name. +# Mandatory : NO +# Default : "GG" +##end +##variable +# GRAPHVIZ_GRAPH_HEADER - The header written at the top of the graphviz file. +# Mandatory : NO +# Default : "node [n fontsize = "12"];" +##end +##variable +# GRAPHVIZ_NODE_PREFIX - The prefix for each node in the graphviz file. +# Mandatory : NO +# Default : "node" +##end +##variable +# GRAPHVIZ_EXECUTABLES - Set this to FALSE to exclude executables from the generated graphs. +# Mandatory : NO +# Default : TRUE +##end +##variable +# GRAPHVIZ_STATIC_LIBS - Set this to FALSE to exclude static libraries from the generated graphs. +# Mandatory : NO +# Default : TRUE +##end +##variable +# GRAPHVIZ_SHARED_LIBS - Set this to FALSE to exclude shared libraries from the generated graphs. +# Mandatory : NO +# Default : TRUE +##end +##variable +# GRAPHVIZ_MODULE_LIBS - Set this to FALSE to exclude static libraries from the generated graphs. +# Mandatory : NO +# Default : TRUE +##end +##variable +# GRAPHVIZ_EXTERNAL_LIBS - Set this to FALSE to exclude external libraries from the generated graphs. +# Mandatory : NO +# Default : TRUE +##end +##variable +# GRAPHVIZ_IGNORE_TARGETS - A list of regular expressions for ignoring targets. +# Mandatory : NO +# Default : empty +##end + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# Copyright 2013 Alexander Neundorf <neundorf@kde.org> +# +# 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.) diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake new file mode 100644 index 0000000..ef5d857 --- /dev/null +++ b/Modules/CMakePrintHelpers.cmake @@ -0,0 +1,146 @@ +# - Convenience macros for printing properties and variables, useful e.g. for debugging. +# +# +# CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN] +# [SOURCES source1 .. sourceN] +# [DIRECTORIES dir1 .. dirN] +# [TESTS test1 .. testN] +# [CACHE_ENTRIES entry1 .. entryN] +# PROPERTIES prop1 .. propN ) +# +# This macro prints the values of the properties of the given targets, +# source files, directories, tests or cache entries. Exactly one of the +# scope keywords must be used. +# Example: +# cmake_print_properties(TARGETS foo bar PROPERTIES LOCATION INTERFACE_INCLUDE_DIRS) +# This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for both +# targets foo and bar. +# +# +# CMAKE_PRINT_VARIABLES(var1 var2 .. varN) +# +# This macro will print the name of each variable followed by its value. +# Example: +# cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION THIS_ONE_DOES_NOT_EXIST) +# Gives: +# -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; THIS_ONE_DOES_NOT_EXIST="" + +#============================================================================= +# Copyright 2013 Alexander Neundorf, <neundorf@kde.org> +# +# 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(CMakeParseArguments) + +function(CMAKE_PRINT_VARIABLES) + set(msg "") + foreach(var ${ARGN}) + if(msg) + set(msg "${msg} ; ") + endif() + set(msg "${msg}${var}=\"${${var}}\"") + endforeach() + message(STATUS "${msg}") +endfunction() + + +function(CMAKE_PRINT_PROPERTIES ) + set(options ) + set(oneValueArgs ) + set(multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES ) + + cmake_parse_arguments(CPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CPP_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to cmake_print_properties(): \"${CPP_UNPARSED_ARGUMENTS}\"") + return() + endif() + + if(NOT CPP_PROPERTIES) + message(FATAL_ERROR "Required argument PROPERTIES missing in cmake_print_properties() call") + return() + endif() + + set(mode) + set(items) + set(keyword) + + if(CPP_TARGETS) + set(items ${CPP_TARGETS}) + set(mode ${mode} TARGETS) + set(keyword TARGET) + endif() + + if(CPP_SOURCES) + set(items ${CPP_SOURCES}) + set(mode ${mode} SOURCES) + set(keyword SOURCE) + endif() + + if(CPP_TESTS) + set(items ${CPP_TESTS}) + set(mode ${mode} TESTS) + set(keyword TEST) + endif() + + if(CPP_DIRECTORIES) + set(items ${CPP_DIRECTORIES}) + set(mode ${mode} DIRECTORIES) + set(keyword DIRECTORY) + endif() + + if(CPP_CACHE_ENTRIES) + set(items ${CPP_CACHE_ENTRIES}) + set(mode ${mode} CACHE_ENTRIES) + set(keyword CACHE) + endif() + + if(NOT mode) + message(FATAL_ERROR "Mode keyword missing in cmake_print_properties() call, must be one of TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES") + return() + endif() + + list(LENGTH mode modeLength) + if("${modeLength}" GREATER 1) + message(FATAL_ERROR "Multiple mode keyword used in cmake_print_properties() call, it must be exactly one of TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES") + return() + endif() + + set(msg "\n") + foreach(item ${items}) + + set(itemExists TRUE) + if(keyword STREQUAL "TARGET") + if(NOT TARGET ${item}) + set(itemExists FALSE) + set(msg "${msg}\n No such TARGET \"${item}\" !\n\n") + endif() + endif() + + if (itemExists) + set(msg "${msg} Properties for ${keyword} ${item}:\n") + foreach(prop ${CPP_PROPERTIES}) + + get_property(propertySet ${keyword} ${item} PROPERTY "${prop}" SET) + + if(propertySet) + get_property(property ${keyword} ${item} PROPERTY "${prop}") + set(msg "${msg} ${item}.${prop} = \"${property}\"\n") + else() + set(msg "${msg} ${item}.${prop} = <NOTFOUND>\n") + endif() + endforeach() + endif() + + endforeach() + message(STATUS "${msg}") + +endfunction() diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index de17f16..4f522e5 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -28,7 +28,6 @@ # 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 # @@ -67,6 +66,17 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Version 1.5 (UNRELEASED) (CMake 2.8.12) +# * 14236: Detect gthread library +# Detect pangocairo on windows +# Detect pangocairo with gtk module instead of with gtkmm +# * 14259: Use vc100 libraries with MSVC11 +# * 14260: Export a GTK2_DEFINITIONS variable to set /vd2 when appropriate +# (i.e. MSVC) +# * Use the optimized/debug syntax for _LIBRARY and _LIBRARIES variables when +# appropriate. A new set of _RELEASE variables was also added. +# * Remove GTK2_SKIP_MARK_AS_ADVANCED option, as now the variables are +# marked as advanced by SelectLibraryConfigurations # Version 1.4 (10/4/2012) (CMake 2.8.10) # * 12596: Missing paths for FindGTK2 on NetBSD # * 12049: Fixed detection of GTK include files in the lib folder on @@ -117,6 +127,9 @@ # _OUT_micro = Micro version number # _gtkversion_hdr = Header file to parse #============================================================= + +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) file(STRINGS ${_gtkversion_hdr} _contents REGEX "#define GTK_M[A-Z]+_VERSION[ \t]+") if(_contents) @@ -145,7 +158,7 @@ endfunction() #============================================================= # _GTK2_FIND_INCLUDE_DIR # Internal function to find the GTK include directories -# _var = variable to set +# _var = variable to set (_INCLUDE_DIR is appended) # _hdr = header file to look for #============================================================= function(_GTK2_FIND_INCLUDE_DIR _var _hdr) @@ -201,7 +214,7 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) message(STATUS "Adding ${_gtk2_arch_dir} to search path for multiarch support") endif() endif() - find_path(${_var} ${_hdr} + find_path(${_var}_INCLUDE_DIR ${_hdr} PATHS ${_gtk2_arch_dir} /usr/local/lib64 @@ -228,11 +241,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) ${_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() + if(${_var}_INCLUDE_DIR) + set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${${_var}_INCLUDE_DIR} PARENT_SCOPE) endif() endfunction() @@ -240,7 +250,7 @@ endfunction() #============================================================= # _GTK2_FIND_LIBRARY # Internal function to find libraries packaged with GTK2 -# _var = library variable to create +# _var = library variable to create (_LIBRARY is appended) #============================================================= function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) @@ -322,10 +332,10 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) if(GTK2_DEBUG) message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " - "While searching for ${_var}, our proposed library list is ${_lib_list}") + "While searching for ${_var}_LIBRARY, our proposed library list is ${_lib_list}") endif() - find_library(${_var} + find_library(${_var}_LIBRARY_RELEASE NAMES ${_lib_list} PATHS /opt/gnome/lib @@ -339,34 +349,34 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) 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}") + "While searching for ${_var}_LIBRARY_DEBUG our proposed library list is ${_libd_list}") endif() - find_library(${_var}_DEBUG + find_library(${_var}_LIBRARY_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 ) + endif() - 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) + select_library_configurations(${_var}) + + set(${_var}_LIBRARY ${${_var}_LIBRARY} PARENT_SCOPE) + + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${${_var}_LIBRARY}) + set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE) + + if(GTK2_DEBUG) + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "${_var}_LIBRARY_RELEASE = \"${${_var}_LIBRARY_RELEASE}\"") + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "${_var}_LIBRARY_DEBUG = \"${${_var}_LIBRARY_DEBUG}\"") + message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] " + "${_var}_LIBRARY = \"${${_var}_LIBRARY}\"") endif() + endfunction() #============================================================= @@ -395,7 +405,7 @@ if(GTK2_FIND_VERSION) 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) + _GTK2_FIND_INCLUDE_DIR(GTK2_GTK gtk/gtk.h) if(GTK2_GTK_INCLUDE_DIR) _GTK2_GET_VERSION(GTK2_MAJOR_VERSION GTK2_MINOR_VERSION @@ -445,90 +455,89 @@ list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES}) foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") - _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GTK gtk/gtk.h) if(UNIX) - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK gtk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GDK gdk-x11 false true) else() - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK gtk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GDK gdk-win32 false true) endif() - _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_GDK gdk/gdk.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG gdkconfig.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h) - _GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false) + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO cairo.h) + _GTK2_FIND_LIBRARY (GTK2_CAIRO cairo false false) - _GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG 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_PANGO pango/pango.h) + _GTK2_FIND_LIBRARY (GTK2_PANGO pango false true) - _GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO_LIBRARY pangocairo false true) + _GTK2_FIND_LIBRARY (GTK2_PANGOCAIRO pangocairo 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_PIXBUF gdk-pixbuf/gdk-pixbuf.h) + _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF gdk_pixbuf false true) - _GTK2_FIND_LIBRARY (GTK2_GTHREAD_LIBRARY gthread false true) + _GTK2_FIND_LIBRARY (GTK2_GTHREAD gthread false true) - _GTK2_FIND_LIBRARY (GTK2_GIO_LIBRARY gio false true) + _GTK2_FIND_LIBRARY (GTK2_GIO gio false true) - _GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h) - _GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_ATK atk/atk.h) + _GTK2_FIND_LIBRARY (GTK2_ATK atk 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_GOBJECT gobject/gobject.h) + _GTK2_FIND_LIBRARY (GTK2_GOBJECT gobject false true) - _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_GLIB glib.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG glibconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIB glib false true) elseif(_GTK2_component STREQUAL "gtkmm") - _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_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 gtkmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GTKMMCONFIG gtkmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GTKMM gtkmm 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_GDKMM gdkmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG gdkmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GDKMM gdkmm true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h) - _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMMCONFIG_INCLUDE_DIR cairommconfig.h) - _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM pangomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG pangommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_PANGOMM pangomm 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_CAIROMM cairomm/cairomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMMCONFIG cairommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_CAIROMM cairomm true true) - _GTK2_FIND_INCLUDE_DIR(GTK2_ATKMM_INCLUDE_DIR atkmm.h) - _GTK2_FIND_LIBRARY (GTK2_ATKMM_LIBRARY atkmm true true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMM giomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GIOMMCONFIG giommconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GIOMM giomm true true) - _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_ATKMM atkmm.h) + _GTK2_FIND_LIBRARY (GTK2_ATKMM atkmm 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_GLIBMM glibmm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG glibmmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLIBMM glibmm true true) + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++ sigc++/sigc++.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG sigc++config.h) + _GTK2_FIND_LIBRARY (GTK2_SIGC++ sigc 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) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADE glade/glade.h) + _GTK2_FIND_LIBRARY (GTK2_GLADE 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) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMM libglademm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMMCONFIG libglademmconfig.h) + _GTK2_FIND_LIBRARY (GTK2_GLADEMM glademm true true) else() message(FATAL_ERROR "Unknown GTK2 component ${_component}") diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index fef4669..33c2971 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -39,10 +39,37 @@ if(ZLIB_FOUND) ) list(APPEND PNG_NAMES png libpng) - foreach(v 16 15 14 12) - list(APPEND PNG_NAMES png${v} libpng${v} png${v}d libpng${v}d) + unset(PNG_NAMES_DEBUG) + set(_PNG_VERSION_SUFFIXES 17 16 15 14 12) + if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$") + string(REGEX REPLACE + "^([0-9]+)\\.([0-9]+).*" "\\1\\2" + _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}") + if (PNG_FIND_VERSION_EXACT) + set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN}) + else () + string(REGEX REPLACE + "${_PNG_VERSION_SUFFIX_MIN}.*" "${_PNG_VERSION_SUFFIX_MIN}" + _PNG_VERSION_SUFFIXES "${_PNG_VERSION_SUFFIXES}") + endif () + unset(_PNG_VERSION_SUFFIX_MIN) + endif () + foreach(v IN LISTS _PNG_VERSION_SUFFIXES) + list(APPEND PNG_NAMES png${v} libpng${v}) + list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d) endforeach() - find_library(PNG_LIBRARY NAMES ${PNG_NAMES} ) +message(STATUS "PNG r: ${PNG_NAMES} d: ${PNG_NAMES_DEBUG}") + unset(_PNG_VERSION_SUFFIXES) + find_library(PNG_LIBRARY_RELEASE NAMES ${PNG_NAMES}) + find_library(PNG_LIBRARY_DEBUG NAMES ${PNG_NAMES_DEBUG}) + unset(PNG_NAMES) + unset(PNG_NAMES_DEBUG) + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(PNG) + # Set by select_library_configurations(), but we want the one from + # find_package_handle_standard_args() below. + unset(PNG_FOUND) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) # png.h includes zlib.h. Sigh. diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 5e13b59..f1aedd7 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -113,19 +113,16 @@ macro (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target) set (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") string (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") - set(targetincludes) - set(targetdefines) if(moc_target) - list(APPEND targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>") - list(APPEND targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>") + set(targetincludes "$<TARGET_PROPERTY:${moc_target},INCLUDE_DIRECTORIES>") + set(targetdefines "$<TARGET_PROPERTY:${moc_target},COMPILE_DEFINITIONS>") set(targetincludes "$<$<BOOL:${targetincludes}>:-I$<JOIN:${targetincludes},\n-I>\n>") set(targetdefines "$<$<BOOL:${targetdefines}>:-D$<JOIN:${targetdefines},\n-D>\n>") file (GENERATE OUTPUT ${_moc_parameters_file} - CONTENT "${targetdefines}${targetincludes}${targetoptions}${_moc_parameters}\n" - CONDITION 1 + CONTENT "${targetdefines}${targetincludes}${_moc_parameters}\n" ) set(targetincludes) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7a3e177..f63178e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 11) -set(CMake_VERSION_TWEAK 20130728) +set(CMake_VERSION_TWEAK 20130731) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 0508448..7a3edb5 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1302,10 +1302,9 @@ int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) for ( it = vec.begin(); it != vec.end(); ++it ) { int retVal = 0; - std::string cmd = cmSystemTools::ConvertToOutputPath(it->c_str()); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << cmd + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl); - if ( !cmSystemTools::RunSingleCommand(cmd.c_str(), 0, &retVal, 0, + if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0 ) { diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index cfd5e76..58b7147 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -963,9 +963,11 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Enables tracing output for target properties.", "This variable can be populated with a list of properties to generate " "debug output for when evaluating target properties. Currently it can " - "only be used when evaluating the INCLUDE_DIRECTORIES target property. " - "In that case, it outputs a backtrace for each include directory in " - "the build. Default is unset.",false,"Variables That Change Behavior"); + "only be used when evaluating the INCLUDE_DIRECTORIES, " + "COMPILE_DEFINITIONS and COMPILE_OPTIONS target properties. " + "In that case, it outputs a backtrace for each entry in the target " + "propertythe build. Default is unset.", + false,"Variables That Change Behavior"); // Variables defined by CMake that describe the system @@ -1518,6 +1520,22 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "See that target property for additional information.", false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_<LANG>_VISIBILITY_PRESET", cmProperty::VARIABLE, + "Default value for <LANG>_VISIBILITY_PRESET of targets.", + "This variable is used to initialize the " + "<LANG>_VISIBILITY_PRESET property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_VISIBILITY_INLINES_HIDDEN", cmProperty::VARIABLE, + "Default value for VISIBILITY_INLINES_HIDDEN of targets.", + "This variable is used to initialize the " + "VISIBILITY_INLINES_HIDDEN property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will // also be defined whenever CMake has loaded its support for compiling (LANG) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 36802b5..5b351bc 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -291,7 +291,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( { return; } - if (!*input && tei->InterfaceIncludeDirectories.empty()) + if ((input && !*input) && tei->InterfaceIncludeDirectories.empty()) { // Set to empty properties[propName] = ""; @@ -641,7 +641,7 @@ cmExportFileGenerator cmMakefile *mf = target->GetMakefile(); cmOStringStream e; e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, " - "but also has old-style INTERFACE_LINK_LIBRARIES properties " + "but also has old-style LINK_INTERFACE_LIBRARIES properties " "populated, but it was exported without the " "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties"; mf->IssueMessage(cmake::FATAL_ERROR, e.str()); diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 586fee2..aa755d1 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -90,7 +90,7 @@ public: " file(TIMESTAMP filename variable [<format string>] [UTC])\n" " file(GENERATE OUTPUT output_file\n" " <INPUT input_file|CONTENT input_content>\n" - " CONDITION expression)\n" + " [CONDITION expression])\n" "WRITE will write a message into a file called 'filename'. It " "overwrites the file if it already exists, and creates the file " "if it does not exist. (If the file is a build input, use " diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index b59298f..d0b6190 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -790,11 +790,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (propertyName == "LINKER_LANGUAGE") { - if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) + if (target->LinkLanguagePropagatesToDependents() && + dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) { reportError(context, content->GetOriginalExpression(), "LINKER_LANGUAGE target property can not be used while evaluating " - "link libraries"); + "link libraries for a static library"); return std::string(); } const char *lang = target->GetLinkerLanguage(context->Config); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2cd19cf..78012de 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4081,7 +4081,7 @@ void cmMakefile::DefineProperties(cmake *cm) "List of options to pass to the compiler.", "This property specifies the list of directories given " "so far for this property. " - "This property exists on directories and targets. " + "This property exists on directories and targets." "\n" "The target property values are used by the generators to set " "the options for the compiler.\n" diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index c52c266..9ec4938 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -638,6 +638,12 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command, cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); } + if (outputflag == OUTPUT_PASSTHROUGH) + { + cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1); + cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1); + } + cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp); @@ -645,7 +651,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command, char* data; int length; int pipe; - if ( output || outputflag != OUTPUT_NONE ) + if(outputflag != OUTPUT_PASSTHROUGH && (output || outputflag != OUTPUT_NONE)) { while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0) { @@ -2464,7 +2470,15 @@ bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, cmds.push_back(fullPath.c_str()); std::string output; - RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE); + if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE)) + { + cmds.insert(cmds.begin(), "-r"); + cmds.insert(cmds.begin(), "xcrun"); + if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE)) + { + return false; + } + } std::vector<std::string> strs = cmSystemTools::tokenize(output, "\n"); // otool returns extra lines reporting multiple install names diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9614449..9d7dae9 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -211,7 +211,7 @@ public: * user-viewable output from the program being run will be generated. * OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged * into stdout. OUTPUT_NORMAL passes through the output to stdout/stderr as - * it was received. + * it was received. OUTPUT_PASSTHROUGH passes through the original handles. * * If timeout is specified, the command will be terminated after * timeout expires. Timeout is specified in seconds. @@ -230,7 +230,8 @@ public: { OUTPUT_NONE = 0, OUTPUT_MERGE, - OUTPUT_NORMAL + OUTPUT_NORMAL, + OUTPUT_PASSTHROUGH }; static bool RunSingleCommand(const char* command, std::string* output = 0, int* retVal = 0, const char* dir = 0, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b9dc423..560f07c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -304,7 +304,7 @@ void cmTarget::DefineProperties(cmake *cm) "List of options to pass to the compiler.", "This property specifies the list of options specified " "so far for this property. " - "This property exists on directories and targets. " + "This property exists on directories and targets." "\n" "The target property values are used by the generators to set " "the options for the compiler.\n" @@ -1001,22 +1001,13 @@ void cmTarget::DefineProperties(cmake *cm) "(such as \"lib\") on a library name."); cm->DefineProperty - ("C_VISIBILITY_PRESET", cmProperty::TARGET, + ("<LANG>_VISIBILITY_PRESET", cmProperty::TARGET, "Value for symbol visibility compile flags", - "The C_VISIBILITY_PRESET property determines the value passed used in " - "a visibility related compile option, such as -fvisibility=. This " - "property only has an affect for libraries and executables with " + "The <LANG>_VISIBILITY_PRESET property determines the value passed in " + "a visibility related compile option, such as -fvisibility= for <LANG>. " + "This property only has an affect for libraries and executables with " "exports. This property is initialized by the value of the variable " - "CMAKE_C_VISIBILITY_PRESET if it is set when a target is created."); - - cm->DefineProperty - ("CXX_VISIBILITY_PRESET", cmProperty::TARGET, - "Value for symbol visibility compile flags", - "The CXX_VISIBILITY_PRESET property determines the value passed used in " - "a visibility related compile option, such as -fvisibility=. This " - "property only has an affect for libraries and executables with " - "exports. This property is initialized by the value of the variable " - "CMAKE_CXX_VISIBILITY_PRESET if it is set when a target is created."); + "CMAKE_<LANG>_VISIBILITY_PRESET if it is set when a target is created."); cm->DefineProperty ("VISIBILITY_INLINES_HIDDEN", cmProperty::TARGET, @@ -2530,6 +2521,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, = (sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain"); s << "The uses of the " << sigString << " signature are here:\n"; + std::set<cmStdString> emitted; for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin(); it != sigs.end(); ++it) { @@ -2537,7 +2529,12 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s, if(i != it->end()) { cmListFileContext const& lfc = *i; - s << " * " << (lfc.Line? "": " in ") << lfc << std::endl; + cmOStringStream line; + line << " * " << (lfc.Line? "": " in ") << lfc << std::endl; + if (emitted.insert(line.str()).second) + { + s << line.str(); + } ++i; } } @@ -6244,7 +6241,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, } // Get the link languages. - if(this->GetType() == cmTarget::STATIC_LIBRARY) + if(this->LinkLanguagePropagatesToDependents()) { std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES"; linkProp += suffix; @@ -6470,6 +6467,15 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, break; } } + else + { + iface.Libraries = impl->Libraries; + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } + } } } @@ -6498,7 +6504,8 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, headTarget, this, &dagChecker), iface.Libraries); - if(this->GetType() == cmTarget::SHARED_LIBRARY) + if(this->GetType() == cmTarget::SHARED_LIBRARY + || this->GetType() == cmTarget::STATIC_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. @@ -6532,6 +6539,11 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } + if(this->LinkLanguagePropagatesToDependents()) + { + // Targets using this archive need its language runtime libraries. + iface.Languages = impl->Languages; + } } } else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN @@ -6546,7 +6558,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, iface.ImplementationIsInterface = true; iface.Libraries = impl->Libraries; iface.WrongConfigLibraries = impl->WrongConfigLibraries; - if(this->GetType() == cmTarget::STATIC_LIBRARY) + if(this->LinkLanguagePropagatesToDependents()) { // Targets using this archive need its language runtime libraries. iface.Languages = impl->Languages; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 24a71ed..27b74ca 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -549,6 +549,9 @@ public: void FinalizeSystemIncludeDirectories(); + bool LinkLanguagePropagatesToDependents() const + { return this->TargetTypeValue == STATIC_LIBRARY; } + private: // The set of include directories that are marked as system include // directories. diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 77a5e43..68d8339 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -62,7 +62,10 @@ static const char * cmDocumentationDescription[][3] = " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \ " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ - " --use-stderr = Don't merge stdout/stderr.\n" \ + " --use-stderr = Don't merge stdout/stderr output and pass the\n" \ + " original stdout/stderr handles to the native\n" \ + " tool so it can use the capabilities of the\n" \ + " calling terminal (e.g. colored output).\n" \ " -- = Pass remaining options to the native tool.\n" //---------------------------------------------------------------------------- @@ -108,9 +111,11 @@ static const char * cmDocumentationOptions[][3] = "to stdout. This can be used to use cmake instead of pkg-config to find " "installed libraries in plain Makefile-based projects or in " "autoconf-based projects (via share/aclocal/cmake.m4)."}, - {"--graphviz=[file]", "Generate graphviz of dependencies.", + {"--graphviz=[file]", "Generate graphviz of dependencies, see " + "CMakeGraphVizOptions.cmake for more.", "Generate a graphviz input file that will contain all the library and " - "executable dependencies in the project."}, + "executable dependencies in the project. See the documentation for " + "CMakeGraphVizOptions.cmake for more details. "}, {"--system-information [file]", "Dump information about this system.", "Dump a wide range of information about the current system. If run " "from the top of a binary tree for a CMake project it will dump " @@ -604,7 +609,7 @@ static int do_build(int ac, char** av) } else if(strcmp(av[i], "--use-stderr") == 0) { - outputflag = cmSystemTools::OUTPUT_NORMAL; + outputflag = cmSystemTools::OUTPUT_PASSTHROUGH; } else if(strcmp(av[i], "--") == 0) { diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 262d83b..8571557 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -62,8 +62,8 @@ static std::string trimLeadingSpace(const std::string& cmdline) { return cmdline.substr(i); } -static void doEscape(std::string& str, const std::string& search, - const std::string& repl) { +static void replaceAll(std::string& str, const std::string& search, + const std::string& repl) { std::string::size_type pos = 0; while ((pos = str.find(search, pos)) != std::string::npos) { str.replace(pos, search.size(), repl); @@ -71,6 +71,10 @@ static void doEscape(std::string& str, const std::string& search, } } +bool startsWith(const std::string& str, const std::string& what) { + return str.compare(0, what.size(), what) == 0; +} + // Strips one argument from the cmdline and returns it. "surrounding quotes" // are removed from the argument if there were any. static std::string getArg(std::string& cmdline) { @@ -117,6 +121,13 @@ static void parseCommandLine(LPTSTR wincmdline, rest = trimLeadingSpace(cmdline); } +// Not all backslashes need to be escaped in a depfile, but it's easier that +// way. See the re2c grammar in ninja's source code for more info. +static void escapePath(std::string &path) { + replaceAll(path, "\\", "\\\\"); + replaceAll(path, " ", "\\ "); +} + static void outputDepFile(const std::string& dfile, const std::string& objfile, std::vector<std::string>& incs) { @@ -132,16 +143,24 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile, // FIXME should this be fatal or not? delete obj? delete d? if (!out) return; + std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); + replaceAll(cwd, "/", "\\"); + cwd += "\\"; std::string tmp = objfile; - doEscape(tmp, " ", "\\ "); + escapePath(tmp); fprintf(out, "%s: \\\n", tmp.c_str()); std::vector<std::string>::iterator it = incs.begin(); for (; it != incs.end(); ++it) { tmp = *it; - doEscape(tmp, "\\", "/"); - doEscape(tmp, " ", "\\ "); + // The paths need to match the ones used to identify build artifacts in the + // build.ninja file. Therefore we need to canonicalize the path to use + // backward slashes and relativize the path to the build directory. + replaceAll(tmp, "/", "\\"); + if (startsWith(tmp, cwd)) + tmp = tmp.substr(cwd.size()); + escapePath(tmp); fprintf(out, "%s \\\n", tmp.c_str()); } @@ -150,10 +169,6 @@ static void outputDepFile(const std::string& dfile, const std::string& objfile, } -bool startsWith(const std::string& str, const std::string& what) { - return str.compare(0, what.size(), what) == 0; -} - bool contains(const std::string& str, const std::string& what) { return str.find(what) != std::string::npos; } diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 2792751..6281c40 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -53,6 +53,8 @@ write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/dir/header.txt + "#define HEADER_STRING \"ninja\"\n" ) file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in "static const char* zot_custom = \"zot_custom\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx @@ -93,6 +95,26 @@ if(NOT RESULT) message(SEND_ERROR "Could not build test project (1)!") endif() +# find and save the ninjadep executable +set(ninjadep ${BuildDepends_BINARY_DIR}/Project/ninjadep${CMAKE_EXECUTABLE_SUFFIX}) +if(EXISTS + "${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}" ) + message("found debug") + set(ninjadep + "${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}") +endif() +message("Running ${ninjadep} ") +execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "HEADER_STRING: ninja ") + message("Worked!") +else() + message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n" + " expected [HEADER_STRING: ninja]") +endif() + set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX}) if(EXISTS "${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" ) @@ -151,6 +173,8 @@ execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out) message("Modifying Project/foo.cxx") write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx "const char* foo() { return \"foo changed\";}" ) +file(WRITE "${BuildDepends_BINARY_DIR}/Project/dir/header.txt" + "#define HEADER_STRING \"ninja changed\"\n" ) file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot changed\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in @@ -204,6 +228,18 @@ if(EXISTS message("found debug") endif() +message("Running ${ninjadep} ") +execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) +string(REGEX REPLACE "[\r\n]" " " out "${out}") +message("Run result: ${runResult} Output: \"${out}\"") + +if("${out}" STREQUAL "HEADER_STRING: ninja changed ") + message("Worked!") +else() + message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n" + " expected [HEADER_STRING: ninja changed]") +endif() + message("Running ${bar} ") execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) string(REGEX REPLACE "[\r\n]" " " out "${out}") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index f8a3d15..b4c6a07 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -123,3 +123,19 @@ add_custom_target(link_depends_no_shared_check ALL -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake ) add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe) + +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt + ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + ) + +set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dir/header.h + PROPERTIES GENERATED 1) + +add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_executable(ninjadep ninjadep.cpp) +add_dependencies(ninjadep header_tgt) diff --git a/Tests/BuildDepends/Project/ninjadep.cpp b/Tests/BuildDepends/Project/ninjadep.cpp new file mode 100644 index 0000000..8d61336 --- /dev/null +++ b/Tests/BuildDepends/Project/ninjadep.cpp @@ -0,0 +1,6 @@ +#include <stdio.h> +#include "dir/header.h" + +int main() { + printf("HEADER_STRING: %s\n", HEADER_STRING); +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt index dd6ab41..07d7c43 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -16,3 +16,12 @@ assert_property(cmp0022ifacelib INTERFACE_LINK_LIBRARIES "") add_executable(cmp0022exe cmp0022exe.cpp) target_link_libraries(cmp0022exe cmp0022lib) + +add_library(staticlib1 STATIC staticlib1.cpp) +generate_export_header(staticlib1) +add_library(staticlib2 STATIC staticlib2.cpp) +generate_export_header(staticlib2) +target_link_libraries(staticlib1 LINK_PUBLIC staticlib2) + +add_executable(staticlib_exe staticlib_exe.cpp) +target_link_libraries(staticlib_exe staticlib1) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp new file mode 100644 index 0000000..a253c46 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp @@ -0,0 +1,2 @@ + +int staticlib1() { return 0; } diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h new file mode 100644 index 0000000..4bbf23f --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int staticlib1(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp new file mode 100644 index 0000000..4e38063 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp @@ -0,0 +1,2 @@ + +int staticlib2() { return 0; } diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h new file mode 100644 index 0000000..a4e07b6 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.h @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int staticlib2(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp new file mode 100644 index 0000000..97adc40 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib_exe.cpp @@ -0,0 +1,8 @@ + +#include "staticlib1.h" +#include "staticlib2.h" + +int main() +{ + return staticlib1() + staticlib2(); +} diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt index ff02883..2db9282 100644 --- a/Tests/CTestTestMemcheck/CMakeLists.txt +++ b/Tests/CTestTestMemcheck/CMakeLists.txt @@ -91,7 +91,11 @@ gen_mcnl_test(DummyPurifyNoLogfile "\${PSEUDO_PURIFY}") gen_mcnl_test(DummyValgrindNoLogfile "\${PSEUDO_VALGRIND}") gen_mcnl_test(DummyBCNoLogfile "\${PSEUDO_BC}") -set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_PRE_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")\nset(CTEST_CUSTOM_POST_MEMCHECK \"\${CTEST_MEMORYCHECK_COMMAND}\")") +set(CTEST_EXTRA_CODE "string(REPLACE \" \" \"\\\\ \" PRE_POST_COMMAND \"\${CTEST_MEMORYCHECK_COMMAND}\") + +set(CTEST_CUSTOM_PRE_MEMCHECK \"\${PRE_POST_COMMAND} pre command\") +set(CTEST_CUSTOM_POST_MEMCHECK \"\${PRE_POST_COMMAND} post command \") +") gen_mc_test(DummyValgrindPrePost "\${PSEUDO_VALGRIND}") set(CTEST_EXTRA_CODE "set(CTEST_CUSTOM_POST_MEMCHECK \"\${ERROR_COMMAND}\")") diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 49f1c58..1910f8c 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -270,6 +270,8 @@ set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2 set_property(TARGET cmp0022OLD APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) set_property(TARGET cmp0022OLD APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib3) +add_library(noIncludesInterface empty.cpp) + install(TARGETS testLibRequired testLibIncludeRequired1 testLibIncludeRequired2 @@ -278,6 +280,7 @@ install(TARGETS testLibRequired testLibIncludeRequired5 testLibIncludeRequired6 testSharedLibRequired + noIncludesInterface EXPORT RequiredExp DESTINATION lib INCLUDES DESTINATION installIncludesTest diff --git a/Tests/ExportImport/Export/empty.cpp b/Tests/ExportImport/Export/empty.cpp new file mode 100644 index 0000000..1787013 --- /dev/null +++ b/Tests/ExportImport/Export/empty.cpp @@ -0,0 +1,4 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty() { return 0; } diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt index 6c29057..ae7627e 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt @@ -1,4 +1,4 @@ CMake Error at CMP0022-export.cmake:11 \(export\): Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style - INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + LINK_INTERFACE_LIBRARIES properties populated, but it was exported without the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt index 3425e8e..405dd8d 100644 --- a/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt +++ b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt @@ -1,4 +1,4 @@ CMake Error in CMakeLists.txt: Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style - INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + LINK_INTERFACE_LIBRARIES properties populated, but it was exported without the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake index d4e31cd..64f394c 100644 --- a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake @@ -1,4 +1,4 @@ -add_library(foo SHARED empty.cpp) -add_library(bar SHARED empty.cpp) +add_library(foo STATIC empty.cpp) +add_library(bar STATIC empty.cpp) target_link_libraries(foo $<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,anything>:bar>) |