Updates from BitShares FC #22

Closed
nathanielhourt wants to merge 693 commits from dapp-support into latest-fc
7 changed files with 1 additions and 966 deletions
Showing only changes of commit 7e07bc4514 - Show all commits

View file

@ -21,8 +21,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/GitVersionGen")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
INCLUDE(GetPrerequisites)
INCLUDE( VersionMacros )
INCLUDE( SetupTargetMacros )
INCLUDE(GetGitRevisionDescription)
INCLUDE(CheckLibraryExists)
@ -159,8 +157,6 @@ ENDIF( LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB )
find_package(OpenSSL REQUIRED)
option( UNITY_BUILD OFF )
set( fc_sources
src/popcount.cpp
src/variant.cpp
@ -243,7 +239,7 @@ list(APPEND sources ${fc_headers})
add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL )
setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC )
add_library( fc ${sources} )
install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include )
# begin editline stuff

View file

@ -1,74 +0,0 @@
# This module defines the ARGUMENT_PARSER macro for parsing macro arguments.
# ARGUMENT_PARSER Macro
# This macro parses a mixed list of arguments and headers into lists and boolean
# variables. The output lists and boolean variables are stored using
# tolower( header ) variable names. All non-header arguments will be added to
# the output list that corresponds to the header that they follow (or to the
# default list if no header has been parsed yet). If a boolean header is passed,
# then its corresponding output variable is set to YES.
#
# Usage:
# ARGUMENT_PARSER( default_list lists bools ARGN )
#
# Parameters:
# default_list The name of the variable that list values should be added
# to before any list headers have been reached. You may
# pass "" to disregard premature list values.
# lists The list headers (semicolon-separated string).
# bools The boolean headers (semicolon-separated string).
# ARGN The arguments to parse.
MACRO( ARGUMENT_PARSER default_list lists bools )
# Start using the default list.
SET( dest "${default_list}" )
IF( NOT dest )
SET( dest tmp )
ENDIF( NOT dest )
# Clear all of the lists.
FOREACH( list_itr ${lists} )
STRING( TOLOWER ${list_itr} lower )
SET( ${lower} "" )
ENDFOREACH( list_itr )
# Set all boolean variables to NO.
FOREACH( bool_itr ${bools} )
STRING( TOLOWER ${bool_itr} lower )
SET( ${lower} NO )
ENDFOREACH( bool_itr )
# For all arguments.
FOREACH( arg_itr ${ARGN} )
SET( done NO )
# For each of the list headers, if the current argument matches a list
# header, then set the destination to the header.
FOREACH( list_itr ${lists} )
IF( ${arg_itr} STREQUAL ${list_itr} )
STRING( TOLOWER ${arg_itr} lower )
SET( dest ${lower} )
SET( done YES )
ENDIF( ${arg_itr} STREQUAL ${list_itr} )
ENDFOREACH( list_itr )
# For each of the boolean headers, if the current argument matches a
# boolean header, then set the boolean variable to true.
FOREACH( bool_itr ${bools} )
IF( ${arg_itr} STREQUAL ${bool_itr} )
STRING( TOLOWER ${arg_itr} lower )
SET( ${lower} YES )
SET( done YES )
ENDIF( ${arg_itr} STREQUAL ${bool_itr} )
ENDFOREACH( bool_itr )
# If the current argument is not a header, then add it to the current
# destination list.
IF( NOT done )
SET( ${dest} ${${dest}} ${arg_itr} )
ENDIF( NOT done )
ENDFOREACH( arg_itr )
ENDMACRO( ARGUMENT_PARSER )

View file

