adding missing build files
This commit is contained in:
parent
9041b9bff4
commit
8f8bcafdc4
5 changed files with 886 additions and 0 deletions
74
CMakeModules/ArgumentParser.cmake
Normal file
74
CMakeModules/ArgumentParser.cmake
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
# 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 )
|
||||||
127
CMakeModules/FindWt.cmake
Executable file
127
CMakeModules/FindWt.cmake
Executable file
|
|
@ -0,0 +1,127 @@
|
||||||
|
# Find Wt includes and libraries
|
||||||
|
#
|
||||||
|
# This script sets the following variables:
|
||||||
|
#
|
||||||
|
# Wt_INCLUDE_DIR
|
||||||
|
# Wt_LIBRARIES - Release libraries
|
||||||
|
# Wt_FOUND - True if release libraries found
|
||||||
|
# Wt_DEBUG_LIBRARIES - Debug libraries
|
||||||
|
# Wt_DEBUG_FOUND - True if debug libraries found
|
||||||
|
#
|
||||||
|
# To direct the script to a particular Wt installation, use the
|
||||||
|
# standard cmake variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH
|
||||||
|
#
|
||||||
|
# To use this script to find Wt, when using the new style for include files:
|
||||||
|
# #include <Wt/WLineEdit>
|
||||||
|
# #include <Wt/Ext/LineEdit>
|
||||||
|
# #include <Wt/Chart/WPieChart>
|
||||||
|
#
|
||||||
|
# include the following CMake snippet in your project:
|
||||||
|
#
|
||||||
|
# FIND_PACKAGE( Wt REQUIRED )
|
||||||
|
# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} )
|
||||||
|
# TARGET_LINK_LIBRARIES( yourexe
|
||||||
|
# ${Wt_DEBUG_LIBRARY} # or {Wt_LIBRARY}
|
||||||
|
# ${Wt_HTTP_DEBUG_LIBRARY} # or {Wt_HTTP_LIBRARY}
|
||||||
|
# ${Wt_EXT_DEBUG_LIBRARY} # or {Wt_EXT_LIBRARY}
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# To use this script to find Wt, when using the old include style:
|
||||||
|
# #include <WLineEdit>
|
||||||
|
# #include <Ext/LineEdit>
|
||||||
|
# #include <Chart/WPieChart>
|
||||||
|
# style of include files, change the INCLUDE_DIRECTORIES statement to:
|
||||||
|
# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} ${Wt_INCLUDE_DIR}/Wt )
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 2007, Pau Garcia i Quiles, <pgquiles@elpauer.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
FIND_PATH( Wt_INCLUDE_DIR NAMES Wt/WObject PATHS ENV PATH PATH_SUFFIXES include wt )
|
||||||
|
|
||||||
|
SET( Wt_FIND_COMPONENTS Release Debug )
|
||||||
|
|
||||||
|
IF( Wt_INCLUDE_DIR )
|
||||||
|
FIND_LIBRARY( Wt_LIBRARY NAMES wt PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_EXT_LIBRARY NAMES wtext PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_HTTP_LIBRARY NAMES wthttp PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_FCGI_LIBRARY NAMES wtfcgi PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_DBO_LIBRARY NAMES wtdbo PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_DBOSQLITE3_LIBRARY NAMES wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
FIND_LIBRARY( Wt_DBOPOSTGRES_LIBRARY NAMES wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-release lib_release )
|
||||||
|
|
||||||
|
FIND_LIBRARY( Wt_DEBUG_LIBRARY NAMES wtd wt PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_EXT_DEBUG_LIBRARY NAMES wtextd wtext PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_HTTP_DEBUG_LIBRARY NAMES wthttpd wthttp PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_FCGI_DEBUG_LIBRARY NAMES wtfcgid wtfcgi PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_DBO_DEBUG_LIBRARY NAMES wtdbod wtdbo PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_DBOSQLITE3_DEBUG_LIBRARY NAMES wtdbosqlite3d wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
FIND_LIBRARY( Wt_DBOPOSTGRES_DEBUG_LIBRARY NAMES wtdbopostgresd wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib)
|
||||||
|
|
||||||
|
IF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY)
|
||||||
|
SET( Wt_FOUND TRUE )
|
||||||
|
SET( Wt_FIND_REQUIRED_Release TRUE )
|
||||||
|
SET( Wt_LIBRARIES ${Wt_HTTP_LIBRARY} ${Wt_EXT_LIBRARY} ${Wt_LIBRARY} )
|
||||||
|
ENDIF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY)
|
||||||
|
|
||||||
|
IF( Wt_DBO_LIBRARY )
|
||||||
|
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBO_LIBRARY} )
|
||||||
|
IF( Wt_DBOSQLITE3_LIBRARY )
|
||||||
|
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOSQLITE3_LIBRARY} )
|
||||||
|
ENDIF( Wt_DBOSQLITE3_LIBRARY )
|
||||||
|
IF( Wt_DBOPOSTGRES_LIBRARY )
|
||||||
|
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOPOSTGRES_LIBRARY} )
|
||||||
|
ENDIF( Wt_DBOPOSTGRES_LIBRARY )
|
||||||
|
ENDIF( Wt_DBO_LIBRARY )
|
||||||
|
|
||||||
|
IF( Wt_FCGI_LIBRARY )
|
||||||
|
SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_FCGI_LIBRARY} )
|
||||||
|
ENDIF( Wt_FCGI_LIBRARY )
|
||||||
|
|
||||||
|
IF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY)
|
||||||
|
SET( Wt_DEBUG_FOUND TRUE )
|
||||||
|
SET( Wt_FIND_REQUIRED_Debug TRUE )
|
||||||
|
SET( Wt_DEBUG_LIBRARIES ${Wt_HTTP_DEBUG_LIBRARY} ${Wt_EXT_DEBUG_LIBRARY} ${Wt_DEBUG_LIBRARY} )
|
||||||
|
ENDIF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY)
|
||||||
|
|
||||||
|
IF( Wt_DBO_DEBUG_LIBRARY )
|
||||||
|
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBO_DEBUG_LIBRARY} )
|
||||||
|
IF( Wt_DBOSQLITE3_DEBUG_LIBRARY )
|
||||||
|
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOSQLITE3_DEBUG_LIBRARY} )
|
||||||
|
ENDIF( Wt_DBOSQLITE3_DEBUG_LIBRARY )
|
||||||
|
IF( Wt_DBOPOSTGRES_DEBUG_LIBRARY )
|
||||||
|
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOPOSTGRES_DEBUG_LIBRARY} )
|
||||||
|
ENDIF( Wt_DBOPOSTGRES_DEBUG_LIBRARY )
|
||||||
|
ENDIF( Wt_DBO_DEBUG_LIBRARY )
|
||||||
|
|
||||||
|
IF( Wt_FCGI_DEBUG_LIBRARY )
|
||||||
|
SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_FCGI_DEBUG_LIBRARY} )
|
||||||
|
ENDIF( Wt_FCGI_DEBUG_LIBRARY )
|
||||||
|
|
||||||
|
IF(Wt_FOUND)
|
||||||
|
IF (NOT Wt_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found the Wt libraries at ${Wt_LIBRARIES}")
|
||||||
|
MESSAGE(STATUS "Found the Wt headers at ${Wt_INCLUDE_DIR}")
|
||||||
|
ENDIF (NOT Wt_FIND_QUIETLY)
|
||||||
|
ELSE(Wt_FOUND)
|
||||||
|
IF(Wt_FIND_REQUIRED)
|
||||||
|
MESSAGE(FATAL_ERROR "Could NOT find Wt")
|
||||||
|
ENDIF(Wt_FIND_REQUIRED)
|
||||||
|
ENDIF(Wt_FOUND)
|
||||||
|
|
||||||
|
IF(Wt_DEBUG_FOUND)
|
||||||
|
IF (NOT Wt_FIND_QUIETLY)
|
||||||
|
MESSAGE(STATUS "Found the Wt debug libraries at ${Wt_DEBUG_LIBRARIES}")
|
||||||
|
MESSAGE(STATUS "Found the Wt debug headers at ${Wt_INCLUDE_DIR}")
|
||||||
|
ENDIF (NOT Wt_FIND_QUIETLY)
|
||||||
|
ELSE(Wt_DEBUG_FOUND)
|
||||||
|
IF(Wt_FIND_REQUIRED_Debug)
|
||||||
|
MESSAGE(FATAL_ERROR "Could NOT find Wt debug libraries")
|
||||||
|
ENDIF(Wt_FIND_REQUIRED_Debug)
|
||||||
|
ENDIF(Wt_DEBUG_FOUND)
|
||||||
|
|
||||||
|
ENDIF( Wt_INCLUDE_DIR )
|
||||||
369
CMakeModules/SetupTargetMacros.cmake
Normal file
369
CMakeModules/SetupTargetMacros.cmake
Normal file
|
|
@ -0,0 +1,369 @@
|
||||||
|
# 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 )
|
||||||
72
CMakeModules/UseLibraryMacros.cmake
Normal file
72
CMakeModules/UseLibraryMacros.cmake
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
# 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 )
|
||||||
244
CMakeModules/VersionMacros.cmake
Normal file
244
CMakeModules/VersionMacros.cmake
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
# 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 )
|
||||||
Loading…
Reference in a new issue