@ -1,123 +0,0 @@
# Module for locating Visual Leak Detector.
#
# Customizable variables:
# VLD_ROOT_DIR
# This variable points to the Visual Leak Detector root directory. By
# default, the module looks for the installation directory by examining the
# Program Files/Program Files (x86) folders and the VLDROOT environment
# variable.
#
# Read-only variables:
# VLD_FOUND
# Indicates that the library has been found.
#
# VLD_INCLUDE_DIRS
# Points to the Visual Leak Detector include directory.
#
# VLD_LIBRARY_DIRS
# Points to the Visual Leak Detector directory that contains the libraries.
# The content of this variable can be passed to link_directories.
#
# VLD_LIBRARIES
# Points to the Visual Leak Detector libraries that can be passed to
# target_link_libararies.
#
#
# Copyright (c) 2012 Sergiu Dotenco
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
INCLUDE (FindPackageHandleStandardArgs)
SET (_VLD_POSSIBLE_LIB_SUFFIXES lib)
# Version 2.0 uses vld_x86 and vld_x64 instead of simply vld as library names
IF (CMAKE_SIZEOF_VOID_P EQUAL 4)
LIST (APPEND _VLD_POSSIBLE_LIB_SUFFIXES lib/Win32)
ELSEIF (CMAKE_SIZEOF_VOID_P EQUAL 8)
LIST (APPEND _VLD_POSSIBLE_LIB_SUFFIXES lib/Win64)
ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 4)
FIND_PATH (VLD_ROOT_DIR
NAMES include/vld.h
PATHS ENV VLDROOT
"$ENV{PROGRAMFILES}/Visual Leak Detector"
"$ENV{PROGRAMFILES(X86)}/Visual Leak Detector"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Visual Leak Detector;InstallLocation]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Visual Leak Detector;InstallLocation]"
DOC "VLD root directory")
FIND_PATH (VLD_INCLUDE_DIR
NAMES vld.h
HINTS ${VLD_ROOT_DIR}
PATH_SUFFIXES include
DOC "VLD include directory")
FIND_LIBRARY (VLD_LIBRARY_DEBUG
NAMES vld
HINTS ${VLD_ROOT_DIR}
PATH_SUFFIXES ${_VLD_POSSIBLE_LIB_SUFFIXES}
DOC "VLD debug library")
IF (VLD_ROOT_DIR)
SET (_VLD_VERSION_FILE ${VLD_ROOT_DIR}/CHANGES.txt)
IF (EXISTS ${_VLD_VERSION_FILE})
SET (_VLD_VERSION_REGEX
"Visual Leak Detector \\(VLD\\) Version (([0-9]+)\\.([0-9]+)([a-z]|(.([0-9]+)))?)")
FILE (STRINGS ${_VLD_VERSION_FILE} _VLD_VERSION_TMP REGEX
${_VLD_VERSION_REGEX})
STRING (REGEX REPLACE ${_VLD_VERSION_REGEX} "\\1" _VLD_VERSION_TMP
"${_VLD_VERSION_TMP}")
STRING (REGEX REPLACE "([0-9]+).([0-9]+).*" "\\1" VLD_VERSION_MAJOR
"${_VLD_VERSION_TMP}")
STRING (REGEX REPLACE "([0-9]+).([0-9]+).*" "\\2" VLD_VERSION_MINOR
"${_VLD_VERSION_TMP}")
SET (VLD_VERSION ${VLD_VERSION_MAJOR}.${VLD_VERSION_MINOR})
IF ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
# major.minor.patch version numbering scheme
STRING (REGEX REPLACE "([0-9]+).([0-9]+).([0-9]+)" "\\3"
VLD_VERSION_PATCH "${_VLD_VERSION_TMP}")
SET (VLD_VERSION "${VLD_VERSION}.${VLD_VERSION_PATCH}")
SET (VLD_VERSION_COUNT 3)
ELSE ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
# major.minor version numbering scheme. The trailing letter is ignored.
SET (VLD_VERSION_COUNT 2)
ENDIF ("${_VLD_VERSION_TMP}" MATCHES "^([0-9]+).([0-9]+).([0-9]+)$")
ENDIF (EXISTS ${_VLD_VERSION_FILE})
ENDIF (VLD_ROOT_DIR)
IF (VLD_LIBRARY_DEBUG)
SET (VLD_LIBRARY debug ${VLD_LIBRARY_DEBUG} CACHE DOC "VLD library")
GET_FILENAME_COMPONENT (_VLD_LIBRARY_DIR ${VLD_LIBRARY_DEBUG} PATH)
SET (VLD_LIBRARY_DIR ${_VLD_LIBRARY_DIR} CACHE PATH "VLD library directory")
ENDIF (VLD_LIBRARY_DEBUG)
SET (VLD_INCLUDE_DIRS ${VLD_INCLUDE_DIR})
SET (VLD_LIBRARY_DIRS ${VLD_LIBRARY_DIR})
SET (VLD_LIBRARIES ${VLD_LIBRARY})
MARK_AS_ADVANCED (VLD_INCLUDE_DIR VLD_LIBRARY_DIR VLD_LIBRARY_DEBUG VLD_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (VLD REQUIRED_VARS VLD_ROOT_DIR
VLD_INCLUDE_DIR VLD_LIBRARY VERSION_VAR VLD_VERSION)

View file

@ -1,79 +0,0 @@
# -*- mode: cmake -*-
#
# Shamelessly stolen from MSTK who shamelessly stole from Amanzi open source code https://software.lanl.gov/ascem/trac)
#
# PARSE_LIBRARY_LIST( <lib_list>
# DEBUG <out_debug_list>
# OPT <out_opt_list>
# GENERAL <out_gen_list> )
# CMake module
include(CMakeParseArguments)
function(PARSE_LIBRARY_LIST)
# Macro: _print_usage
macro(_print_usage)
message("PARSE_LIBRARY_LIST <lib_list>\n"
" FOUND <out_flag>\n"
" DEBUG <out_debug_list>\n"
" OPT <out_opt_list>\n"
" GENERAL <out_gen_list>\n"
"lib_list string to parse\n"
"FOUND flag to indicate if keywords were found\n"
"DEBUG variable containing debug libraries\n"
"OPT variable containing optimized libraries\n"
"GENERAL variable containing debug libraries\n")
endmacro()
# Read in args
cmake_parse_arguments(PARSE_ARGS "" "FOUND;DEBUG;OPT;GENERAL" "" ${ARGN})
set(_parse_list "${PARSE_ARGS_UNPARSED_ARGUMENTS}")
if ( (NOT PARSE_ARGS_FOUND) OR
(NOT PARSE_ARGS_DEBUG) OR
(NOT PARSE_ARGS_OPT) OR
(NOT PARSE_ARGS_GENERAL) OR
(NOT _parse_list )
)
_print_usage()
message(FATAL_ERROR "Invalid arguments")
endif()
# Now split the list
set(_debug_libs "")
set(_opt_libs "")
set(_gen_libs "")
foreach( item ${_parse_list} )
if( ${item} MATCHES debug OR
${item} MATCHES optimized OR
${item} MATCHES general )
if( ${item} STREQUAL "debug" )
set( mylist "_debug_libs" )
elseif( ${item} STREQUAL "optimized" )
set( mylist "_opt_libs" )
elseif( ${item} STREQUAL "general" )
set( mylist "_gen_libs" )
endif()
else()
list( APPEND ${mylist} ${item} )
endif()
endforeach()
# Now set output vairables
set(${PARSE_ARGS_DEBUG} "${_debug_libs}" PARENT_SCOPE)
set(${PARSE_ARGS_OPT} "${_opt_libs}" PARENT_SCOPE)
set(${PARSE_ARGS_GENERAL} "${_gen_libs}" PARENT_SCOPE)
# If any of the lib lists are defined set flag to TRUE
if ( (_debug_libs) OR (_opt_libs) OR (_gen_libs) )
set(${PARSE_ARGS_FOUND} TRUE PARENT_SCOPE)
else()
set(${PARSE_ARGS_FOUND} FALSE PARENT_SCOPE)
endif()
endfunction(PARSE_LIBRARY_LIST)

View file

@ -1,369 +0,0 @@
# This module defines several macros that are useful for setting up library,
# plugin, and executable targets.
INCLUDE( ArgumentParser )
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})
# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp)
# Exclude all translation units from compilation
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
# Open the ub file
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
# Add include statement for each translation unit
foreach(source_file ${files} )
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
endforeach(source_file)
# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
endfunction(enable_unity_build)
# SETUP_LIBRARY Macro
# Sets up to build a library target. The macro uses the following global
# variables to define default values (you may change these variables to change
# the defaults:
# DEFAULT_HEADER_INSTALL_DIR
# DEFAULT_LIBRARY_INSTALL_DIR
#
# Usage:
# SETUP_LIBRARY( target
# SOURCES source1 [source2...]
# MOC_HEADERS header1 [header2...]
# LIBRARIES library1 [library2...]
# INSTALL_HEADERS header1 [header2...]
# HEADER_INSTALL_DIR dir
# LIBRARY_INSTALL_DIR dir
# DEBUG_POSTFIX string
# LIBRARY_TYPE string
# AUTO_INSTALL_HEADERS
# DONT_INSTALL_LIBRARY )
#
# Parameters:
# target The target library.
# SOURCES Follow with the sources to compile.
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
# LIBRARIES Follow with the libraries to link.
# INSTALL_HEADERS Follow with the headers to install.
# HEADER_INSTALL_DIR Follow with the directory to install the headers
# in (${DEFAULT_HEADER_INSTALL_DIR} by default).
# LIBRARY_INSTALL_DIR Follow with the directory to install the library
# in (${DEFAULT_LIBRARY_INSTALL_DIR} by default).
# DEBUG_POSTFIX Follow with the postfix to use when building in
# debug mode (${CMAKE_DEBUG_POSTFIX} by default).
# LIBRARY_TYPE Follow with the type of library to build: SHARED,
# STATIC, or MODULE (if not passed, then the
# behavior is defined by BUILD_SHARED_LIBS).
# AUTO_INSTALL_HEADERS If passed, all *.h files in the current directory
# will be installed.
# DONT_INSTALL_LIBRARY If passed, the library will not be installed.
MACRO( SETUP_LIBRARY target )
# Setup the list headers.
SET( list_headers
SOURCES
MOC_HEADERS
LIBRARIES
INSTALL_HEADERS
HEADER_INSTALL_DIR
LIBRARY_INSTALL_DIR
DEBUG_POSTFIX
LIBRARY_TYPE
)
# Setup the boolean headers.
SET( bool_headers
AUTO_INSTALL_HEADERS
DONT_INSTALL_LIBRARY
)
# Parse the arguments into variables.
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
# Set the default values for the header_install_dir, library_install_dir,
# and debug_postfix.
IF( NOT "${ARGN}" MATCHES "(^|;)HEADER_INSTALL_DIR($|;)" )
SET( header_install_dir ${DEFAULT_HEADER_INSTALL_DIR} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)HEADER_INSTALL_DIR($|;)" )
IF( NOT "${ARGN}" MATCHES "(^|;)LIBRARY_INSTALL_DIR($|;)" )
SET( library_install_dir ${DEFAULT_LIBRARY_INSTALL_DIR} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)LIBRARY_INSTALL_DIR($|;)" )
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
# Configure the header_install_dir and library_install_dir so that ${target}
# may be used in them. Setting target to itself is REQUIRED for the
# configuration to work.
SET( target "${target}" )
STRING( CONFIGURE "${header_install_dir}" header_install_dir )
STRING( CONFIGURE "${library_install_dir}" library_install_dir )
# Setup the library_type.
IF( NOT library_type )
SET( library_type STATIC )
IF( BUILD_SHARED_LIBS )
SET( library_type SHARED )
ENDIF( BUILD_SHARED_LIBS )
ENDIF( NOT library_type )
# Clear the moc_sources.
SET( moc_sources "" )
# If Qt is being used...
IF( QT_FOUND AND QT_LIBRARIES )
# Setup QT to build a shared library.
IF( library_type MATCHES SHARED )
ADD_DEFINITIONS( -DQT_SHARED )
ENDIF( library_type MATCHES SHARED )
# Setup the moc sources.
IF( moc_headers )
QT4_WRAP_CPP( moc_sources ${moc_headers} )
ENDIF( moc_headers )
ENDIF( QT_FOUND AND QT_LIBRARIES )
# Fatal error if moc_headers given but moc_sources not created.
IF( moc_headers AND NOT moc_sources )
MESSAGE( FATAL_ERROR "Calling SETUP_LIBRARY() with MOC_HEADERS failed. "
"Make sure that you included \${QT_USE_FILE} prior to calling "
"SETUP_LIBRARY()." )
ENDIF( moc_headers AND NOT moc_sources )
IF( UNITY_BUILD )
enable_unity_build( ${target} sources )
ENDIF( UNITY_BUILD )
# Add the library.
ADD_LIBRARY( "${target}" ${library_type} ${sources} ${moc_sources} )
# Setup the debug_postfix.
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
DEBUG_POSTFIX "${debug_postfix}" )
# Link in the dependency libraries.
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
# If auto_install_headers, then set the headers to all .h files in the
# directory.
IF( auto_install_headers )
FILE( GLOB install_headers *.h )
ENDIF( auto_install_headers )
# Install the headers.
IF( install_headers )
INSTALL( FILES ${install_headers} DESTINATION "${header_install_dir}" )
ENDIF( install_headers )
# Install the library.
IF( NOT dont_install_library )
INSTALL( TARGETS "${target}"
LIBRARY DESTINATION "${library_install_dir}"
ARCHIVE DESTINATION "${library_install_dir}" )
ENDIF( NOT dont_install_library )
ENDMACRO( SETUP_LIBRARY )
# SETUP_MODULE Macro
# Sets up to build a module (also setup as a Qt plugin if using Qt). A module is
# built as a shared library; however, modules are typically loaded dynamically
# rather than linked against. Therefore, this macro does not install header
# files and uses its own default install directory. The macro uses the following
# global variables to define default values (you may change these variables to
# change the defaults:
# DEFAULT_MODULE_INSTALL_DIR
#
# Usage:
# SETUP_MODULE( target
# SOURCES source1 [source2...]
# MOC_HEADERS header1 [header2...]
# LIBRARIES library1 [library2...]
# MODULE_INSTALL_DIR dir
# DEBUG_POSTFIX string
# DONT_INSTALL_MODULE )
#
# Parameters:
# target The target module (built as a shared library).
# SOURCES Follow with the sources to compile.
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
# LIBRARIES Follow with the libraries to link.
# MODULE_INSTALL_DIR Follow with the directory to install the module in
# (${DEFAULT_MODULE_INSTALL_DIR} by default).
# DEBUG_POSTFIX Follow with the postfix to use when building in
# debug mode (${CMAKE_DEBUG_POSTFIX} by default).
# DONT_INSTALL_MODULE If passed, the module will not be installed.
MACRO( SETUP_MODULE target )
# Setup the list headers.
SET( list_headers
SOURCES
MOC_HEADERS
LIBRARIES
MODULE_INSTALL_DIR
DEBUG_POSTFIX
)
# Setup the boolean headers.
SET( bool_headers
DONT_INSTALL_MODULE
)
# Parse the arguments into variables.
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
# Set the default values for the module_install_dir and debug postfix.
IF( NOT "${ARGN}" MATCHES "(^|;)MODULE_INSTALL_DIR($|;)" )
SET( module_install_dir ${DEFAULT_MODULE_INSTALL_DIR} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)MODULE_INSTALL_DIR($|;)" )
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
# Configure the module_install_dir so that ${target} may be used in it.
# Setting target to itself is REQUIRED for the configuration to work.
SET( target "${target}" )
STRING( CONFIGURE "${module_install_dir}" module_install_dir )
# Clear the moc_sources.
SET( moc_sources "" )
# If Qt is being used...
IF( QT_FOUND AND QT_LIBRARIES )
ADD_DEFINITIONS( -DQT_PLUGIN )
# Setup the moc sources.
IF( moc_headers )
QT4_WRAP_CPP( moc_sources ${moc_headers} )
ENDIF( moc_headers )
ENDIF( QT_FOUND AND QT_LIBRARIES )
# Fatal error if moc_headers given but moc_sources not created.
IF( moc_headers AND NOT moc_sources )
MESSAGE( FATAL_ERROR "Calling SETUP_MODULE() with MOC_HEADERS failed. "
"Make sure that you included \${QT_USE_FILE} prior to calling "
"SETUP_MODULE()." )
ENDIF( moc_headers AND NOT moc_sources )
# Add the module (built as a shared library).
ADD_LIBRARY( "${target}" SHARED ${sources} ${moc_sources} )
# Setup the debug postfix.
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
DEBUG_POSTFIX "${debug_postfix}" )
# Link in the dependency libraries.
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
# Install the module.
IF( NOT dont_install_module )
INSTALL( TARGETS "${target}"
LIBRARY DESTINATION "${module_install_dir}" )
ENDIF( NOT dont_install_module )
ENDMACRO( SETUP_MODULE )
# SETUP_EXECUTABLE Macro
# Sets up to build an executable target. The macro uses the following global
# variables to define default values (you may change these variables to change
# the defaults:
# DEFAULT_EXECUTABLE_INSTALL_DIR
#
# Usage:
# SETUP_EXECUTABLE( target
# SOURCES source1 [source2...]
# MOC_HEADERS header1 [header2...]
# LIBRARIES library1 [library2...]
# EXECUTABLE_INSTALL_DIR dir
# DEBUG_POSTFIX string
# DONT_INSTALL_EXECUTABLE )
#
# Parameters:
# target The target executable.
# SOURCES Follow with the sources to compile.
# MOC_HEADERS Follow with the headers to moc (Requires Qt).
# LIBRARIES Follow with the libraries to link.
# EXECUTABLE_INSTALL_DIR Follow with the directory to install the
# executable in
# (${DEFAULT_EXECUTABLE_INSTALL_DIR} by default).
# DEBUG_POSTFIX Follow with the postfix to use when building in
# debug mode (${CMAKE_DEBUG_POSTFIX} by
# default).
# DONT_INSTALL_EXECUTABLE If passed, the executable will not be
# installed.
MACRO( SETUP_EXECUTABLE target )
# Setup the list headers.
SET( list_headers
SOURCES
MOC_HEADERS
LIBRARIES
EXECUTABLE_INSTALL_DIR
DEBUG_POSTFIX
)
# Setup the boolean headers.
SET( bool_headers
DONT_INSTALL_EXECUTABLE
)
# Parse the arguments into variables.
ARGUMENT_PARSER( "" "${list_headers}" "${bool_headers}" ${ARGN} )
# Set the default values for the executable_install_dir and debug postfix.
IF( NOT "${ARGN}" MATCHES "(^|;)EXECUTABLE_INSTALL_DIR($|;)" )
SET( executable_install_dir ${DEFAULT_EXECUTABLE_INSTALL_DIR} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)EXECUTABLE_INSTALL_DIR($|;)" )
IF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
SET( debug_postfix ${CMAKE_DEBUG_POSTFIX} )
ENDIF( NOT "${ARGN}" MATCHES "(^|;)DEBUG_POSTFIX($|;)" )
# Configure the executable_install_dir so that ${target} may be used in it.
# Setting target to itself is REQUIRED for the configuration to work.
SET( target "${target}" )
STRING( CONFIGURE "${executable_install_dir}" executable_install_dir )
# Clear the moc_sources.
SET( moc_sources "" )
# If Qt is being used...
IF( QT_FOUND AND QT_LIBRARIES )
ADD_DEFINITIONS( -DQT_SHARED )
# Setup the moc sources.
IF( moc_headers )
QT4_WRAP_CPP( moc_sources ${moc_headers} )
ENDIF( moc_headers )
ENDIF( QT_FOUND AND QT_LIBRARIES )
# Fatal error if moc_headers given but moc_sources not created.
IF( moc_headers AND NOT moc_sources )
MESSAGE( FATAL_ERROR "Calling SETUP_EXECUTABLE() with MOC_HEADERS failed. "
"Make sure that you included \${QT_USE_FILE} prior to calling "
"SETUP_EXECUTABLE()." )
ENDIF( moc_headers AND NOT moc_sources )
# Add the executable.
ADD_EXECUTABLE( "${target}" ${sources} ${moc_sources} )
# Setup the debug postfix.
SET_TARGET_PROPERTIES ( "${target}" PROPERTIES
DEBUG_POSTFIX "${debug_postfix}" )
# Link in the dependency libraries.
TARGET_LINK_LIBRARIES( "${target}" ${libraries} )
# Install the executable.
IF( NOT dont_install_executable )
INSTALL( TARGETS "${target}" RUNTIME DESTINATION
"${executable_install_dir}" )
ENDIF( NOT dont_install_executable )
ENDMACRO( SETUP_EXECUTABLE )

View file

@ -1,72 +0,0 @@
# This module defines macros that are useful for using libraries in a build. The
# macros in this module are typically used along with the FindDependencyMacros.
# ADD_LIBRARY_TO_LIST Macro
# Adds a library to a list of libraries if it is found. Otherwise, reports an
# error.
#
# Usage:
# ADD_LIBRARY_TO_LIST( libraries found lib lib_name )
#
# Parameters:
# libraries The list of libraries to add the library to.
# found Whether or not the library to add was found.
# lib The library to add to the list.
# lib_name The name of the library to add to the list.
MACRO( ADD_LIBRARY_TO_LIST libraries found lib lib_name )
# Setting found to itself is necessary for the conditional to work.
SET( found ${found} )
# IF found, then add the library to the list, else report an error.
IF( found )
LIST( REMOVE_ITEM ${libraries} ${lib} )
SET( ${libraries} ${${libraries}} ${lib} )
ENDIF( found )
IF( NOT found )
MESSAGE( "Using ${lib_name} failed." )
ENDIF( NOT found )
ENDMACRO( ADD_LIBRARY_TO_LIST )
# USE_LIBRARY_GLOBALS Macro
# If ${prefix}_USE_${LIB} is true, then ${prefix}_${LIB}_LIBRARY will be added
# to ${prefix}_LIBRARIES (assuming the library was correctly found). All of the
# dependencies will also be added to ${prefix}_LIBRARIES.
#
# Usage:
# USE_LIBRARY_GLOBALS( prefix lib
# DEPS dependency1 [dependency2...] )
#
# Parameters:
# prefix The prefix for the global variables.
# lib The library to try to use.
# DEPS Follow with the list of dependencies that should be added with
# the given library.
MACRO( USE_LIBRARY_GLOBALS prefix lib )
STRING( TOUPPER ${lib} upper )
# If the library should be used...
IF( ${prefix}_USE_${upper} )
# Parse the arguments into variables.
ARGUMENT_PARSER( "" "DEPS" "" ${ARGN} )
# Add the library to the list.
ADD_LIBRARY_TO_LIST( ${prefix}_LIBRARIES "${${prefix}_${upper}_FOUND}"
"${${prefix}_${upper}_LIBRARY}" ${lib} )
# For each of the library's dependencies.
FOREACH( dep_itr ${deps} )
STRING( TOUPPER ${dep_itr} upper )
# Add the dependency to the list.
ADD_LIBRARY_TO_LIST( ${prefix}_LIBRARIES
"${${prefix}_${upper}_FOUND}"
"${${prefix}_${upper}_LIBRARY}" ${dep_itr} )
ENDFOREACH( dep_itr )
ENDIF( ${prefix}_USE_${upper} )
ENDMACRO( USE_LIBRARY_GLOBALS )

View file

@ -1,244 +0,0 @@
# This module defines several macros that are useful for handling version
# information. These macros work for version strings of format "#.#.#"
# representing major, minor, and patch integer components.
INCLUDE( ArgumentParser )
# PARSE_VERSION_STR Macro
# This macro parses the version string information from a string. The macro
# parses the string for the given definitions followed by whitespace (or by ':'
# or '"' characters) and then version information. For example, passing
# "MyVersion" as a definition would properly retrieve the version from a string
# "containing the line "def MyVersion: 1.2.3".
#
# Usage:
# PARSE_VERSION_STR( version string definition [definition2...] )
#
# Parameters:
# version The variable to store the version string in.
# string The string to parse.
# definition The definition(s) that may preceed the version string
# information.
MACRO( PARSE_VERSION_STR version string )
# Parse the arguments into variables.
ARGUMENT_PARSER( definitions "" "" ${ARGN} )
# For each of the given definitions...
FOREACH( def_itr ${definitions} )
# If the version has not been found, then attempt to parse it.
IF( NOT ${version} )
# Parse the version string.
STRING( REGEX MATCH "${def_itr}[ \t\":]+[0-9]+(.[0-9]+)?(.[0-9]+)?"
${version} ${string} )
STRING( REGEX MATCH "[0-9]+(.[0-9]+)?(.[0-9]+)?" ${version}
"${${version}}" )
CORRECT_VERSION_STR( ${version} "${${version}}" )
ENDIF( NOT ${version} )
ENDFOREACH( def_itr )
ENDMACRO( PARSE_VERSION_STR )
# PARSE_VERSION_INT Macro
# This macro parses the version integer component information from a string. The
# macro parses the string for the given definitions followed by whitespace (or
# by ':' or '"' characters) and then version information. For example, passing
# "MyVersionMajor" as a definition would properly retrieve the version from a
# string "containing the line "def MyVersionMajor: 1".
#
# Usage:
# PARSE_VERSION_INT( version string definition [definition2...] )
#
# Parameters:
# version The variable to store the version integer component in.
# string The string to parse.
# definition The definition(s) that may preceed the version integer
# component information.
MACRO( PARSE_VERSION_INT version string )
# Parse the arguments into variables.
ARGUMENT_PARSER( definitions "" "" ${ARGN} )
# For each of the given definitions...
FOREACH( def_itr ${definitions} )
# If the version has not been found, then attempt to parse it.
IF( NOT ${version} )
# Parse the version string.
STRING( REGEX MATCH "${def_itr}[ \t\":]+[0-9]+" ${version}
${string} )
STRING( REGEX MATCH "[0-9]+" ${version} "${${version}}" )
ENDIF( NOT ${version} )
ENDFOREACH( def_itr )
ENDMACRO( PARSE_VERSION_INT )
# VERSION_STR_TO_INTS Macro
# This macro converts a version string into its three integer components.
#
# Usage:
# VERSION_STR_TO_INTS( major minor patch version )
#
# Parameters:
# major The variable to store the major integer component in.
# minor The variable to store the minor integer component in.
# patch The variable to store the patch integer component in.
# version The version string to convert ("#.#.#" format).
MACRO( VERSION_STR_TO_INTS major minor patch version )
STRING( REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+" "\\1" ${major} ${version} )
STRING( REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+" "\\1" ${minor} ${version} )
STRING( REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+)" "\\1" ${patch} ${version} )
ENDMACRO( VERSION_STR_TO_INTS )
# VERSION_INTS_TO_STR Macro
# This macro converts three version integer components into a version string.
#
# Usage:
# VERSION_INTS_TO_STR( version major minor patch )
#
# Parameters:
# version The variable to store the version string in.
# major The major version integer.
# minor The minor version integer.
# patch The patch version integer.
MACRO( VERSION_INTS_TO_STR version major minor patch )
SET( ${version} "${major}.${minor}.${patch}" )
CORRECT_VERSION_STR( ${version} ${${version}} )
ENDMACRO( VERSION_INTS_TO_STR version major minor patch )
# COMPARE_VERSION_STR Macro
# This macro compares two version strings to each other. The macro sets the
# result variable to -1 if lhs < rhs, 0 if lhs == rhs, and 1 if lhs > rhs.
#
# Usage:
# COMPARE_VERSION_STR( result lhs rhs )
#
# Parameters:
# result The variable to store the result of the comparison in.
# lhs The version of the left hand side ("#.#.#" format).
# rhs The version of the right hand side ("#.#.#" format).
MACRO( COMPARE_VERSION_STR result lhs rhs )
VERSION_STR_TO_INTS( lhs_major lhs_minor lhs_patch ${lhs} )
VERSION_STR_TO_INTS( rhs_major rhs_minor rhs_patch ${rhs} )
COMPARE_VERSION_INTS( ${result}
${lhs_major} ${lhs_minor} ${lhs_patch}
${rhs_major} ${rhs_minor} ${rhs_patch} )
ENDMACRO( COMPARE_VERSION_STR result lhs rhs )
# COMPARE_VERSION_INTS Macro
# This macro compares two versions to each other using their integer components.
# The macro sets the result variable to -1 if lhs < rhs, 0 if lhs == rhs, and 1
# if lhs > rhs.
#
# Usage:
# COMPARE_VERSION_INTS( result
# lhs_major lhs_minor lhs_patch
# rhs_major rhs_minor rhs_patch )
#
# Parameters:
# result The variable to store the result of the comparison in.
# lhs_major The major integer component for the left hand side.
# lhs_minor The minor integer component for the left hand side.
# lhs_patch The patch integer component for the left hand side.
# rhs_major The major integer component for the right hand side.
# rhs_minor The minor integer component for the right hand side.
# rhs_patch The patch integer component for the right hand side.
MACRO( COMPARE_VERSION_INTS result lhs_major lhs_minor lhs_patch
rhs_major rhs_minor rhs_patch )
SET( ${result} 0 )
IF( NOT ${result} AND ${lhs_major} LESS ${rhs_major} )
SET( ${result} -1 )
ENDIF( NOT ${result} AND ${lhs_major} LESS ${rhs_major} )
IF( NOT ${result} AND ${lhs_major} GREATER ${rhs_major} )
SET( ${result} 1 )
ENDIF( NOT ${result} AND ${lhs_major} GREATER ${rhs_major} )
IF( NOT ${result} AND ${lhs_minor} LESS ${rhs_minor} )
SET( ${result} -1 )
ENDIF( NOT ${result} AND ${lhs_minor} LESS ${rhs_minor} )
IF( NOT ${result} AND ${lhs_minor} GREATER ${rhs_minor} )
SET( ${result} 1 )
ENDIF( NOT ${result} AND ${lhs_minor} GREATER ${rhs_minor} )
IF( NOT ${result} AND ${lhs_patch} LESS ${rhs_patch} )
SET( ${result} -1 )
ENDIF( NOT ${result} AND ${lhs_patch} LESS ${rhs_patch} )
IF( NOT ${result} AND ${lhs_patch} GREATER ${rhs_patch} )
SET( ${result} 1 )
ENDIF( NOT ${result} AND ${lhs_patch} GREATER ${rhs_patch} )
ENDMACRO( COMPARE_VERSION_INTS result lhs_major lhs_minor lhs_patch
rhs_major rhs_minor rhs_patch )
# CORRECT_VERSION_STR Macro
# This macro corrects the version_str and stores the result in the version
# variable. If the version_str contains a version string in "#" or "#.#" format,
# then ".0" will be appended to the string to convert it to "#.#.#" format. If
# the version_str is invalid, then version will be set to "".
#
# Usage:
# CORRECT_VERSION_STR( version version_str )
#
# Parameters:
# version The variable to store the corrected version string in.
# version_str The version string to correct.
MACRO( CORRECT_VERSION_STR version version_str )
SET( ${version} "${version_str}" )
# Add ".0" to the end of the version string in case a full "#.#.#" string
# was not given.
FOREACH( itr RANGE 2 )
IF( NOT ${version} MATCHES "[0-9]+.[0-9]+.[0-9]+" )
SET( ${version} "${${version}}.0" )
ENDIF( NOT ${version} MATCHES "[0-9]+.[0-9]+.[0-9]+" )
ENDFOREACH( itr )
# If the version string is not correct, then set it to "".
IF( NOT ${version} MATCHES "^[0-9]+.[0-9]+.[0-9]+$" )
SET( ${version} "" )
ENDIF( NOT ${version} MATCHES "^[0-9]+.[0-9]+.[0-9]+$" )
ENDMACRO( CORRECT_VERSION_STR )
# CORRECT_VERSION_Int Macro
# This macro corrects the version_int and stores the result in the version
# variable. If the version_int is invalid, then version will be set to "".
#
# Usage:
# CORRECT_VERSION_Int( version version_int )
#
# Parameters:
# version The variable to store the corrected version integer
# component in.
# version_INT The version integer component to correct.
MACRO( CORRECT_VERSION_INT version version_int )
SET( ${version} "${version_int}" )
# If the version is not an integer, then set it to "".
IF( NOT ${version} MATCHES "^[0-9]+$" )
SET( ${version} "" )
ENDIF( NOT ${version} MATCHES "^[0-9]+$" )
ENDMACRO( CORRECT_VERSION_INT )