Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • scs/ipaaca
  • ramin.yaghoubzadeh/ipaaca
2 results
Show changes
Commits on Source (115)
Showing
with 1549 additions and 1961 deletions
stages:
- deploy
conda-build-job:
stage: deploy
image: dominikbattefeld/miniconda3-build:conda-22.9.0
# Some information for debugging
before_script:
- conda --version
- conda list
# The actual call to build the package
script:
- conda build conda.recipe/
# The path of job artifacts has to be relative to and be a child of our project directory.
# Thus, to upload our package as job artifact, we need to copy the output of conda build to our working directory.
after_script:
- cp -r /opt/conda/conda-bld conda-build-output
artifacts:
paths:
- conda-build-output/*
REQUIRED="rsb"
REQUIRED=""
OPTIONAL=""
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
# IPAACA
This repository contains the software library IPAACA developed by the Social Cognitive Systems Group at Bielefeld University. IPAACA stands for 'Incremental Processing Architecture for Artificial Conversational Agents.' The library is available in three languages: Python (Python3 compatible), C++, and Java, and for three operating systems: Linux, OS X, and Windows.
## Build dependencies
### Linux
Dependencies: Protocol Buffer (libprotobuf), Transport Protocol (**libmosquittopp**, ros, librsb)
sudo apt-get install libprotobuf-dev
sudo apt-get install libprotoc-dev
sudo apt-get install protobuf-compiler
sudo apt-get install mosquitto libmosquittopp-dev
## Build/Install instructions
### Linux
**Compiling C++ Version**
cd ipaaca/ipaacalib/cpp
mkdir build
cd build
cmake ..
make
sudo make install
**Installing Python Version**
cd ipaaca/ipaacalib/python
python3 setup.py install --user
### OS X
### Windows
## Usage
**Python:** import ipaaca
**C++:** #include "ipaaca/ipaaca.h"
## History
## Credits
Hendrik Buschmeier <hbuschme@techfak.uni-bielefeld.de>
Ramin Yaghoubzadeh <ryaghoub@techfak.uni-bielefeld.de>
## License
GNU LESSER GENERAL PUBLIC LICENSE (See LICENSE.txt in the repository)
## Further Reading
[1] IPAACA: https://scs.techfak.uni-bielefeld.de/wiki/public/ipaaca/start
[2] Schlangen et al. "Middleware for Incremental Processing in Conversational Agents," SIGDIAL 2010. https://www.aclweb.org/anthology/W10-4308
# this one is important
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_PLATFORM Linux)
#this one not so much
set(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
set(CMAKE_C_COMPILER $ENV{CC})
# where is the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot)
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# god-awful hack because it seems to not run correct tests to determine this:
set(__CHAR_UNSIGNED___EXITCODE 1)
\ No newline at end of file
#!/bin/bash
echo "Installing ipaaca-cpp"
declare -a CMAKE_PLATFORM_FLAGS
INCLUDE_PATH="${PREFIX}/include"
LIBRARY_PATH="${PREFIX}/lib"
export CMAKE_INCLUDE_PATH=$INCLUDE_PATH
export CMAKE_LIBRARY_PATH=$LIBRARY_PATH
if [[ "$(uname)" == "Linux" ]]; then
# Linus needs this lrt flag
export LDFLAGS="$LDFLAGS -lrt"
CMAKE_PLATFORM_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE="${RECIPE_DIR}/cross-linux.cmake")
elif [[ "$(uname)" == "Darwin" ]]; then
echo "mac"
fi
# build protobuf files
mkdir -p ipaaca-cpp/build/ipaaca
cd proto
protoc ipaaca.proto --cpp_out=../ipaaca-cpp/build/ipaaca
# build ipaaca cpp
cd ../ipaaca-cpp/build
export VERBOSE=1
cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DBOOST_INCLUDEDIR=${INCLUDE_PATH} -DBOOST_LIBRARYDIR=${LIBRARY_PATH} ${CMAKE_PLATFORM_FLAGS[@]}
echo "Finished cmake, trying build now"
make
make install DESTDIR=${PREFIX}
cd ../../..
\ No newline at end of file
#!/bin/bash
# Since we setup subfolders for ipaaca and proto, we want to step into the ipaaca folder here
# Note: setup.py assumes protoc file to be at ../proto from here and we do not want to change
# that for easier manual installation
cd ipaaca-py
echo "Installing ipaaca using setup.py"
$PYTHON -m pip install . -vv --no-deps
#python setup.py install --single-version-externally-managed --record=record.txt
{% set protobufversion = "3.8.0.*" %}
{% set pahomqttversion = "1.4.0.*" %} # Currently no longer needed, but you may want to build your own if you want to include Ramin's patch
package:
name: ipaaca
version: "0.1.3"
source:
- path: ../ipaacalib/cpp
folder: ipaaca-cpp
- path: ../ipaacalib/proto
folder: proto
- path: ../ipaacalib/python
folder: ipaaca-py
build:
number: 4
requirements:
run:
- ipaaca-cpp
- ipaaca-py
outputs:
- name: ipaaca-cpp
script: install_cpp.sh # [unix]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake >=3.10
host:
- libprotobuf {{ protobufversion }}
- mosquitto
- boost-cpp
- libuuid
run:
- mosquitto
- libprotobuf {{ protobufversion }}
- boost-cpp
- libuuid
- name: ipaaca-py
noarch: python
script: install_python.sh
requirements:
host:
- python {{ python }}
- pip
- protobuf {{ protobufversion }}
run:
- python
- mosquitto
- paho-mqtt
- protobuf {{ protobufversion }}
{% set protobufversion = "3.8.0" %}
package:
name: ipaaca
version: "0.1.2"
source:
- path: ../ipaacalib/cpp
folder: ipaaca-cpp
- path: ../ipaacalib/proto
folder: proto
- path: ../ipaacalib/python
folder: ipaaca-py
build:
number: 9
requirements:
run:
- ipaaca-cpp
- ipaaca-py
outputs:
- name: ipaaca-cpp
script: install_cpp.sh # [unix]
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- cmake >=3.10
host:
- libprotobuf {{ protobufversion }}
- mosquitto
- boost-cpp {{ boostcpp }}
run:
- mosquitto
- libprotobuf {{ protobufversion }}
- boost-cpp {{ boostcpp }}
- name: ipaaca-py
noarch: python
script: install_python.sh
requirements:
host:
- python {{ py_version }}
- pip
- setuptools
- protobuf {{ protobufversion }}
run:
- python {{ py_version }}
- mosquitto
- paho-mqtt
- protobuf {{ protobufversion }}
\ No newline at end of file
Instructions for building ipaaca on Windows
Install Visual Studio 2017 (with C++), including CMake
Install GoW (Gnu on Windows) to have some POSIX-like utilities, or double-check the commands below
Open terminal via Visual Studio's "x64 Native Tools Command Prompt", for 64-bit builds
The following instructions are for Debug mode, you can use Release, too
(replace all occurrences below).
BUILD DEPS:
protobuf (latest test with 3.9.0):
cd cmake
mkdir build
cd build
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX="C:/Libs/protobuf/x64" -G "Visual Studio 15 2017 Win64" /p:Configuration=Debug ..
cmake --build . --target INSTALL --config Debug -- /nologo /verbosity:minimal /maxcpucount
mosquitto (latest test with 1.5.4):
mkdir build
cd build
# threading=off below disables a nasty library dependency, our dispatcher is threaded anyway
cmake -DWITH_THREADING=OFF -DCMAKE_INSTALL_PREFIX=C:/Libs/mosquitto/x64 -G "Visual Studio 15 2017 Win64" /p:Configuration=Debug ..
cmake --build . --target INSTALL --config Debug -- /nologo /verbosity:minimal /maxcpucount
cp lib\Debug\*.lib lib\cpp\Debug\*.lib \Libs\mosquitto\x64\
BUILD IPAACA (ipaaca4):
cd ......\repo\ipaaca\ipaacalib\proto
mkdir ..\cpp\build\ipaaca
\Libs\protobuf\x64\bin\protoc.exe ipaaca.proto --cpp_out=..\cpp\build\ipaaca
cd ..\cpp\build\ipaaca
cmake -DCMAKE_INSTALL_PREFIX="C:/Libs/ipaaca/x64" -G "Visual Studio 15 2017 Win64" /p:Configuration=Debug ..
cmake --build . --target INSTALL --config Debug -- /nologo /verbosity:minimal /maxcpucount
SETUP FOR VISUAL STUDIO PROJECTS:
Project -> Properties ->
Debugging: add the runtime paths to the environment variables (Path=%Path%;C:\Libs\ipaaca\x64\bin;C:\Libs\mosquitto\x64\bin)
C++: add the include directories (C:\Libs\ipaaca\x64\include;C:\Libs\protobuf\x64\include)
Linker: add ipaaca.lib to the dependencies and C:\Libs\ipaaca\x64\lib to the additional lib dirs
Also add /wd4146 to compiler options if you get errors in protobuf headers (like "unary negative on unsigned value").
......@@ -38,7 +38,7 @@ PROJECT_NAME = "IPAACA-C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = "Revision 12 (Protocol 2.0)"
#PROJECT_NUMBER = "Revision ... (Protocol ...)"
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
--- client.py.sav 2018-12-14 18:30:04.836523913 +0100
+++ client.py 2018-12-14 19:23:13.759468147 +0100
@@ -983,7 +983,7 @@
# sockpairR is used to break out of select() before the timeout, on a
# call to publish() etc.
- rlist = [self._sock, self._sockpairR]
+ rlist = [self._sock, self._sockpairR] if self._sock else [self._sockpairR]
try:
socklist = select.select(rlist, wlist, [], timeout)
except TypeError:
......@@ -3,21 +3,18 @@ cmake_minimum_required (VERSION 2.6)
# project name
project (ipaaca_cpp)
set (CMAKE_CXX_STANDARD 11)
#set (CMAKE_CXX_STANDARD 11)
# use C++11 (starting with proto v2 / ipaaca-c++ release 12)
## use C++11 (starting with proto v2 / ipaaca-c++ release 12)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
## use the following line to enable console debug messages in ipaaca
## (this entails a slight slowdown since dynamic log level checks made at the very least)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_DEBUG_MESSAGES")
# expose the full RSB api in the headers (set only in ipaaca itself)
# !! NOTE: at the moment required in any ipaaca cpp project in Windows !!
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_EXPOSE_FULL_RSB_API")
## use the following line to enable building mock IUs (FakeIU)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIPAACA_BUILD_MOCK_OBJECTS")
# find cmake modules locally too
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
......@@ -39,51 +36,47 @@ if(WIN32) # Check if we are on Windows
#
#
#
# If you want to compile rsb locally, check out the soa project 'rsb', build it
# and use resolve.sh to pull its libraries into this project.
# On the other hand, if you simply want to use the precompiled rsb from inside
# "rsx" (it works but has no debug info), uncomment the following four lines.
#
include_directories( ${PROJECT_SOURCE_DIR}/../../../rsb-win-scs_64bit/include/rsc0.14 )
include_directories( ${PROJECT_SOURCE_DIR}/../../../rsb-win-scs_64bit/include/rsb0.14 )
link_directories( ${PROJECT_SOURCE_DIR}/../../../rsb-win-scs_64bit/lib )
link_directories( ${PROJECT_SOURCE_DIR}/../../../rsb-win-scs_64bit/lib )
set(RSBLIBS rsc0.14 rsb0.14)
#set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../../rsx/RSC-0.14.5-win32/rsc0.14.lib ${PROJECT_SOURCE_DIR}/../../../rsx/RSB-0.14.2-win32/rsb0.14.lib )
set(LIBS ${LIBS} rpcrt4)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_LIBS ON)
#set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS date_time program_options system filesystem thread signals regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
#find_package(Boost COMPONENTS date_time program_options system filesystem thread signals regex REQUIRED)
#link_directories(${Boost_LIBRARY_DIRS})
#include_directories(${Boost_INCLUDE_DIRS})
# Windows linkage hack: overriding the determined libs to remove boost_thread (causes multiple-definition issues)
set(CORRECT_BOOST_LIBS "")
foreach(BLIB ${Boost_LIBRARIES})
#message(STATUS "Boost lib: ${BLIB}")
##message(STATUS "(Windows hack:) forcing vc110")
##string(REPLACE "-vc140" "-vc110" BLIB_CONV ${BLIB})
#string(REGEX MATCH "boost_thread[^/]+$" drop_item ${BLIB_CONV})
#if(drop_item)
# message(STATUS "(Windows hack:) =====> Removing boost_thread library from the linkage list.")
# else(drop_item)
list(APPEND CORRECT_BOOST_LIBS ${BLIB})
# endif(drop_item)
endforeach(BLIB ${Boost_LIBRARIES})
set(Boost_LIBRARIES ${CORRECT_BOOST_LIBS})
## Windows linkage hack: overriding the determined libs to remove boost_thread (causes multiple-definition issues)
#set(CORRECT_BOOST_LIBS "")
#foreach(BLIB ${Boost_LIBRARIES})
# list(APPEND CORRECT_BOOST_LIBS ${BLIB})
#endforeach(BLIB ${Boost_LIBRARIES})
#set(Boost_LIBRARIES ${CORRECT_BOOST_LIBS})
# Using custom Protobuf script (from rsc) because it honors PROTOBUF_ROOT
find_package(ProtocolBuffers REQUIRED)
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
#find_package(ProtocolBuffers REQUIRED PATHS "\\Libs\\protobuf")
#link_directories(${PROTOBUF_LIBRARY_DIRS})
#include_directories(${PROTOBUF_INCLUDE_DIRS})
#message(STATUS "############################")
#message(STATUS ${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_LIBRARY optimized "C:\\libs\\protobuf\\x64\\lib\\libprotobuf.lib" debug "C:\\libs\\protobuf\\x64\\lib\\libprotobufd.lib")
link_directories( "C:\\libs\\protobuf\\x64\\lib" )
include_directories( "C:\\libs\\protobuf\\x64\\include" )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
else()
message(SEND_ERROR "Unsupported compiler! Please build with MSVC 14.0 (Visual Studio 2015).")
message(SEND_ERROR "Unsupported compiler! Please build with MSVC++ 19.x (Visual Studio 2017).")
endif()
else()
#
......@@ -91,7 +84,7 @@ else()
# Setup section for Linux or OS X (using 'rsb' soa project)
#
#
find_package(Boost COMPONENTS system filesystem thread regex signals REQUIRED)
find_package(Boost COMPONENTS system filesystem thread regex REQUIRED)
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
#set(BOOSTLIBS boost_regex-mt boost_date_time-mt boost_program_options-mt boost_thread-mt boost_filesystem-mt boost_signals-mt boost_system-mt)
......@@ -100,12 +93,21 @@ else()
link_directories(${PROTOBUF_LIBRARY_DIRS})
include_directories(${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_INPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(PROTOBUF_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/build/ipaaca")
file(MAKE_DIRECTORY ${PROTOBUF_OUTPUT_DIRECTORY})
set(PROTOBUF_ARGUMENTS "--cpp_out=${PROTOBUF_OUTPUT_DIRECTORY}")
execute_process(COMMAND protoc ${PROTOBUF_ARGUMENTS} ipaaca.proto
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/../proto/
RESULT_VARIABLE PROTOBUF_RESULT
OUTPUT_VARIABLE PROTOBUF_OUTPUT_VARIABLE)
# change for each new rsb version
if (DEFINED APPLE)
set(RSBLIBS rsc0.14 rsb0.14)
#set(RSBLIBS rsc0.10 rsb.0.10)
else(DEFINED APPLE)
set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../deps/lib/librsc0.14.so ${PROJECT_SOURCE_DIR}/../../deps/lib/librsb0.14.so )
if (DEFINED APPLE)
#set(RSBLIBS rsc0.14 rsb0.14)
#set(RSBLIBS rsc0.10 rsb.0.10)
else(DEFINED APPLE)
#set(RSBLIBS ${PROJECT_SOURCE_DIR}/../../deps/lib/librsc0.14.so ${PROJECT_SOURCE_DIR}/../../deps/lib/librsb0.14.so )
set(LIBS ${LIBS} uuid)
endif(DEFINED APPLE)
# enhance the default search paths (headers, libs ...)
......@@ -119,28 +121,29 @@ else()
endif(DEFINED APPLE)
endif(WIN32)
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES})
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${RSBLIBS})
if(!WIN32)
set(LIBS ${LIBS} pthread)
endif(!WIN32)
if(NOT DEFINED WIN32)
if (DEFINED APPLE)
message(STATUS "No extra pthread flags needed on Mac")
else()
message(STATUS "Adding extra pthread flags for Linux")
# needs -lpthread AND -pthread
set(LIBS ${LIBS} pthread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
endif(NOT DEFINED WIN32)
# Hide the rsb-induced boost-signals warning (FOR NOW)
set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -DBOOST_SIGNALS_NO_DEPRECATION_WARNING")
#set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -DBOOST_SIGNALS_NO_DEPRECATION_WARNING")
# Compiler defines copied from the old build system
set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -D_BSD_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0")
## Compiler defines copied from the old build system
#set(IPAACA_CXX_DEFINES "${IPAACA_CXX_DEFINES} -D_DEFAULT_SOURCE -DUSE_AV -DMGC_USE_DOUBLE -DLEDA_PREFIX -D__NO_CAST_TO_LOCAL_TYPE__ -DDBGLVL=0")
# Combine the extra compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_OLD_CODE_CONVENIENCE_FLAGS} ${IPAACA_CXX_DEFINES}")
# add for for each new rsb version
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsc0.14 )
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsb0.14 )
#include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsc0.10 )
#include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include/rsb0.10 )
# add include dir for auto-generated headers placed in build/
include_directories( ${PROJECT_SOURCE_DIR}/build )
......@@ -150,13 +153,62 @@ include_directories( ${PROJECT_SOURCE_DIR}/include )
include_directories( ${PROJECT_SOURCE_DIR}/../../deps/include )
link_directories( ${PROJECT_SOURCE_DIR}/../../deps/lib )
###
### Back-ends (will include any and all that are compileable)
###
#
if(WIN32)
if(MSVC)
# fixed configuration for Windows
set(LIBS ${LIBS} "C:\\libs\\mosquitto\\x64\\mosquitto.lib" "C:\\libs\\mosquitto\\x64\\mosquittopp.lib")
link_directories( "C:\\libs\\mosquitto\\x64" )
include_directories( "C:\\libs\\mosquitto\\x64\\include" )
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-mqtt.cc)
endif(MSVC)
else()
# dynamic checks under Unix
# 1: MQTT
find_library(MOSQUITTO_LIB mosquittopp)
if(MOSQUITTO_LIB)
message(STATUS "=== MQTT backend === enabled")
set(LIBS ${LIBS} mosquittopp)
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-mqtt.cc)
else()
message(STATUS "=== MQTT backend === DISABLED (mosquittopp not found)")
endif()
# 2: ROS
set (ROSBASE $ENV{ROS_ROOT}/../..)
find_library(ROSCPP_LIB roscpp PATHS ${ROSBASE})
if(ROSCPP_LIB)
message(STATUS "=== ROS backend === enabled")
include_directories($ENV{ROS_ROOT}/../../include)
link_directories($ENV{ROS_ROOT}/../../lib)
set(LIBS ${LIBS} roscpp roscpp_serialization rosconsole)
set(BACKEND_SOURCES ${BACKEND_SOURCES} src/ipaaca-backend-ros.cc)
else()
message(STATUS "=== ROS backend === DISABLED (roscpp not found)")
endif()
#
# Now make sure that at least one of those backends is available
#
if(NOT BACKEND_SOURCES)
message(SEND_ERROR "\nWill not build IPAACA without any backends!\n")
endif()
endif() # of Unix block
# specify source files for ipaaca (auto-generated ones are in build/ )
set (SOURCE
src/ipaaca.cc
src/ipaaca-config.cc
src/ipaaca-converters.cc
src/ipaaca-backend.cc
src/ipaaca-buffers.cc
src/ipaaca-internal.cc
src/ipaaca-iuinterface.cc
src/ipaaca-initializer.cc
src/ipaaca-iuinterface.cc
src/ipaaca-ius.cc
src/ipaaca-links.cc
src/ipaaca-locking.cc
......@@ -164,64 +216,78 @@ set (SOURCE
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
src/util/notifier.cc
src/b64/b64.cc
build/ipaaca/ipaaca.pb.cc
)
set (JSON_TEST_SOURCE
src/ipaaca.cc
src/ipaaca-buffers.cc
src/ipaaca-fake.cc
src/ipaaca-internal.cc
src/ipaaca-iuinterface.cc
src/ipaaca-json.cc # main
src/ipaaca-locking.cc
src/ipaaca-links.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
# more stuff going beyond the fake test case
src/ipaaca-ius.cc
build/ipaaca/ipaaca.pb.cc
)
set (SOURCE ${SOURCE} ${BACKEND_SOURCES})
#set (JSON_TEST_SOURCE
# src/ipaaca.cc
# src/ipaaca-buffers.cc
# src/ipaaca-fake.cc
# src/ipaaca-internal.cc
# src/ipaaca-iuinterface.cc
# src/ipaaca-json.cc # main
# src/ipaaca-locking.cc
# src/ipaaca-links.cc
# src/ipaaca-payload.cc
# src/ipaaca-cmdline-parser.cc
# src/ipaaca-string-utils.cc
# # more stuff going beyond the fake test case
# src/ipaaca-ius.cc
# build/ipaaca/ipaaca.pb.cc
# )
#
set (TESTER_SOURCE
src/ipaaca-tester.cc # main
src/ipaaca.cc
src/ipaaca-config.cc
src/ipaaca-converters.cc
src/ipaaca-backend.cc
src/ipaaca-buffers.cc
src/ipaaca-fake.cc
src/ipaaca-internal.cc
src/ipaaca-initializer.cc
src/ipaaca-iuinterface.cc
src/ipaaca-locking.cc
src/ipaaca-ius.cc
src/ipaaca-links.cc
src/ipaaca-locking.cc
src/ipaaca-payload.cc
src/ipaaca-cmdline-parser.cc
src/ipaaca-string-utils.cc
# more stuff going beyond the fake test case
src/ipaaca-ius.cc
src/util/notifier.cc
src/b64/b64.cc
build/ipaaca/ipaaca.pb.cc
)
set (TESTER_SOURCE ${TESTER_SOURCE} ${BACKEND_SOURCES})
if(WIN32)
if(MSVC)
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "C:/Libs/ipaaca/x64")
endif()
endif()
else()
# this is for building with cmake/soa
set(CMAKE_INSTALL_PREFIX "")
endif()
# compile all files to "ipaaca" shared library
add_library(ipaaca SHARED ${SOURCE})
# and link all the required external libs (found above using find_package etc.)
target_link_libraries(ipaaca ${LIBS})
add_executable (ipaaca-test-json ${JSON_TEST_SOURCE})
target_link_libraries (ipaaca-test-json ${LIBS})
#add_executable (ipaaca-test-json ${JSON_TEST_SOURCE})
#target_link_libraries (ipaaca-test-json ${LIBS})
add_executable (ipaaca-tester-cpp ${TESTER_SOURCE})
target_compile_options (ipaaca-tester-cpp PRIVATE "-DIPAACA_STATIC_BINARY")
target_link_libraries (ipaaca-tester-cpp ${LIBS})
set(DEFAULT_BIN_SUBDIR bin)
set(DEFAULT_LIB_SUBDIR lib)
set(DEFAULT_DATA_SUBDIR share/data)
set(DEFAULT_INCLUDE_SUBDIR include)
set(CMAKE_INSTALL_PREFIX "")
install (
TARGETS ipaaca ipaaca-test-json ipaaca-tester-cpp
TARGETS ipaaca ipaaca-tester-cpp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
......
#.rst:
# FindBoost
# ---------
#
# Find Boost include dirs and libraries
#
# Use this module by invoking find_package with the form::
#
# find_package(Boost
# [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0
# [REQUIRED] # Fail with error if Boost is not found
# [COMPONENTS <libs>...] # Boost libraries by their canonical name
# ) # e.g. "date_time" for "libboost_date_time"
#
# This module finds headers and requested component libraries OR a CMake
# package configuration file provided by a "Boost CMake" build. For the
# latter case skip to the "Boost CMake" section below. For the former
# case results are reported in variables::
#
# Boost_FOUND - True if headers and requested libraries were found
# Boost_INCLUDE_DIRS - Boost include directories
# Boost_LIBRARY_DIRS - Link directories for Boost libraries
# Boost_LIBRARIES - Boost component libraries to be linked
# Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
# Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
# target_link_libraries debug/optimized keywords)
# Boost_VERSION - BOOST_VERSION value from boost/version.hpp
# Boost_LIB_VERSION - Version string appended to library filenames
# Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
# Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
# Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
# Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
# - Pass to add_definitions() to have diagnostic
# information about Boost's automatic linking
# displayed during compilation
#
# This module reads hints about search locations from variables::
#
# BOOST_ROOT - Preferred installation prefix
# (or BOOSTROOT)
# BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
# BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
# Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
# specified by these hint variables. Default is OFF.
# Boost_ADDITIONAL_VERSIONS
# - List of Boost versions not known to this module
# (Boost install locations may contain the version)
#
# and saves search results persistently in CMake cache entries::
#
# Boost_INCLUDE_DIR - Directory containing Boost headers
# Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries
# Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries
# Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant
# Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant
#
# The following :prop_tgt:`IMPORTED` targets are also defined::
#
# Boost::boost - Target for header-only dependencies
# (Boost include directory)
# Boost::<C> - Target for specific component dependency
# (shared or static library); <C> is lower-
# case
# Boost::diagnostic_definitions - interface target to enable diagnostic
# information about Boost's automatic linking
# during compilation (adds BOOST_LIB_DIAGNOSTIC)
# Boost::disable_autolinking - interface target to disable automatic
# linking with MSVC (adds BOOST_ALL_NO_LIB)
# Boost::dynamic_linking - interface target to enable dynamic linking
# linking with MSVC (adds BOOST_ALL_DYN_LINK)
#
# Implicit dependencies such as Boost::filesystem requiring
# Boost::system will be automatically detected and satisfied, even
# if system is not specified when using find_package and if
# Boost::system is not added to target_link_libraries. If using
# Boost::thread, then Thread::Thread will also be added automatically.
#
# It is important to note that the imported targets behave differently
# than variables created by this module: multiple calls to
# find_package(Boost) in the same directory or sub-directories with
# different options (e.g. static or shared) will not override the
# values of the targets created by the first call.
#
# Users may set these hints or results as cache entries. Projects
# should not read these entries directly but instead use the above
# result variables. Note that some hint names start in upper-case
# "BOOST". One may specify these as environment variables if they are
# not specified as CMake variables or cache entries.
#
# This module first searches for the Boost header files using the above
# hint variables (excluding BOOST_LIBRARYDIR) and saves the result in
# Boost_INCLUDE_DIR. Then it searches for requested component libraries
# using the above hints (excluding BOOST_INCLUDEDIR and
# Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR,
# and the library name configuration settings below. It saves the
# library directories in Boost_LIBRARY_DIR_DEBUG and
# Boost_LIBRARY_DIR_RELEASE and individual library
# locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE.
# When one changes settings used by previous searches in the same build
# tree (excluding environment variables) this module discards previous
# search results affected by the changes and searches again.
#
# Boost libraries come in many variants encoded in their file name.
# Users or projects may tell this module which variant to find by
# setting variables::
#
# Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
# libraries ('mt' tag). Default is ON.
# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
# libraries. Default is OFF.
# Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
# libraries linked statically to the C++ runtime
# ('s' tag). Default is platform dependent.
# Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
# libraries linked to the MS debug C++ runtime
# ('g' tag). Default is ON.
# Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
# debug Python build ('y' tag). Default is OFF.
# Boost_USE_STLPORT - Set to ON to use libraries compiled with
# STLPort ('p' tag). Default is OFF.
# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
# - Set to ON to use libraries compiled with
# STLPort deprecated "native iostreams"
# ('n' tag). Default is OFF.
# Boost_COMPILER - Set to the compiler-specific library suffix
# (e.g. "-gcc43"). Default is auto-computed
# for the C++ compiler in use.
# Boost_THREADAPI - Suffix for "thread" component library name,
# such as "pthread" or "win32". Names with
# and without this suffix will both be tried.
# Boost_NAMESPACE - Alternate namespace used to build boost with
# e.g. if set to "myboost", will search for
# myboost_thread instead of boost_thread.
#
# Other variables one may set to control this module are::
#
# Boost_DEBUG - Set to ON to enable debug output from FindBoost.
# Please enable this before filing any bug report.
# Boost_DETAILED_FAILURE_MSG
# - Set to ON to add detailed information to the
# failure message even when the REQUIRED option
# is not given to the find_package call.
# Boost_REALPATH - Set to ON to resolve symlinks for discovered
# libraries to assist with packaging. For example,
# the "system" component library may be resolved to
# "/usr/lib/libboost_system.so.1.42.0" instead of
# "/usr/lib/libboost_system.so". This does not
# affect linking and should not be enabled unless
# the user needs this information.
# Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and
# Boost_LIBRARY_DIR_DEBUG.
#
# On Visual Studio and Borland compilers Boost headers request automatic
# linking to corresponding libraries. This requires matching libraries
# to be linked explicitly or available in the link library search path.
# In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve
# dynamic linking. Boost automatic linking typically requests static
# libraries with a few exceptions (such as Boost.Python). Use::
#
# add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
#
# to ask Boost to report information about automatic linking requests.
#
# Example to find Boost headers only::
#
# find_package(Boost 1.36.0)
# if(Boost_FOUND)
# include_directories(${Boost_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# endif()
#
# Example to find Boost libraries and use imported targets::
#
# find_package(Boost 1.56 REQUIRED COMPONENTS
# date_time filesystem iostreams)
# add_executable(foo foo.cc)
# target_link_libraries(foo Boost::date_time Boost::filesystem
# Boost::iostreams)
#
# Example to find Boost headers and some *static* libraries::
#
# set(Boost_USE_STATIC_LIBS ON) # only find static libs
# set(Boost_USE_MULTITHREADED ON)
# set(Boost_USE_STATIC_RUNTIME OFF)
# find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
# if(Boost_FOUND)
# include_directories(${Boost_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${Boost_LIBRARIES})
# endif()
#
# Boost CMake
# ^^^^^^^^^^^
#
# If Boost was built using the boost-cmake project it provides a package
# configuration file for use with find_package's Config mode. This
# module looks for the package configuration file called
# BoostConfig.cmake or boost-config.cmake and stores the result in cache
# entry "Boost_DIR". If found, the package configuration file is loaded
# and this module returns with no further action. See documentation of
# the Boost CMake package configuration for details on what it provides.
#
# Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake.
#=============================================================================
# Copyright 2006-2012 Kitware, Inc.
# Copyright 2006-2008 Andreas Schneider <mail@cynapses.org>
# Copyright 2007 Wengo
# Copyright 2007 Mike Jackson
# Copyright 2008 Andreas Pakulat <apaku@gmx.de>
# Copyright 2008-2012 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
#-------------------------------------------------------------------------------
# Before we go searching, check whether boost-cmake is available, unless the
# user specifically asked NOT to search for boost-cmake.
#
# If Boost_DIR is set, this behaves as any find_package call would. If not,
# it looks at BOOST_ROOT and BOOSTROOT to find Boost.
#
if (NOT Boost_NO_BOOST_CMAKE)
# If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives,
# since these are more conventional for Boost.
if ("$ENV{Boost_DIR}" STREQUAL "")
if (NOT "$ENV{BOOST_ROOT}" STREQUAL "")
set(ENV{Boost_DIR} $ENV{BOOST_ROOT})
elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "")
set(ENV{Boost_DIR} $ENV{BOOSTROOT})
endif()
endif()
# Do the same find_package call but look specifically for the CMake version.
# Note that args are passed in the Boost_FIND_xxxxx variables, so there is no
# need to delegate them to this find_package call.
find_package(Boost QUIET NO_MODULE)
mark_as_advanced(Boost_DIR)
# If we found boost-cmake, then we're done. Print out what we found.
# Otherwise let the rest of the module try to find it.
if (Boost_FOUND)
message("Boost ${Boost_FIND_VERSION} found.")
if (Boost_FIND_COMPONENTS)
message("Found Boost components:")
message(" ${Boost_FIND_COMPONENTS}")
endif()
return()
endif()
endif()
#-------------------------------------------------------------------------------
# FindBoost functions & macros
#
############################################
#
# Check the existence of the libraries.
#
############################################
# This macro was taken directly from the FindQt4.cmake file that is included
# with the CMake distribution. This is NOT my work. All work was done by the
# original authors of the FindQt4.cmake file. Only minor modifications were
# made to remove references to Qt and make this file more generally applicable
# And ELSE/ENDIF pairs were removed for readability.
#########################################################################
macro(_Boost_ADJUST_LIB_VARS basename)
if(Boost_INCLUDE_DIR )
if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
else()
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
endif()
# FIXME: This probably should be set for both cases
set(Boost_${basename}_LIBRARIES optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
endif()
# if only the release version was found, set the debug variable also to the release version
if(Boost_${basename}_LIBRARY_RELEASE AND NOT Boost_${basename}_LIBRARY_DEBUG)
set(Boost_${basename}_LIBRARY_DEBUG ${Boost_${basename}_LIBRARY_RELEASE})
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE})
set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE})
endif()
# if only the debug version was found, set the release variable also to the debug version
if(Boost_${basename}_LIBRARY_DEBUG AND NOT Boost_${basename}_LIBRARY_RELEASE)
set(Boost_${basename}_LIBRARY_RELEASE ${Boost_${basename}_LIBRARY_DEBUG})
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_DEBUG})
set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_DEBUG})
endif()
# If the debug & release library ends up being the same, omit the keywords
if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG})
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
endif()
if(Boost_${basename}_LIBRARY AND Boost_${basename}_HEADER)
set(Boost_${basename}_FOUND ON)
endif()
endif()
# Make variables changeable to the advanced user
mark_as_advanced(
Boost_${basename}_LIBRARY_RELEASE
Boost_${basename}_LIBRARY_DEBUG
)
endmacro()
# Detect changes in used variables.
# Compares the current variable value with the last one.
# In short form:
# v != v_LAST -> CHANGED = 1
# v is defined, v_LAST not -> CHANGED = 1
# v is not defined, but v_LAST is -> CHANGED = 1
# otherwise -> CHANGED = 0
# CHANGED is returned in variable named ${changed_var}
macro(_Boost_CHANGE_DETECT changed_var)
set(${changed_var} 0)
foreach(v ${ARGN})
if(DEFINED _Boost_COMPONENTS_SEARCHED)
if(${v})
if(_${v}_LAST)
string(COMPARE NOTEQUAL "${${v}}" "${_${v}_LAST}" _${v}_CHANGED)
else()
set(_${v}_CHANGED 1)
endif()
elseif(_${v}_LAST)
set(_${v}_CHANGED 1)
endif()
if(_${v}_CHANGED)
set(${changed_var} 1)
endif()
else()
set(_${v}_CHANGED 0)
endif()
endforeach()
endmacro()
#
# Find the given library (var).
# Use 'build_type' to support different lib paths for RELEASE or DEBUG builds
#
macro(_Boost_FIND_LIBRARY var build_type)
find_library(${var} ${ARGN})
if(${var})
# If this is the first library found then save Boost_LIBRARY_DIR_[RELEASE,DEBUG].
if(NOT Boost_LIBRARY_DIR_${build_type})
get_filename_component(_dir "${${var}}" PATH)
set(Boost_LIBRARY_DIR_${build_type} "${_dir}" CACHE PATH "Boost library directory ${build_type}" FORCE)
endif()
elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
# Try component-specific hints but do not save Boost_LIBRARY_DIR_[RELEASE,DEBUG].
find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN})
endif()
# If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is known then search only there.
if(Boost_LIBRARY_DIR_${build_type})
set(_boost_LIBRARY_SEARCH_DIRS_${build_type} ${Boost_LIBRARY_DIR_${build_type}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" Boost_LIBRARY_DIR_${build_type} = ${Boost_LIBRARY_DIR_${build_type}}"
" _boost_LIBRARY_SEARCH_DIRS_${build_type} = ${_boost_LIBRARY_SEARCH_DIRS_${build_type}}")
endif()
endif()
endmacro()
#-------------------------------------------------------------------------------
#
# Runs compiler with "-dumpversion" and parses major/minor
# version with a regex.
#
function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
exec_program(${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE _boost_COMPILER_VERSION
)
string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
_boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
endfunction()
#
# Take a list of libraries with "thread" in it
# and prepend duplicates with "thread_${Boost_THREADAPI}"
# at the front of the list
#
function(_Boost_PREPEND_LIST_WITH_THREADAPI _output)
set(_orig_libnames ${ARGN})
string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames "${_orig_libnames}")
set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE)
endfunction()
#
# If a library is found, replace its cache entry with its REALPATH
#
function(_Boost_SWAP_WITH_REALPATH _library _docstring)
if(${_library})
get_filename_component(_boost_filepathreal ${${_library}} REALPATH)
unset(${_library} CACHE)
set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}")
endif()
endfunction()
function(_Boost_CHECK_SPELLING _var)
if(${_var})
string(TOUPPER ${_var} _var_UC)
message(FATAL_ERROR "ERROR: ${_var} is not the correct spelling. The proper spelling is ${_var_UC}.")
endif()
endfunction()
# Guesses Boost's compiler prefix used in built library names
# Returns the guess by setting the variable pointed to by _ret
function(_Boost_GUESS_COMPILER_PREFIX _ret)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel"
OR CMAKE_CXX_COMPILER MATCHES "icl"
OR CMAKE_CXX_COMPILER MATCHES "icpc")
if(WIN32)
set (_boost_COMPILER "-iw")
else()
set (_boost_COMPILER "-il")
endif()
elseif (GHSMULTI)
set(_boost_COMPILER "-ghs")
elseif (MSVC14)
set(_boost_COMPILER "-vc140")
elseif (MSVC12)
set(_boost_COMPILER "-vc120")
elseif (MSVC11)
set(_boost_COMPILER "-vc110")
elseif (MSVC10)
set(_boost_COMPILER "-vc100")
elseif (MSVC90)
set(_boost_COMPILER "-vc90")
elseif (MSVC80)
set(_boost_COMPILER "-vc80")
elseif (MSVC71)
set(_boost_COMPILER "-vc71")
elseif (MSVC70) # Good luck!
set(_boost_COMPILER "-vc7") # yes, this is correct
elseif (MSVC60) # Good luck!
set(_boost_COMPILER "-vc6") # yes, this is correct
elseif (BORLAND)
set(_boost_COMPILER "-bcb")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
set(_boost_COMPILER "-sw")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL")
set(_boost_COMPILER "-xlc")
elseif (MINGW)
if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
else()
_Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
endif()
elseif (UNIX)
if (CMAKE_COMPILER_IS_GNUCXX)
if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
else()
_Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
# Determine which version of GCC we have.
if(APPLE)
if(Boost_MINOR_VERSION)
if(${Boost_MINOR_VERSION} GREATER 35)
# In Boost 1.36.0 and newer, the mangled compiler name used
# on Mac OS X/Darwin is "xgcc".
set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
else()
# In Boost <= 1.35.0, there is no mangled compiler name for
# the Mac OS X/Darwin version of GCC.
set(_boost_COMPILER "")
endif()
else()
# We don't know the Boost version, so assume it's
# pre-1.36.0.
set(_boost_COMPILER "")
endif()
else()
set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
endif()
endif()
endif ()
else()
# TODO at least Boost_DEBUG here?
set(_boost_COMPILER "")
endif()
set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
endfunction()
#
# Get component dependencies. Requires the dependencies to have been
# defined for the Boost release version.
#
# component - the component to check
# _ret - list of library dependencies
#
function(_Boost_COMPONENT_DEPENDENCIES component _ret)
# Note: to add a new Boost release, run
#
# % cmake -DBOOST_DIR=/path/to/boost/source -P Utilities/Scripts/BoostScanDeps.cmake
#
# The output may be added in a new block below. If it's the same as
# the previous release, simply update the version range of the block
# for the previous release. Also check if any new components have
# been added, and add any new components to
# _Boost_COMPONENT_HEADERS.
#
# This information was originally generated by running
# BoostScanDeps.cmake against every boost release to date supported
# by FindBoost:
#
# % for version in /path/to/boost/sources/*
# do
# cmake -DBOOST_DIR=$version -P Utilities/Scripts/BoostScanDeps.cmake
# done
#
# The output was then updated by search and replace with these regexes:
#
# - Strip message(STATUS) prefix dashes
# s;^-- ;;
# - Indent
# s;^set(; set(;;
# - Add conditionals
# s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION VERSION_LESS \10\20\3 AND Boost_VERSION VERSION_LESS xxxx);
#
# This results in the logic seen below, but will require the xxxx
# replacing with the following Boost release version (or the next
# minor version to be released, e.g. 1.59 was the latest at the time
# of writing, making 1.60 the next, so 106000 is the needed version
# number). Identical consecutive releases were then merged together
# by updating the end range of the first block and removing the
# following redundant blocks.
#
# Running the script against all historical releases should be
# required only if the BoostScanDeps.cmake script logic is changed.
# The addition of a new release should only require it to be run
# against the new release.
set(_Boost_IMPORTED_TARGETS TRUE)
if(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500)
set(_Boost_IOSTREAMS_DEPENDENCIES regex thread)
set(_Boost_REGEX_DEPENDENCIES thread)
set(_Boost_WAVE_DEPENDENCIES filesystem thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 103500 AND Boost_VERSION VERSION_LESS 103600)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 103600 AND Boost_VERSION VERSION_LESS 103800)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 103800 AND Boost_VERSION VERSION_LESS 104300)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 104300 AND Boost_VERSION VERSION_LESS 104400)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 104400 AND Boost_VERSION VERSION_LESS 104500)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 104500 AND Boost_VERSION VERSION_LESS 104700)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 104700 AND Boost_VERSION VERSION_LESS 104800)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 104800 AND Boost_VERSION VERSION_LESS 105000)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105000 AND Boost_VERSION VERSION_LESS 105300)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105300 AND Boost_VERSION VERSION_LESS 105400)
set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105400 AND Boost_VERSION VERSION_LESS 105500)
set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105500 AND Boost_VERSION VERSION_LESS 105600)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105600 AND Boost_VERSION VERSION_LESS 105900)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 105900 AND Boost_VERSION VERSION_LESS 106000)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
else()
message(WARNING "Imported targets not available for Boost version ${Boost_VERSION}")
set(_Boost_IMPORTED_TARGETS FALSE)
endif()
string(TOUPPER ${component} uppercomponent)
set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE)
string(REGEX REPLACE ";" " " _boost_DEPS_STRING "${_Boost_${uppercomponent}_DEPENDENCIES}")
if (NOT _boost_DEPS_STRING)
set(_boost_DEPS_STRING "(none)")
endif()
# message(STATUS "Dependencies for Boost::${component}: ${_boost_DEPS_STRING}")
endfunction()
#
# Get component headers. This is the primary header (or headers) for
# a given component, and is used to check that the headers are present
# as well as the library itself as an extra sanity check of the build
# environment.
#
# component - the component to check
# _hdrs
#
function(_Boost_COMPONENT_HEADERS component _hdrs)
# Note: new boost components will require adding here. The header
# must be present in all versions of Boost providing a library.
set(_Boost_ATOMIC_HEADERS "boost/atomic.hpp")
set(_Boost_CHRONO_HEADERS "boost/chrono.hpp")
set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp")
set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp")
set(_Boost_COROUTINE_HEADERS "boost/coroutine/all.hpp")
set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp")
set(_Boost_DATE_TIME_HEADERS "boost/date_time/date.hpp")
set(_Boost_FILESYSTEM_HEADERS "boost/filesystem/path.hpp")
set(_Boost_GRAPH_HEADERS "boost/graph/adjacency_list.hpp")
set(_Boost_GRAPH_PARALLEL_HEADERS "boost/graph/adjacency_list.hpp")
set(_Boost_IOSTREAMS_HEADERS "boost/iostreams/stream.hpp")
set(_Boost_LOCALE_HEADERS "boost/locale.hpp")
set(_Boost_LOG_HEADERS "boost/log/core.hpp")
set(_Boost_LOG_SETUP_HEADERS "boost/log/detail/setup_config.hpp")
set(_Boost_MATH_HEADERS "boost/math_fwd.hpp")
set(_Boost_MATH_C99_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_C99F_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_C99L_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_TR1_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_TR1F_HEADERS "boost/math/tr1.hpp")
set(_Boost_MATH_TR1L_HEADERS "boost/math/tr1.hpp")
set(_Boost_MPI_HEADERS "boost/mpi.hpp")
set(_Boost_MPI_PYTHON_HEADERS "boost/mpi/python/config.hpp")
set(_Boost_PRG_EXEC_MONITOR_HEADERS "boost/test/prg_exec_monitor.hpp")
set(_Boost_PROGRAM_OPTIONS_HEADERS "boost/program_options.hpp")
set(_Boost_PYTHON_HEADERS "boost/python.hpp")
set(_Boost_RANDOM_HEADERS "boost/random.hpp")
set(_Boost_REGEX_HEADERS "boost/regex.hpp")
set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp")
set(_Boost_SIGNALS_HEADERS "boost/signals.hpp")
set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp")
set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp")
set(_Boost_THREAD_HEADERS "boost/thread.hpp")
set(_Boost_TIMER_HEADERS "boost/timer.hpp")
set(_Boost_TYPE_ERASURE_HEADERS "boost/type_erasure/config.hpp")
set(_Boost_UNIT_TEST_FRAMEWORK_HEADERS "boost/test/framework.hpp")
set(_Boost_WAVE_HEADERS "boost/wave.hpp")
set(_Boost_WSERIALIZATION_HEADERS "boost/archive/text_wiarchive.hpp")
string(TOUPPER ${component} uppercomponent)
set(${_hdrs} ${_Boost_${uppercomponent}_HEADERS} PARENT_SCOPE)
string(REGEX REPLACE ";" " " _boost_HDRS_STRING "${_Boost_${uppercomponent}_HEADERS}")
if (NOT _boost_HDRS_STRING)
set(_boost_HDRS_STRING "(none)")
endif()
# message(STATUS "Headers for Boost::${component}: ${_boost_HDRS_STRING}")
endfunction()
#
# Determine if any missing dependencies require adding to the component list.
#
# Sets _Boost_${COMPONENT}_DEPENDENCIES for each required component,
# plus _Boost_IMPORTED_TARGETS (TRUE if imported targets should be
# defined; FALSE if dependency information is unavailable).
#
# componentvar - the component list variable name
# extravar - the indirect dependency list variable name
#
#
function(_Boost_MISSING_DEPENDENCIES componentvar extravar)
# _boost_unprocessed_components - list of components requiring processing
# _boost_processed_components - components already processed (or currently being processed)
# _boost_new_components - new components discovered for future processing
#
list(APPEND _boost_unprocessed_components ${${componentvar}})
while(_boost_unprocessed_components)
list(APPEND _boost_processed_components ${_boost_unprocessed_components})
foreach(component ${_boost_unprocessed_components})
string(TOUPPER ${component} uppercomponent)
set(${_ret} ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
_Boost_COMPONENT_DEPENDENCIES("${component}" _Boost_${uppercomponent}_DEPENDENCIES)
set(_Boost_${uppercomponent}_DEPENDENCIES ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE)
foreach(componentdep ${_Boost_${uppercomponent}_DEPENDENCIES})
list(FIND _boost_processed_components "${componentdep}" _boost_component_found)
list(FIND _boost_new_components "${componentdep}" _boost_component_new)
if (_boost_component_found EQUAL -1 AND _boost_component_new EQUAL -1)
list(APPEND _boost_new_components ${componentdep})
endif()
endforeach()
endforeach()
set(_boost_unprocessed_components ${_boost_new_components})
unset(_boost_new_components)
endwhile()
set(_boost_extra_components ${_boost_processed_components})
if(_boost_extra_components AND ${componentvar})
list(REMOVE_ITEM _boost_extra_components ${${componentvar}})
endif()
set(${componentvar} ${_boost_processed_components} PARENT_SCOPE)
set(${extravar} ${_boost_extra_components} PARENT_SCOPE)
endfunction()
#
# End functions/macros
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# main.
#-------------------------------------------------------------------------------
# If the user sets Boost_LIBRARY_DIR, use it as the default for both
# configurations.
if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR)
set(Boost_LIBRARY_DIR_RELEASE "${Boost_LIBRARY_DIR}")
endif()
if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR)
set(Boost_LIBRARY_DIR_DEBUG "${Boost_LIBRARY_DIR}")
endif()
if(NOT DEFINED Boost_USE_MULTITHREADED)
set(Boost_USE_MULTITHREADED TRUE)
endif()
if(NOT DEFINED Boost_USE_DEBUG_RUNTIME)
set(Boost_USE_DEBUG_RUNTIME TRUE)
endif()
# Check the version of Boost against the requested version.
if(Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR)
message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34")
endif()
if(Boost_FIND_VERSION_EXACT)
# The version may appear in a directory with or without the patch
# level, even when the patch level is non-zero.
set(_boost_TEST_VERSIONS
"${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}"
"${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
else()
# The user has not requested an exact version. Among known
# versions, find those that are acceptable to the user request.
#
# Note: When adding a new Boost release, also update the dependency
# information in _Boost_COMPONENT_DEPENDENCIES and
# _Boost_COMPONENT_HEADERS. See the instructions at the top of
# _Boost_COMPONENT_DEPENDENCIES.
set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
"1.63" "1.63.0" "1.61.0" "1.61" "1.60.0" "1.60"
"1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
"1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
"1.50.0" "1.50" "1.49.0" "1.49" "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1"
"1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42"
"1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37"
"1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0"
"1.34" "1.33.1" "1.33.0" "1.33")
set(_boost_TEST_VERSIONS)
if(Boost_FIND_VERSION)
set(_Boost_FIND_VERSION_SHORT "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
# Select acceptable versions.
foreach(version ${_Boost_KNOWN_VERSIONS})
if(NOT "${version}" VERSION_LESS "${Boost_FIND_VERSION}")
# This version is high enough.
list(APPEND _boost_TEST_VERSIONS "${version}")
elseif("${version}.99" VERSION_EQUAL "${_Boost_FIND_VERSION_SHORT}.99")
# This version is a short-form for the requested version with
# the patch level dropped.
list(APPEND _boost_TEST_VERSIONS "${version}")
endif()
endforeach()
else()
# Any version is acceptable.
set(_boost_TEST_VERSIONS "${_Boost_KNOWN_VERSIONS}")
endif()
endif()
# The reason that we failed to find Boost. This will be set to a
# user-friendly message when we fail to find some necessary piece of
# Boost.
set(Boost_ERROR_REASON)
if(Boost_DEBUG)
# Output some of their choices
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
endif()
# Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It
# will only contain any interface definitions on WIN32, but is created
# on all platforms to keep end user code free from platform dependent
# code. Also provide convenience targets to disable autolinking and
# enable dynamic linking.
if(NOT TARGET Boost::diagnostic_definitions)
add_library(Boost::diagnostic_definitions INTERFACE IMPORTED)
add_library(Boost::disable_autolinking INTERFACE IMPORTED)
add_library(Boost::dynamic_linking INTERFACE IMPORTED)
endif()
if(WIN32)
# In windows, automatic linking is performed, so you do not have
# to specify the libraries. If you are linking to a dynamic
# runtime, then you can choose to link to either a static or a
# dynamic Boost library, the default is to do a static link. You
# can alter this for a specific library "whatever" by defining
# BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be
# linked dynamically. Alternatively you can force all Boost
# libraries to dynamic link by defining BOOST_ALL_DYN_LINK.
# This feature can be disabled for Boost library "whatever" by
# defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining
# BOOST_ALL_NO_LIB.
# If you want to observe which libraries are being linked against
# then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking
# code to emit a #pragma message each time a library is selected
# for linking.
set(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
set_target_properties(Boost::diagnostic_definitions PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC")
set_target_properties(Boost::disable_autolinking PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB")
set_target_properties(Boost::dynamic_linking PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK")
endif()
_Boost_CHECK_SPELLING(Boost_ROOT)
_Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
_Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
# Collect environment variable inputs as hints. Do not consider changes.
foreach(v BOOSTROOT BOOST_ROOT BOOST_INCLUDEDIR BOOST_LIBRARYDIR)
set(_env $ENV{${v}})
if(_env)
file(TO_CMAKE_PATH "${_env}" _ENV_${v})
else()
set(_ENV_${v} "")
endif()
endforeach()
if(NOT _ENV_BOOST_ROOT AND _ENV_BOOSTROOT)
set(_ENV_BOOST_ROOT "${_ENV_BOOSTROOT}")
endif()
# Collect inputs and cached results. Detect changes since the last run.
if(NOT BOOST_ROOT AND BOOSTROOT)
set(BOOST_ROOT "${BOOSTROOT}")
endif()
set(_Boost_VARS_DIR
BOOST_ROOT
Boost_NO_SYSTEM_PATHS
)
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Declared as CMake or Environmental Variables:")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" BOOST_ROOT = ${BOOST_ROOT}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
endif()
# ------------------------------------------------------------------------
# Search for Boost include DIR
# ------------------------------------------------------------------------
set(_Boost_VARS_INC BOOST_INCLUDEDIR Boost_INCLUDE_DIR Boost_ADDITIONAL_VERSIONS)
_Boost_CHANGE_DETECT(_Boost_CHANGE_INCDIR ${_Boost_VARS_DIR} ${_Boost_VARS_INC})
# Clear Boost_INCLUDE_DIR if it did not change but other input affecting the
# location did. We will find a new one based on the new inputs.
if(_Boost_CHANGE_INCDIR AND NOT _Boost_INCLUDE_DIR_CHANGED)
unset(Boost_INCLUDE_DIR CACHE)
endif()
if(NOT Boost_INCLUDE_DIR)
set(_boost_INCLUDE_SEARCH_DIRS "")
if(BOOST_INCLUDEDIR)
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR})
elseif(_ENV_BOOST_INCLUDEDIR)
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_INCLUDEDIR})
endif()
if( BOOST_ROOT )
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${BOOST_ROOT})
elseif( _ENV_BOOST_ROOT )
list(APPEND _boost_INCLUDE_SEARCH_DIRS ${_ENV_BOOST_ROOT}/include ${_ENV_BOOST_ROOT})
endif()
if( Boost_NO_SYSTEM_PATHS)
list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
else()
list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS
C:/boost/include
C:/boost
/sw/local/include
)
endif()
# Try to find Boost by stepping backwards through the Boost versions
# we know about.
# Build a list of path suffixes for each version.
set(_boost_PATH_SUFFIXES)
foreach(_boost_VER ${_boost_TEST_VERSIONS})
# Add in a path suffix, based on the required version, ideally
# we could read this from version.hpp, but for that to work we'd
# need to know the include dir already
set(_boost_BOOSTIFIED_VERSION)
# Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(_boost_BOOSTIFIED_VERSION
"${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}")
elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)")
set(_boost_BOOSTIFIED_VERSION
"${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
endif()
list(APPEND _boost_PATH_SUFFIXES
"boost-${_boost_BOOSTIFIED_VERSION}"
"boost_${_boost_BOOSTIFIED_VERSION}"
"boost/boost-${_boost_BOOSTIFIED_VERSION}"
"boost/boost_${_boost_BOOSTIFIED_VERSION}"
)
endforeach()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Include debugging info:")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
" _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
endif()
# Look for a standard boost header file.
find_path(Boost_INCLUDE_DIR
NAMES boost/config.hpp
HINTS ${_boost_INCLUDE_SEARCH_DIRS}
PATH_SUFFIXES ${_boost_PATH_SUFFIXES}
)
endif()
# ------------------------------------------------------------------------
# Extract version information from version.hpp
# ------------------------------------------------------------------------
# Set Boost_FOUND based only on header location and version.
# It will be updated below for component libraries.
if(Boost_INCLUDE_DIR)
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
endif()
# Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
set(Boost_VERSION 0)
set(Boost_LIB_VERSION "")
file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ")
set(_Boost_VERSION_REGEX "([0-9]+)")
set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
foreach(v VERSION LIB_VERSION)
if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}")
set(Boost_${v} "${CMAKE_MATCH_1}")
endif()
endforeach()
unset(_boost_VERSION_HPP_CONTENTS)
math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"version.hpp reveals boost "
"${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
endif()
if(Boost_FIND_VERSION)
# Set Boost_FOUND based on requested version.
set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}")
set(Boost_FOUND 0)
set(_Boost_VERSION_AGE "old")
elseif(Boost_FIND_VERSION_EXACT AND
NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}")
set(Boost_FOUND 0)
set(_Boost_VERSION_AGE "new")
else()
set(Boost_FOUND 1)
endif()
if(NOT Boost_FOUND)
# State that we found a version of Boost that is too new or too old.
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
if (Boost_FIND_VERSION_PATCH)
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}")
endif ()
if (NOT Boost_FIND_VERSION_EXACT)
set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)")
endif ()
set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.")
endif ()
else()
# Caller will accept any Boost version.
set(Boost_FOUND 1)
endif()
else()
set(Boost_FOUND 0)
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.")
endif()
# ------------------------------------------------------------------------
# Prefix initialization
# ------------------------------------------------------------------------
set(Boost_LIB_PREFIX "")
if ( (GHSMULTI AND Boost_USE_STATIC_LIBS) OR
(WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) )
set(Boost_LIB_PREFIX "lib")
endif()
if ( NOT Boost_NAMESPACE )
set(Boost_NAMESPACE "boost")
endif()
# ------------------------------------------------------------------------
# Suffix initialization and compiler suffix detection.
# ------------------------------------------------------------------------
set(_Boost_VARS_NAME
Boost_NAMESPACE
Boost_COMPILER
Boost_THREADAPI
Boost_USE_DEBUG_PYTHON
Boost_USE_MULTITHREADED
Boost_USE_STATIC_LIBS
Boost_USE_STATIC_RUNTIME
Boost_USE_STLPORT
Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
)
_Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME})
# Setting some more suffixes for the library
if (Boost_COMPILER)
set(_boost_COMPILER ${Boost_COMPILER})
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"using user-specified Boost_COMPILER = ${_boost_COMPILER}")
endif()
else()
# Attempt to guess the compiler suffix
# NOTE: this is not perfect yet, if you experience any issues
# please report them and use the Boost_COMPILER variable
# to work around the problems.
_Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER)
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"guessed _boost_COMPILER = ${_boost_COMPILER}")
endif()
endif()
set (_boost_MULTITHREADED "-mt")
if( NOT Boost_USE_MULTITHREADED )
set (_boost_MULTITHREADED "")
endif()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
endif()
#======================
# Systematically build up the Boost ABI tag
# http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
set( _boost_RELEASE_ABI_TAG "-")
set( _boost_DEBUG_ABI_TAG "-")
# Key Use this library when:
# s linking statically to the C++ standard library and
# compiler runtime support libraries.
if(Boost_USE_STATIC_RUNTIME)
set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s")
set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s")
endif()
# g using debug versions of the standard and runtime
# support libraries
if(WIN32 AND Boost_USE_DEBUG_RUNTIME)
if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g")
endif()
endif()
# y using special debug build of python
if(Boost_USE_DEBUG_PYTHON)
set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y")
endif()
# d using a debug version of your code
set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d")
# p using the STLport standard library rather than the
# default one supplied with your compiler
if(Boost_USE_STLPORT)
set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p")
set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p")
endif()
# n using the STLport deprecated "native iostreams" feature
if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n")
set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n")
endif()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
endif()
# ------------------------------------------------------------------------
# Begin finding boost libraries
# ------------------------------------------------------------------------
set(_Boost_VARS_LIB "")
foreach(c DEBUG RELEASE)
set(_Boost_VARS_LIB_${c} BOOST_LIBRARYDIR Boost_LIBRARY_DIR_${c})
list(APPEND _Boost_VARS_LIB ${_Boost_VARS_LIB_${c}})
_Boost_CHANGE_DETECT(_Boost_CHANGE_LIBDIR_${c} ${_Boost_VARS_DIR} ${_Boost_VARS_LIB_${c}} Boost_INCLUDE_DIR)
# Clear Boost_LIBRARY_DIR_${c} if it did not change but other input affecting the
# location did. We will find a new one based on the new inputs.
if(_Boost_CHANGE_LIBDIR_${c} AND NOT _Boost_LIBRARY_DIR_${c}_CHANGED)
unset(Boost_LIBRARY_DIR_${c} CACHE)
endif()
# If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is set, prefer its value.
if(Boost_LIBRARY_DIR_${c})
set(_boost_LIBRARY_SEARCH_DIRS_${c} ${Boost_LIBRARY_DIR_${c}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
else()
set(_boost_LIBRARY_SEARCH_DIRS_${c} "")
if(BOOST_LIBRARYDIR)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_LIBRARYDIR})
elseif(_ENV_BOOST_LIBRARYDIR)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_LIBRARYDIR})
endif()
if(BOOST_ROOT)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${BOOST_ROOT}/lib ${BOOST_ROOT}/stage/lib)
elseif(_ENV_BOOST_ROOT)
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} ${_ENV_BOOST_ROOT}/lib ${_ENV_BOOST_ROOT}/stage/lib)
endif()
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c}
${Boost_INCLUDE_DIR}/lib
${Boost_INCLUDE_DIR}/../lib
${Boost_INCLUDE_DIR}/stage/lib
)
if( Boost_NO_SYSTEM_PATHS )
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
else()
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} PATHS
C:/boost/lib
C:/boost
/sw/local/lib
)
endif()
endif()
endforeach()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_boost_LIBRARY_SEARCH_DIRS_RELEASE = ${_boost_LIBRARY_SEARCH_DIRS_RELEASE}"
"_boost_LIBRARY_SEARCH_DIRS_DEBUG = ${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
endif()
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
if( Boost_USE_STATIC_LIBS )
set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
endif()
endif()
# We want to use the tag inline below without risking double dashes
if(_boost_RELEASE_ABI_TAG)
if(${_boost_RELEASE_ABI_TAG} STREQUAL "-")
set(_boost_RELEASE_ABI_TAG "")
endif()
endif()
if(_boost_DEBUG_ABI_TAG)
if(${_boost_DEBUG_ABI_TAG} STREQUAL "-")
set(_boost_DEBUG_ABI_TAG "")
endif()
endif()
# The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled
# on WIN32 was to:
# 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found)
# 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found)
# We maintain this behavior since changing it could break people's builds.
# To disable the ambiguous behavior, the user need only
# set Boost_USE_STATIC_RUNTIME either ON or OFF.
set(_boost_STATIC_RUNTIME_WORKAROUND false)
if(WIN32 AND Boost_USE_STATIC_LIBS)
if(NOT DEFINED Boost_USE_STATIC_RUNTIME)
set(_boost_STATIC_RUNTIME_WORKAROUND true)
endif()
endif()
# On versions < 1.35, remove the System library from the considered list
# since it wasn't added until 1.35.
if(Boost_VERSION AND Boost_FIND_COMPONENTS)
if(Boost_VERSION LESS 103500)
list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
endif()
endif()
# Additional components may be required via component dependencies.
# Add any missing components to the list.
_Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS _Boost_EXTRA_FIND_COMPONENTS)
# If thread is required, get the thread libs as a dependency
list(FIND Boost_FIND_COMPONENTS thread _Boost_THREAD_DEPENDENCY_LIBS)
if(NOT _Boost_THREAD_DEPENDENCY_LIBS EQUAL -1)
include(CMakeFindDependencyMacro)
find_dependency(Threads)
endif()
# If the user changed any of our control inputs flush previous results.
if(_Boost_CHANGE_LIBDIR OR _Boost_CHANGE_LIBNAME)
foreach(COMPONENT ${_Boost_COMPONENTS_SEARCHED})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
foreach(c DEBUG RELEASE)
set(_var Boost_${UPPERCOMPONENT}_LIBRARY_${c})
unset(${_var} CACHE)
set(${_var} "${_var}-NOTFOUND")
endforeach()
endforeach()
set(_Boost_COMPONENTS_SEARCHED "")
endif()
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)")
# Compute component-specific hints.
set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
${COMPONENT} STREQUAL "graph_parallel")
foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
if(IS_ABSOLUTE "${lib}")
get_filename_component(libdir "${lib}" PATH)
string(REPLACE "\\" "/" libdir "${libdir}")
list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
endif()
endforeach()
endif()
# Consolidate and report component-specific hints.
if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Component-specific library search paths for ${COMPONENT}: "
"${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
endif()
endif()
#
# Find headers
#
_Boost_COMPONENT_HEADERS("${COMPONENT}" Boost_${UPPERCOMPONENT}_HEADER_NAME)
# Look for a standard boost header file.
if(Boost_${UPPERCOMPONENT}_HEADER_NAME)
if(EXISTS "${Boost_INCLUDE_DIR}/${Boost_${UPPERCOMPONENT}_HEADER_NAME}")
set(Boost_${UPPERCOMPONENT}_HEADER ON)
else()
set(Boost_${UPPERCOMPONENT}_HEADER OFF)
endif()
else()
set(Boost_${UPPERCOMPONENT}_HEADER ON)
message(WARNING "No header defined for ${COMPONENT}; skipping header check")
endif()
#
# Find RELEASE libraries
#
set(_boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
if(_boost_STATIC_RUNTIME_WORKAROUND)
set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
list(APPEND _boost_RELEASE_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
endif()
if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
_Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
endif()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
endif()
# if Boost_LIBRARY_DIR_RELEASE is not defined,
# but Boost_LIBRARY_DIR_DEBUG is, look there first for RELEASE libs
if(NOT Boost_LIBRARY_DIR_RELEASE AND Boost_LIBRARY_DIR_DEBUG)
list(INSERT _boost_LIBRARY_SEARCH_DIRS_RELEASE 0 ${Boost_LIBRARY_DIR_DEBUG})
endif()
# Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_RELEASE}")
_Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE
NAMES ${_boost_RELEASE_NAMES}
HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
NAMES_PER_DIR
DOC "${_boost_docstring_release}"
)
#
# Find DEBUG libraries
#
set(_boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
if(_boost_STATIC_RUNTIME_WORKAROUND)
set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
list(APPEND _boost_DEBUG_NAMES
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
endif()
if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
_Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
endif()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
endif()
# if Boost_LIBRARY_DIR_DEBUG is not defined,
# but Boost_LIBRARY_DIR_RELEASE is, look there first for DEBUG libs
if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR_RELEASE)
list(INSERT _boost_LIBRARY_SEARCH_DIRS_DEBUG 0 ${Boost_LIBRARY_DIR_RELEASE})
endif()
# Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
_Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG
NAMES ${_boost_DEBUG_NAMES}
HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
NAMES_PER_DIR
DOC "${_boost_docstring_debug}"
)
if(Boost_REALPATH)
_Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
_Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" )
endif()
_Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT})
endforeach()
# Restore the original find library ordering
if( Boost_USE_STATIC_LIBS )
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
# ------------------------------------------------------------------------
# End finding boost libraries
# ------------------------------------------------------------------------
set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
set(Boost_LIBRARY_DIRS)
if(Boost_LIBRARY_DIR_RELEASE)
list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_RELEASE})
endif()
if(Boost_LIBRARY_DIR_DEBUG)
list(APPEND Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR_DEBUG})
endif()
if(Boost_LIBRARY_DIRS)
list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
endif()
# The above setting of Boost_FOUND was based only on the header files.
# Update it for the requested component libraries.
if(Boost_FOUND)
# The headers were found. Check for requested component libs.
set(_boost_CHECKED_COMPONENT FALSE)
set(_Boost_MISSING_COMPONENTS "")
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} COMPONENT)
set(_boost_CHECKED_COMPONENT TRUE)
if(NOT Boost_${COMPONENT}_FOUND)
string(TOLOWER ${COMPONENT} COMPONENT)
list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
endif()
endforeach()
if(_Boost_MISSING_COMPONENTS AND _Boost_EXTRA_FIND_COMPONENTS)
# Optional indirect dependencies are not counted as missing.
list(REMOVE_ITEM _Boost_MISSING_COMPONENTS ${_Boost_EXTRA_FIND_COMPONENTS})
endif()
if(Boost_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
endif()
if (_Boost_MISSING_COMPONENTS)
set(Boost_FOUND 0)
# We were unable to find some libraries, so generate a sensible
# error message that lists the libraries we were unable to find.
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}\nCould not find the following")
if(Boost_USE_STATIC_LIBS)
set(Boost_ERROR_REASON "${Boost_ERROR_REASON} static")
endif()
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON} Boost libraries:\n")
foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON} ${Boost_NAMESPACE}_${COMPONENT}\n")
endforeach()
list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
else ()
set(Boost_ERROR_REASON
"${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
endif ()
endif ()
if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
# Compatibility Code for backwards compatibility with CMake
# 2.4's FindBoost module.
# Look for the boost library path.
# Note that the user may not have installed any libraries
# so it is quite possible the Boost_LIBRARY_DIRS may not exist.
set(_boost_LIB_DIR ${Boost_INCLUDE_DIR})
if("${_boost_LIB_DIR}" MATCHES "boost-[0-9]+")
get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
endif()
if("${_boost_LIB_DIR}" MATCHES "/include$")
# Strip off the trailing "/include" in the path.
get_filename_component(_boost_LIB_DIR ${_boost_LIB_DIR} PATH)
endif()
if(EXISTS "${_boost_LIB_DIR}/lib")
set(_boost_LIB_DIR ${_boost_LIB_DIR}/lib)
else()
if(EXISTS "${_boost_LIB_DIR}/stage/lib")
set(_boost_LIB_DIR ${_boost_LIB_DIR}/stage/lib)
else()
set(_boost_LIB_DIR "")
endif()
endif()
if(_boost_LIB_DIR AND EXISTS "${_boost_LIB_DIR}")
set(Boost_LIBRARY_DIRS ${_boost_LIB_DIR})
endif()
endif()
else()
# Boost headers were not found so no components were found.
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
set(Boost_${UPPERCOMPONENT}_FOUND 0)
endforeach()
endif()
# ------------------------------------------------------------------------
# Add imported targets
# ------------------------------------------------------------------------
if(Boost_FOUND)
# For header-only libraries
if(NOT TARGET Boost::boost)
add_library(Boost::boost INTERFACE IMPORTED)
if(Boost_INCLUDE_DIRS)
set_target_properties(Boost::boost PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()
endif()
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
if(Boost_${UPPERCOMPONENT}_FOUND)
if(Boost_USE_STATIC_LIBS)
add_library(Boost::${COMPONENT} STATIC IMPORTED)
else()
# Even if Boost_USE_STATIC_LIBS is OFF, we might have static
# libraries as a result.
add_library(Boost::${COMPONENT} UNKNOWN IMPORTED)
endif()
if(Boost_INCLUDE_DIRS)
set_target_properties(Boost::${COMPONENT} PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()
if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY}")
set_target_properties(Boost::${COMPONENT} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${Boost_${UPPERCOMPONENT}_LIBRARY}")
endif()
if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}")
set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Boost::${COMPONENT} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG}")
endif()
if(EXISTS "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}")
set_property(TARGET Boost::${COMPONENT} APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(Boost::${COMPONENT} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
IMPORTED_LOCATION_RELEASE "${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE}")
endif()
if(_Boost_${UPPERCOMPONENT}_DEPENDENCIES)
unset(_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES)
foreach(dep ${_Boost_${UPPERCOMPONENT}_DEPENDENCIES})
list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Boost::${dep})
endforeach()
if(COMPONENT STREQUAL "thread")
list(APPEND _Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES Threads::Threads)
endif()
set_target_properties(Boost::${COMPONENT} PROPERTIES
INTERFACE_LINK_LIBRARIES "${_Boost_${UPPERCOMPONENT}_TARGET_DEPENDENCIES}")
endif()
endif()
endif()
endforeach()
endif()
# ------------------------------------------------------------------------
# Notification to end user about what was found
# ------------------------------------------------------------------------
set(Boost_LIBRARIES "")
if(Boost_FOUND)
if(NOT Boost_FIND_QUIETLY)
message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
if(Boost_FIND_COMPONENTS)
message(STATUS "Found the following Boost libraries:")
endif()
endif()
foreach( COMPONENT ${Boost_FIND_COMPONENTS} )
string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
if( Boost_${UPPERCOMPONENT}_FOUND )
if(NOT Boost_FIND_QUIETLY)
message (STATUS " ${COMPONENT}")
endif()
list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
endif()
endforeach()
else()
if(Boost_FIND_REQUIRED)
message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
else()
if(NOT Boost_FIND_QUIETLY)
# we opt not to automatically output Boost_ERROR_REASON here as
# it could be quite lengthy and somewhat imposing in its requests
# Since Boost is not always a required dependency we'll leave this
# up to the end-user.
if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
else()
message(STATUS "Could NOT find Boost")
endif()
endif()
endif()
endif()
# Configure display of cache entries in GUI.
foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB})
get_property(_type CACHE ${v} PROPERTY TYPE)
if(_type)
set_property(CACHE ${v} PROPERTY ADVANCED 1)
if("x${_type}" STREQUAL "xUNINITIALIZED")
if("x${v}" STREQUAL "xBoost_ADDITIONAL_VERSIONS")
set_property(CACHE ${v} PROPERTY TYPE STRING)
else()
set_property(CACHE ${v} PROPERTY TYPE PATH)
endif()
endif()
endif()
endforeach()
# Record last used values of input variables so we can
# detect on the next run if the user changed them.
foreach(v
${_Boost_VARS_INC} ${_Boost_VARS_LIB}
${_Boost_VARS_DIR} ${_Boost_VARS_NAME}
)
if(DEFINED ${v})
set(_${v}_LAST "${${v}}" CACHE INTERNAL "Last used ${v} value.")
else()
unset(_${v}_LAST CACHE)
endif()
endforeach()
# Maintain a persistent list of components requested anywhere since
# the last flush.
set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}")
list(APPEND _Boost_COMPONENTS_SEARCHED ${Boost_FIND_COMPONENTS})
list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED)
list(SORT _Boost_COMPONENTS_SEARCHED)
set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}"
CACHE INTERNAL "Components requested for this build tree.")
......@@ -3,7 +3,7 @@
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2013 Sociable Agents Group
* Copyright (c) 2009-2022 Sociable Agents Group
* CITEC, Bielefeld University
*
* http://opensource.cit-ec.de/projects/ipaaca/
......
/**
* `b64.h' - b64
*
* copyright (c) 2014 joseph werle
*/
/*
From https://github.com/littlstar/b64.c/blob/master/LICENSE :
The MIT License (MIT)
Copyright (c) 2014 Little Star Media, Inc.
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.
*/
#ifndef B64_H
#define B64_H 1
// RYT start
#include <string>
std::string base64_encode(const std::string& bin);
std::string base64_decode(const std::string& b64);
// RYT end
/**
* Memory allocation functions to use. You can define b64_malloc and
* b64_realloc to custom functions if you want.
*/
#ifndef b64_malloc
# define b64_malloc(ptr) malloc(ptr)
#endif
#ifndef b64_realloc
# define b64_realloc(ptr, size) realloc(ptr, size)
#endif
/**
* Base64 index table.
*/
static const char b64_table[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* Encode `unsigned char *' source with `size_t' size.
* Returns a `char *' base64 encoded string.
*/
char *
b64_encode (const unsigned char *, size_t);
/**
* Dencode `char *' source with `size_t' size.
* Returns a `unsigned char *' base64 decoded string.
*/
unsigned char *
b64_decode (const char *, size_t);
/**
* Dencode `char *' source with `size_t' size.
* Returns a `unsigned char *' base64 decoded string + size of decoded string.
*/
unsigned char *
b64_decode_ex (const char *, size_t, size_t *);
#ifdef __cplusplus
}
#endif
#endif
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2022 Social Cognitive Systems Group
* (formerly the Sociable Agents Group)
* CITEC, Bielefeld University
*
* http://opensource.cit-ec.de/projects/ipaaca/
* http://purl.org/net/ipaaca
*
* This file may be licensed under the terms of of the
* GNU Lesser General Public License Version 3 (the ``LGPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the LGPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the LGPL along with this
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by the
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
* The Excellence Cluster EXC 277 is a grant of the Deutsche
* Forschungsgemeinschaft (DFG) in the context of the German
* Excellence Initiative.
*/
/**
* \file ipaaca-backend.h
*
* \brief Header file for abstract backend participant implementation
* (used in the core library and as a base to derive specific backends).
*
* Users should not include this file directly, but use ipaaca.h
*
* \b Note: This file is only included during compilation of ipaaca,
* for regular use, the full internal API is not exposed.
* Users generally need never touch the internal transport layer.
*
* \author Ramin Yaghoubzadeh Torky (ryaghoubzadeh@uni-bielefeld.de)
* \date January, 2019
*/
#ifndef __ipaaca_backend_mqtt_h_INCLUDED__
#define __ipaaca_backend_mqtt_h_INCLUDED__
#ifndef __ipaaca_h_INCLUDED__
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
}
// Backend-specific include[s]
#include <mosquittopp.h>
namespace ipaaca {
#define _MQTT_REMOTE_SERVER_MAX_QUEUED_REQUESTS 0
namespace backend {
namespace mqtt {
//
// START of backend-specific implementation
//
// here: MQTT
// helper to encapsulate a wait-until-live mechanism
// you can take this for other backends and adopt the friend class name
class ParticipantCore {
friend class MQTTBackEnd;
protected:
IPAACA_MEMBER_VAR_EXPORT std::condition_variable _condvar;
IPAACA_MEMBER_VAR_EXPORT std::mutex _condvar_mutex;
IPAACA_MEMBER_VAR_EXPORT bool _running;
IPAACA_MEMBER_VAR_EXPORT bool _live;
protected:
IPAACA_HEADER_EXPORT ParticipantCore();
IPAACA_HEADER_EXPORT void signal_live();
IPAACA_HEADER_EXPORT bool wait_live(long timeout_milliseconds = 15000);
};
class MQTTParticipant: public ParticipantCore, public mosqpp::mosquittopp {
public:
typedef std::shared_ptr<MQTTParticipant> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _scope;
IPAACA_MEMBER_VAR_EXPORT std::string _client_id;
IPAACA_MEMBER_VAR_EXPORT std::string host;
IPAACA_MEMBER_VAR_EXPORT int port;
IPAACA_MEMBER_VAR_EXPORT int keepalive;
public:
IPAACA_HEADER_EXPORT MQTTParticipant(const MQTTParticipant& orig) = delete; // forbid copy-construction for backend
IPAACA_HEADER_EXPORT inline virtual ~MQTTParticipant() { }
IPAACA_HEADER_EXPORT MQTTParticipant(const std::string& client_id, const std::string& scope, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT void connect_and_background();
IPAACA_HEADER_EXPORT virtual void on_error();
IPAACA_HEADER_EXPORT virtual void on_disconnect(int rc);
IPAACA_HEADER_EXPORT static int get_next_mid();
/* // available mosquittopp callbacks:
virtual void on_connect(int rc) {return;}
virtual void on_disconnect(int rc) {return;}
virtual void on_publish(int mid) {return;}
virtual void on_message(const struct mosquitto_message * message) {return;}
virtual void on_subscribe(int mid, int qos_count, const int * granted_qos) {return;}
virtual void on_unsubscribe(int mid) {return;}
virtual void on_log(int level, const char * str) {return;}
virtual void on_error() {return;}
*/
};
class MQTTInformer: public MQTTParticipant, public Informer {
public:
typedef std::shared_ptr<MQTTInformer> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _client_id;
public:
IPAACA_HEADER_EXPORT MQTTInformer(const std::string& client_id, const std::string& scope, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual void on_connect(int rc);
IPAACA_HEADER_EXPORT virtual bool internal_publish(const std::string& wire);
};
class MQTTListener: public MQTTParticipant, public Listener {
public:
typedef std::shared_ptr<MQTTListener> ptr;
public:
IPAACA_HEADER_EXPORT MQTTListener(const std::string& client_id, const std::string& scope, InputBuffer* buffer_ptr, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual void on_connect(int rc);
IPAACA_HEADER_EXPORT virtual void on_subscribe(int mid, int qos_count, const int * granted_qos);
IPAACA_HEADER_EXPORT virtual void on_message(const struct mosquitto_message * message);
};
class MQTTLocalServer: public MQTTParticipant, public LocalServer {
public:
typedef std::shared_ptr<MQTTLocalServer> ptr;
protected:
IPAACA_HEADER_EXPORT void send_result_for_request(const std::string& request_endpoint, const std::string& request_uid, int64_t result);
public:
IPAACA_HEADER_EXPORT MQTTLocalServer(const std::string& client_id, const std::string& scope, ipaaca::OutputBuffer* buffer_ptr, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual void on_connect(int rc);
IPAACA_HEADER_EXPORT virtual void on_subscribe(int mid, int qos_count, const int * granted_qos);
IPAACA_HEADER_EXPORT virtual void on_message(const struct mosquitto_message * message);
};
class MQTTRemoteServer: public MQTTParticipant, public RemoteServer {
public:
typedef std::shared_ptr<RemoteServer> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, PendingRequest::ptr> _pending_requests;
IPAACA_MEMBER_VAR_EXPORT ipaaca::Lock _pending_requests_lock;
IPAACA_MEMBER_VAR_EXPORT std::string _remote_end_scope; // this is the actual important scope,
// MQTTParticipant::_scope is repurposed here for receiving replies
IPAACA_MEMBER_VAR_EXPORT std::string _name; // using this (unique) auto-generated name
public:
IPAACA_HEADER_EXPORT MQTTRemoteServer(const std::string& client_id, const std::string& scope, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT int64_t request_remote_payload_update(std::shared_ptr<IUPayloadUpdate> update);
IPAACA_HEADER_EXPORT int64_t request_remote_link_update(std::shared_ptr<IULinkUpdate> update);
IPAACA_HEADER_EXPORT int64_t request_remote_commission(std::shared_ptr<protobuf::IUCommission> update);
IPAACA_HEADER_EXPORT int64_t request_remote_resend_request(std::shared_ptr<protobuf::IUResendRequest> update);
IPAACA_HEADER_EXPORT virtual void on_connect(int rc);
IPAACA_HEADER_EXPORT virtual void on_subscribe(int mid, int qos_count, const int * granted_qos);
IPAACA_HEADER_EXPORT virtual void on_message(const struct mosquitto_message * message);
IPAACA_HEADER_EXPORT PendingRequest::ptr queue_pending_request(Event::ptr request);
IPAACA_HEADER_EXPORT int64_t blocking_call(Event::ptr request);
};
class MQTTBackEnd: public BackEnd
{
public:
typedef std::shared_ptr<MQTTBackEnd> ptr;
friend class BackEndLibrary;
protected:
IPAACA_HEADER_EXPORT MQTTBackEnd();
public:
IPAACA_HEADER_EXPORT static BackEnd::ptr get();
IPAACA_HEADER_EXPORT void teardown();
IPAACA_HEADER_EXPORT Informer::ptr createInformer(const std::string& scope);
IPAACA_HEADER_EXPORT Listener::ptr createListener(const std::string& scope, InputBuffer* buf);
IPAACA_HEADER_EXPORT LocalServer::ptr createLocalServer(const std::string& scope, OutputBuffer* buf);
IPAACA_HEADER_EXPORT RemoteServer::ptr createRemoteServer(const std::string& scope);
IPAACA_HEADER_EXPORT inline std::string make_valid_scope(const std::string& scope) override { return scope; }
};
} // of namespace mqtt
} // of namespace backend
#endif // of __ipaaca_backend_mqtt_h_INCLUDED__
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2022 Social Cognitive Systems Group
* (formerly the Sociable Agents Group)
* CITEC, Bielefeld University
*
* http://opensource.cit-ec.de/projects/ipaaca/
* http://purl.org/net/ipaaca
*
* This file may be licensed under the terms of of the
* GNU Lesser General Public License Version 3 (the ``LGPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the LGPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the LGPL along with this
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by the
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
* The Excellence Cluster EXC 277 is a grant of the Deutsche
* Forschungsgemeinschaft (DFG) in the context of the German
* Excellence Initiative.
*/
/**
* \file ipaaca-backend.h
*
* \brief Header file for abstract backend participant implementation
* (used in the core library and as a base to derive specific backends).
*
* Users should not include this file directly, but use ipaaca.h
*
* \b Note: This file is only included during compilation of ipaaca,
* for regular use, the full internal API is not exposed.
* Users generally need never touch the internal transport layer.
*
* \author Ramin Yaghoubzadeh Torky (ryaghoubzadeh@uni-bielefeld.de)
* \date January, 2019
*/
#ifndef __ipaaca_backend_ros_h_INCLUDED__
#define __ipaaca_backend_ros_h_INCLUDED__
#ifndef __ipaaca_h_INCLUDED__
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
}
// Backend-specific include[s]
#include "ros/ros.h"
#include "std_msgs/String.h"
namespace ipaaca {
#define _ROS_REMOTE_SERVER_MAX_QUEUED_REQUESTS 0
namespace backend {
namespace ros {
//
// START of backend-specific implementation
//
// here: ROS
// helper to encapsulate a wait-until-live mechanism
// you can take this for other backends and adopt the friend class name
class ParticipantCore {
friend class ROSBackEnd;
protected:
IPAACA_MEMBER_VAR_EXPORT std::condition_variable _condvar;
IPAACA_MEMBER_VAR_EXPORT std::mutex _condvar_mutex;
IPAACA_MEMBER_VAR_EXPORT bool _running;
IPAACA_MEMBER_VAR_EXPORT bool _live;
protected:
IPAACA_HEADER_EXPORT ParticipantCore();
IPAACA_HEADER_EXPORT void signal_live();
IPAACA_HEADER_EXPORT bool wait_live(long timeout_milliseconds = 15000);
};
class ROSParticipant: public ParticipantCore {
public:
typedef std::shared_ptr<ROSParticipant> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _scope;
IPAACA_MEMBER_VAR_EXPORT std::string host;
IPAACA_MEMBER_VAR_EXPORT int port;
IPAACA_MEMBER_VAR_EXPORT int keepalive;
protected:
// a pointer; odd, but see the ROSBackEnd constructor & destructor
::ros::NodeHandle* _node_handle;
public:
IPAACA_HEADER_EXPORT ROSParticipant(const ROSParticipant& orig) = delete; // forbid copy-construction for backend
IPAACA_HEADER_EXPORT inline virtual ~ROSParticipant() { }
IPAACA_HEADER_EXPORT ROSParticipant(::ros::NodeHandle* node, const std::string& scope, Config::ptr config = nullptr);
};
class ROSInformer: public ROSParticipant, public Informer {
public:
typedef std::shared_ptr<ROSInformer> ptr;
protected:
::ros::Publisher _ros_pub;
public:
IPAACA_HEADER_EXPORT ROSInformer(::ros::NodeHandle* node, const std::string& scope, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual bool internal_publish(const std::string& wire);
};
class ROSListener: public ROSParticipant, public Listener {
public:
typedef std::shared_ptr<ROSListener> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT ::ros::Subscriber _ros_sub;
public:
IPAACA_HEADER_EXPORT ROSListener(::ros::NodeHandle* node, const std::string& scope, InputBuffer* buffer_ptr, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual void on_message(const std_msgs::String::ConstPtr& msg);
};
class ROSLocalServer: public ROSParticipant, public LocalServer {
public:
typedef std::shared_ptr<ROSLocalServer> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT ::ros::Subscriber _ros_sub;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, ::ros::Publisher> _ros_pubs;
protected:
IPAACA_HEADER_EXPORT void send_result_for_request(const std::string& request_endpoint, const std::string& request_uid, int64_t result);
IPAACA_HEADER_EXPORT ::ros::Publisher get_publisher(const std::string& endpoint);
public:
IPAACA_HEADER_EXPORT ROSLocalServer(::ros::NodeHandle* node, const std::string& scope, ipaaca::OutputBuffer* buffer_ptr, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT virtual void on_message(const std_msgs::String::ConstPtr& msg);
};
class ROSRemoteServer: public ROSParticipant, public RemoteServer {
public:
typedef std::shared_ptr<RemoteServer> ptr;
protected:
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, PendingRequest::ptr> _pending_requests;
IPAACA_MEMBER_VAR_EXPORT ipaaca::Lock _pending_requests_lock;
IPAACA_MEMBER_VAR_EXPORT std::string _remote_end_scope; // this is the actual important scope,
// ROSParticipant::_scope is repurposed here for receiving replies
IPAACA_MEMBER_VAR_EXPORT std::string _name; // using this (unique) auto-generated name
IPAACA_MEMBER_VAR_EXPORT ::ros::Subscriber _ros_sub;
IPAACA_MEMBER_VAR_EXPORT ::ros::Publisher _ros_pub;
public:
IPAACA_HEADER_EXPORT ROSRemoteServer(::ros::NodeHandle* node, const std::string& scope, Config::ptr config = nullptr);
IPAACA_HEADER_EXPORT int64_t request_remote_payload_update(std::shared_ptr<IUPayloadUpdate> update);
IPAACA_HEADER_EXPORT int64_t request_remote_link_update(std::shared_ptr<IULinkUpdate> update);
IPAACA_HEADER_EXPORT int64_t request_remote_commission(std::shared_ptr<protobuf::IUCommission> update);
IPAACA_HEADER_EXPORT int64_t request_remote_resend_request(std::shared_ptr<protobuf::IUResendRequest> update);
IPAACA_HEADER_EXPORT PendingRequest::ptr queue_pending_request(Event::ptr request);
IPAACA_HEADER_EXPORT int64_t blocking_call(Event::ptr request);
IPAACA_HEADER_EXPORT virtual void on_message(const std_msgs::String::ConstPtr& msg);
};
class ROSBackEnd: public BackEnd
{
public:
typedef std::shared_ptr<ROSBackEnd> ptr;
friend class BackEndLibrary;
protected:
bool _need_init;
char* _cfakename;
::ros::NodeHandle* _node_handle;
::ros::AsyncSpinner* _spinner;
protected:
IPAACA_HEADER_EXPORT ROSBackEnd();
public:
IPAACA_HEADER_EXPORT static BackEnd::ptr get();
IPAACA_HEADER_EXPORT void teardown();
IPAACA_HEADER_EXPORT void init_once();
IPAACA_HEADER_EXPORT Informer::ptr createInformer(const std::string& scope);
IPAACA_HEADER_EXPORT Listener::ptr createListener(const std::string& scope, InputBuffer* buf);
IPAACA_HEADER_EXPORT LocalServer::ptr createLocalServer(const std::string& scope, OutputBuffer* buf);
IPAACA_HEADER_EXPORT RemoteServer::ptr createRemoteServer(const std::string& scope);
IPAACA_HEADER_EXPORT inline std::string make_valid_scope(const std::string& scope) override {
// strip the leading slash for the ROS node name (removing this
// extra rule would lead to a global (non-movable) namespace
if (scope.length() && (scope[0] == '/')) return scope.substr(1);
else return scope;
}
};
} // of namespace ros
} // of namespace backend
#endif // of __ipaaca_backend_ros_h_INCLUDED__
/*
* This file is part of IPAACA, the
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2022 Social Cognitive Systems Group
* (formerly the Sociable Agents Group)
* CITEC, Bielefeld University
*
* http://opensource.cit-ec.de/projects/ipaaca/
* http://purl.org/net/ipaaca
*
* This file may be licensed under the terms of of the
* GNU Lesser General Public License Version 3 (the ``LGPL''),
* or (at your option) any later version.
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the LGPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the LGPL along with this
* program. If not, go to http://www.gnu.org/licenses/lgpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The development of this software was supported by the
* Excellence Cluster EXC 277 Cognitive Interaction Technology.
* The Excellence Cluster EXC 277 is a grant of the Deutsche
* Forschungsgemeinschaft (DFG) in the context of the German
* Excellence Initiative.
*/
/**
* \file ipaaca-backend.h
*
* \brief Header file for abstract backend participant implementation
* (used in the core library and as a base to derive specific backends).
*
* Users should not include this file directly, but use ipaaca.h
*
* \b Note: This file is only included during compilation of ipaaca,
* for regular use, the full internal API is not exposed.
* Users generally need never touch the internal transport layer.
*
* \author Ramin Yaghoubzadeh Torky (ryaghoubzadeh@uni-bielefeld.de)
* \date December, 2018
*/
#ifndef __ipaaca_backend_h_INCLUDED__
#define __ipaaca_backend_h_INCLUDED__
#ifndef __ipaaca_h_INCLUDED__
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
namespace backend {
#if _WIN32 || _WIN64
inline std::string generate_client_id()
{
// '-' not allowed e.g. in ROS
std::string uuid = ipaaca::generate_uuid_string().substr(0,8);
return uuid;
}
#else
// get simplified basename of the process name from /proc
// (we could also decide to route argv here instead)
inline std::string get_simplified_process_name()
{
std::fstream fs;
fs.open("/proc/self/cmdline", std::fstream::in);
if (!fs.is_open()) {
IPAACA_DEBUG("Could not open /proc/self/cmdline")
return "ipaaca_cpp";
}
std::string line;
std::vector<std::string> tokens;
if (!std::getline(fs, line)) {
IPAACA_DEBUG("Failed to read a line from /proc/self/cmdline")
fs.close();
return "ipaaca_cpp";
}
fs.close();
int cnt = ipaaca::str_split_append(line, tokens, "\000");
if (cnt < 1) {
IPAACA_DEBUG("Failed to get process name from /proc/self/cmdline")
return "ipaaca_cpp";
}
line = tokens[0];
cnt = ipaaca::str_split_wipe(line, tokens, "/");
if (cnt < 1) {
IPAACA_DEBUG("Failed to parse process name in /proc/self/cmdline")
return "ipaaca_cpp";
}
std::string procname;
line = tokens[cnt-1];
for (auto ch: line) {
if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9') || (ch=='_')) {
procname += ch;
} else if (ch=='-' || ch=='.' || ch==' ') {
procname += '_';
}
}
if (procname=="") {
IPAACA_DEBUG("Only unacceptable characters in process name from /proc/self/cmdline")
return "ipaaca_cpp";
} else {
return procname;
}
}
inline std::string generate_client_id()
{
//std::stringstream ss;
//ss << "Process_" << getpid() << "_ClientID_" << ipaaca::generate_uuid_string();
//return ss.str();
std::string uuid = get_simplified_process_name() + "_" + ipaaca::generate_uuid_string().substr(0,8);
return uuid;
}
#endif
/*
* class Scope {
public:
std::string scope_string;
Scope(const std::string& sc): scope_string(sc) {}
Scope(const Scope& scope): scope_string(scope.scope_string) {}
inline operator std::string() const { return scope_string; }
};
*/
// RSB-like wrapper for {wire type; void ref to deserialized obj}
// to avoid modifying the event handling side.
class Event {
public:
typedef std::shared_ptr<Event> ptr;
protected:
std::string _type;
std::shared_ptr<void> _data;
public:
inline Event(const std::string& type, std::shared_ptr<void> data): _type(type), _data(data) { }
inline std::string getType() const { return _type; }
inline std::shared_ptr<void> getData() const { return _data; }
};
class PendingRequest {
/** Encapsulation of a pending remote request with
a facility to keep the requesting thread locked
until the reply or a timeout unlocks it. */
public:
typedef std::shared_ptr<PendingRequest> ptr;
protected:
Event::ptr _pending_request;
std::condition_variable _condvar;
std::mutex _condvar_mutex;
// block var
public:
std::string _request_uid;
int _result;
public:
inline PendingRequest(Event::ptr req) {
std::string uuid = ipaaca::generate_uuid_string();
_request_uid = uuid.substr(0,8);
_pending_request = req;
_result = -1;
}
/// reply_with_result is called by the backend when a remote request reply has been received (and it was a known tracked request)
inline void reply_with_result(int result) {
_result = result;
_condvar.notify_one(); // wake up the waiting thread
};
/// wait_for_reply is called internally by the user thread that attempts to modify remote IUs, it waits until the remote end replies
inline int wait_for_reply(long timeout_milliseconds = 30000) {
std::unique_lock<std::mutex> lock(_condvar_mutex);
// the remote end will set the result >=0 (from the other thread), which suffices to continue
auto success = _condvar.wait_for(lock, std::chrono::milliseconds(timeout_milliseconds), [this]{return this->_result >= 0;});
if (!success) {
IPAACA_ERROR("Request timeout: we did not receive a reply for a remote server request")
// TODO could throw instead
}
return _result;
}
};
//
// Abstract interface
//
class Informer {
public:
typedef std::shared_ptr<Informer> ptr;
protected:
std::string _client_id;
public:
IPAACA_HEADER_EXPORT inline virtual ~Informer() { }
template<typename Data> IPAACA_HEADER_EXPORT inline bool publish(Data d) { return internal_publish(ipaaca::converters::internal_serialize(d)); }
public:
//
// You MUST override these functions in the backend versions:
//
IPAACA_HEADER_EXPORT virtual bool internal_publish(const std::string& wire) { IPAACA_ERROR("Attempt to invoke abstract version of Informer::internal_publish"); throw NotImplementedError(); }
};
/*
IPAACA_HEADER_EXPORT virtual bool publish(ipaaca::IU::ptr) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(ipaaca::Message::ptr) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(ipaaca::IUPayloadUpdate::ptr) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(ipaaca::IULinkUpdate::ptr) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::RemoteRequestResult>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IURetraction>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IUCommission>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IUResendRequest>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IUPayloadUpdateRequest>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IULinkUpdateRequest>) = 0;
IPAACA_HEADER_EXPORT virtual bool publish(std::shared_ptr<protobuf::IUCommissionRequest>
*/
class Listener {
public:
typedef std::shared_ptr<Listener> ptr;
protected:
ipaaca::InputBuffer* _buffer;
protected:
Listener(ipaaca::InputBuffer* buffer): _buffer(buffer) { }
public:
IPAACA_HEADER_EXPORT inline virtual ~Listener() { }
//inline Listener(const Scope& scope, InputBuffer* buffer_ptr, Config::ptr config = nullptr)) {}
void relay_received_event_to_buffer(Event::ptr event);
void relay_received_event_to_buffer_threaded(Event::ptr event);
};
class LocalServer {
public:
typedef std::shared_ptr<LocalServer> ptr;
protected:
ipaaca::OutputBuffer* _buffer;
protected:
LocalServer(ipaaca::OutputBuffer* buffer): _buffer(buffer) { }
public:
//inline LocalServer(const Scope& scope, ipaaca::OutputBuffer* buffer_ptr, Config::ptr config = nullptr): _buffer(buffer_ptr);
IPAACA_HEADER_EXPORT inline virtual ~LocalServer() { }
//IPAACA_HEADER_EXPORT virtual int64_t attempt_to_apply_remote_payload_update(std::shared_ptr<IUPayloadUpdate> update) = 0;
//IPAACA_HEADER_EXPORT virtual int64_t attempt_to_apply_remote_link_update(std::shared_ptr<IULinkUpdate> update) = 0;
//IPAACA_HEADER_EXPORT virtual int64_t attempt_to_apply_remote_commission(std::shared_ptr<protobuf::IUCommission> update) = 0;
//IPAACA_HEADER_EXPORT virtual int64_t attempt_to_apply_remote_resend_request(std::shared_ptr<protobuf::IUResendRequest> update) = 0;
IPAACA_HEADER_EXPORT int64_t attempt_to_apply_remote_payload_update(std::shared_ptr<IUPayloadUpdate> update);
IPAACA_HEADER_EXPORT int64_t attempt_to_apply_remote_link_update(std::shared_ptr<IULinkUpdate> update);
IPAACA_HEADER_EXPORT int64_t attempt_to_apply_remote_commission(std::shared_ptr<protobuf::IUCommission> update);
IPAACA_HEADER_EXPORT int64_t attempt_to_apply_remote_resend_request(std::shared_ptr<protobuf::IUResendRequest> update);
};
class RemoteServer {
public:
typedef std::shared_ptr<RemoteServer> ptr;
public:
//inline RemoteServer(const Scope& scope, Config::ptr config = nullptr) {
//}
IPAACA_HEADER_EXPORT inline virtual ~RemoteServer() { }
IPAACA_HEADER_EXPORT virtual int64_t request_remote_payload_update(std::shared_ptr<IUPayloadUpdate> update) = 0;
IPAACA_HEADER_EXPORT virtual int64_t request_remote_link_update(std::shared_ptr<IULinkUpdate> update) = 0;
IPAACA_HEADER_EXPORT virtual int64_t request_remote_commission(std::shared_ptr<protobuf::IUCommission> update) = 0;
IPAACA_HEADER_EXPORT virtual int64_t request_remote_resend_request(std::shared_ptr<protobuf::IUResendRequest> update) = 0;
};
class BackEnd {
public:
typedef std::shared_ptr<BackEnd> ptr;
protected:
std::string _backend_name;
public:
BackEnd(std::string backend_name): _backend_name(backend_name) { }
inline std::string name() const { return _backend_name; }
virtual ~BackEnd() {}
virtual void teardown() = 0;
virtual LocalServer::ptr createLocalServer(const std::string& scope, OutputBuffer* buf) = 0;
virtual Informer::ptr createInformer(const std::string& scope) = 0;
virtual RemoteServer::ptr createRemoteServer(const std::string& scope) = 0;
virtual Listener::ptr createListener(const std::string& scope, InputBuffer* buf) = 0;
virtual std::string make_valid_scope(const std::string& scope) = 0;
};
class BackEndLibrary {
public:
typedef std::shared_ptr<BackEndLibrary> ptr;
protected:
std::map<std::string, BackEnd::ptr> _backends;
public:
BackEndLibrary() { }
inline static BackEndLibrary::ptr get() {
static BackEndLibrary::ptr lib;
if (!lib) {
lib = std::make_shared<BackEndLibrary>();
}
return lib;
}
inline bool register_backend(BackEnd::ptr backend) {
if (_backends.count(backend->name())) {
IPAACA_ERROR("Not registering another BackEnd with already known name: " << backend->name())
return false;
} else {
_backends[backend->name()] = backend;
return true;
}
}
inline BackEnd::ptr get_default_backend() {
static BackEnd::ptr _singleton;
if (_singleton) return _singleton;
if (_backends.size() == 0) {
IPAACA_ERROR("No backends are registered inside the library - cannot continue")
throw BackEndNotFoundError();
}
std::string preferred_backend = get_global_config()->get_with_default<std::string>("backend", "");
if (preferred_backend != "") {
if (_backends.count(preferred_backend)) {
_singleton = _backends[preferred_backend];
} else {
IPAACA_ERROR("Failed to initialize the selected BackEnd " << preferred_backend)
throw BackEndNotFoundError();
}
} else {
// just return the first value // FIXME config or clean precedence rule
for (auto kv: _backends) {
IPAACA_WARNING("No 'backend' config found, selecting BackEnd " << kv.second->name())
_singleton = kv.second;
break;
}
}
if (_singleton) return _singleton;
throw BackEndNotFoundError(); // should not be reached; silence warnings
}
};
inline BackEnd::ptr get_default_backend() {
return BackEndLibrary::get()->get_default_backend();
}
} // of namespace backend
#endif
......@@ -3,7 +3,7 @@
* "Incremental Processing Architecture
* for Artificial Conversational Agents".
*
* Copyright (c) 2009-2015 Social Cognitive Systems Group
* Copyright (c) 2009-2022 Social Cognitive Systems Group
* (formerly the Sociable Agents Group)
* CITEC, Bielefeld University
*
......@@ -38,13 +38,17 @@
#error "Please do not include this file directly, use ipaaca.h instead"
#endif
// Convenience macro to abstract from the bind implementation being used
// and possible future signature changes.
#define IPAACA_BIND_CLASS_HANDLER(fn, inst) std::bind(fn, inst, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)
/// Store for local IUs (used in OutputBuffer)
class IUStore: public std::map<std::string, boost::shared_ptr<IU> >
class IUStore: public std::map<std::string, std::shared_ptr<IU> >
{
};
/// Store for RemotePushIUs (used in InputBuffer)
class RemotePushIUStore: public std::map<std::string, boost::shared_ptr<RemotePushIU> >
class RemotePushIUStore: public std::map<std::string, std::shared_ptr<RemotePushIU> >
{
};
......@@ -56,8 +60,8 @@ class SmartLinkMap {//{{{
friend std::ostream& operator<<(std::ostream& os, const SmartLinkMap& obj);
friend class IUInterface;
friend class IU;
friend class IUConverter;
friend class MessageConverter;
friend class ipaaca::converters::IUConverter;
//friend class ipaaca::converters::MessageConverter;
public:
IPAACA_HEADER_EXPORT const LinkSet& get_links(const std::string& key);
IPAACA_HEADER_EXPORT const LinkMap& get_all_links();
......@@ -66,6 +70,7 @@ class SmartLinkMap {//{{{
IPAACA_MEMBER_VAR_EXPORT LinkMap _links;
/// The empty link set is returned if undefined links are read for an IU.
IPAACA_MEMBER_VAR_EXPORT static LinkSet empty_link_set;
protected:
IPAACA_HEADER_EXPORT void _add_and_remove_links(const LinkMap& add, const LinkMap& remove);
IPAACA_HEADER_EXPORT void _replace_links(const LinkMap& links);
};//}}}
......@@ -122,9 +127,9 @@ class BufferConfigurationBuilder: private BufferConfiguration//{{{
* evt_type is one of IU_ADDED, IU_UPDATED, IU_RETRACTED, IU_DELETED, IU_LINKSUPDATED, IU_COMMITTED, IU_MESSAGE<br/>
* local indicates that a remote change to a local IU (in an OutputBuffer) was effected
*
*
* See #Buffer::register_handler for examples on how to use your own handlers.
*/
IPAACA_HEADER_EXPORT typedef boost::function<void (boost::shared_ptr<IUInterface>, IUEventType, bool)> IUEventHandlerFunction;
IPAACA_HEADER_EXPORT typedef std::function<void (std::shared_ptr<IUInterface>, IUEventType, bool)> IUEventHandlerFunction;
/** \brief Internal handler type used in Buffer (wraps used-specified IUEventHandlerFunction)
*/
......@@ -142,8 +147,8 @@ class IUEventHandler {//{{{
public:
IPAACA_HEADER_EXPORT IUEventHandler(IUEventHandlerFunction function, IUEventType event_mask, const std::string& category);
IPAACA_HEADER_EXPORT IUEventHandler(IUEventHandlerFunction function, IUEventType event_mask, const std::set<std::string>& categories);
IPAACA_HEADER_EXPORT void call(Buffer* buffer, boost::shared_ptr<IUInterface> iu, bool local, IUEventType event_type, const std::string& category);
typedef boost::shared_ptr<IUEventHandler> ptr;
IPAACA_HEADER_EXPORT void call(Buffer* buffer, std::shared_ptr<IUInterface> iu, bool local, IUEventType event_type, const std::string& category);
typedef std::shared_ptr<IUEventHandler> ptr;
};//}}}
/**
......@@ -151,13 +156,15 @@ class IUEventHandler {//{{{
*
* \b Note: This class is never instantiated directly (use OutputBuffer and InputBuffer, respectively).
*/
class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
class Buffer {
friend class IU;
friend class RemotePushIU;
friend class CallbackIUPayloadUpdate;
/*friend class CallbackIUPayloadUpdate;
friend class CallbackIULinkUpdate;
friend class CallbackIUCommission;
friend class CallbackIUResendRequest;
friend class CallbackIUResendRequest;*/
friend class ipaaca::backend::LocalServer;
friend class ipaaca::backend::Listener;
protected:
IPAACA_MEMBER_VAR_EXPORT std::string _uuid;
IPAACA_MEMBER_VAR_EXPORT std::string _basename;
......@@ -166,7 +173,7 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
IPAACA_MEMBER_VAR_EXPORT std::string _channel;
IPAACA_MEMBER_VAR_EXPORT std::vector<IUEventHandler::ptr> _event_handlers;
protected:
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual void _publish_iu_resend(boost::shared_ptr<IU> iu, const std::string& hidden_scope_name) = 0;
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual void _publish_iu_resend(std::shared_ptr<IU> iu, const std::string& hidden_scope_name) = 0;
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual void _send_iu_link_update(IUInterface* iu, bool is_delta, revision_t revision, const LinkMap& new_links, const LinkMap& links_to_remove, const std::string& writer_name="undef") = 0;
......@@ -177,12 +184,10 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
_allocate_unique_name(basename, function);
_channel = __ipaaca_static_option_default_channel;
}
IPAACA_HEADER_EXPORT void call_iu_event_handlers(boost::shared_ptr<IUInterface> iu, bool local, IUEventType event_type, const std::string& category);
IPAACA_HEADER_EXPORT void call_iu_event_handlers(std::shared_ptr<IUInterface> iu, bool local, IUEventType event_type, const std::string& category);
public:
IPAACA_HEADER_EXPORT virtual inline ~Buffer() { }
IPAACA_HEADER_EXPORT inline const std::string& unique_name() { return _unique_name; }
/// This version of register_handler takes a set of several category interests instead of just one.
IPAACA_HEADER_EXPORT void register_handler(IUEventHandlerFunction function, IUEventType event_mask, const std::set<std::string>& categories);
/** \brief Register a user-specified handler for IU events. Unless specified, it triggers for all event types for all category interests of the buffer.
*
* \param function A function [object] that can be converted to #IUEventHandlerFunction (examples below)
......@@ -202,7 +207,7 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
* }
* </pre>
*
* Adding a class member as a handler (using boost::bind):<br/>
* Adding a class member as a handler (using macro or std::bind):<br/>
* <pre>
* class MyClass {
* protected:
......@@ -211,7 +216,11 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
* public:
* MyClass() {
* inbuf = InputBuffer::create("bufname", "categoryInterest");
* inbuf->register_handler(boost::bind(&MyClass::my_internal_iu_handler, this, _1, _2, _3));
* // Using the macro may protect you against future code adaptations:
* inbuf->register_handler(IPAACA_BIND_CLASS_HANDLER(&MyClass::my_internal_iu_handler, this));
* // it is currently identical to:
* // inbuf->register_handler(std::bind(&MyClass::my_internal_iu_handler, this, \
* std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
* }
* };
* </pre>
......@@ -225,8 +234,10 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
*
*/
IPAACA_HEADER_EXPORT void register_handler(IUEventHandlerFunction function, IUEventType event_mask = IU_ALL_EVENTS, const std::string& category="");
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual boost::shared_ptr<IUInterface> get(const std::string& iu_uid) = 0;
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual std::set<boost::shared_ptr<IUInterface> > get_ius() = 0;
/// This version of register_handler takes a set of several category interests instead of just one.
IPAACA_HEADER_EXPORT void register_handler(IUEventHandlerFunction function, IUEventType event_mask, const std::set<std::string>& categories);
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual std::shared_ptr<IUInterface> get(const std::string& iu_uid) = 0;
IPAACA_HEADER_EXPORT _IPAACA_ABSTRACT_ virtual std::set<std::shared_ptr<IUInterface> > get_ius() = 0;
IPAACA_HEADER_EXPORT inline const std::string& channel() { return _channel; }
};
......@@ -235,36 +246,36 @@ class Buffer { //: public boost::enable_shared_from_this<Buffer> {//{{{
/**
* \brief A buffer to which own IUs can be added to publish them
*
* Use OutputBuffer::create() to obtain a smart pointer to a new output buffer.
* Use #OutputBuffer::create to obtain a smart pointer to a new output buffer.
*
* Use OutputBuffer::add() to add (= publish) an IU.
* Use #OutputBuffer::add to add (= publish) an IU.
*
* Use OutputBuffer::remove() to remove (= retract) an IU.
* Use #OutputBuffer::remove to remove (= retract) an IU.
*
* Use Buffer::register_handler() to register a handler that will respond to remote changes to own published IUs.
* Use #Buffer::register_handler to register a handler that will respond to remote changes to own published IUs.
*/
class OutputBuffer: public Buffer { //, public boost::enable_shared_from_this<OutputBuffer> {//{{{
class OutputBuffer: public Buffer {
friend class IU;
friend class RemotePushIU;
friend class OutputBufferRsbAdaptor;
friend class ipaaca::backend::LocalServer;
protected:
protected:
IPAACA_MEMBER_VAR_EXPORT IUStore _iu_store;
IPAACA_MEMBER_VAR_EXPORT Lock _iu_id_counter_lock;
#ifdef IPAACA_EXPOSE_FULL_RSB_API
protected:
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, rsb::Informer<rsb::AnyType>::Ptr> _informer_store;
IPAACA_MEMBER_VAR_EXPORT rsb::patterns::LocalServerPtr _server;
IPAACA_HEADER_EXPORT rsb::Informer<rsb::AnyType>::Ptr _get_informer(const std::string& category);
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, ipaaca::backend::Informer::ptr> _informer_store;
IPAACA_MEMBER_VAR_EXPORT ipaaca::backend::LocalServer::ptr _server;
IPAACA_HEADER_EXPORT ipaaca::backend::Informer::ptr _get_informer(const std::string& category);
#endif
protected:
IPAACA_HEADER_EXPORT void _send_iu_link_update(IUInterface* iu, bool is_delta, revision_t revision, const LinkMap& new_links, const LinkMap& links_to_remove, const std::string& writer_name="undef") _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT void _publish_iu_resend(boost::shared_ptr<IU> iu, const std::string& hidden_scope_name) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT void _publish_iu_resend(std::shared_ptr<IU> iu, const std::string& hidden_scope_name) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT void _send_iu_payload_update(IUInterface* iu, bool is_delta, revision_t revision, const std::map<std::string, PayloadDocumentEntry::ptr>& new_items, const std::vector<std::string>& keys_to_remove, const std::string& writer_name="undef") _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT void _send_iu_commission(IUInterface* iu, revision_t revision, const std::string& writer_name) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT void _publish_iu(boost::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT void _publish_iu(std::shared_ptr<IU> iu);
/// mark and send IU retraction on own IU (removal from buffer is in remove(IU))
IPAACA_HEADER_EXPORT void _retract_iu(boost::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT void _retract_iu(std::shared_ptr<IU> iu);
/// mark and send retraction for all unretracted IUs (without removal, used in ~OutputBuffer)
IPAACA_HEADER_EXPORT void _retract_all_internal();
protected:
......@@ -272,15 +283,15 @@ class OutputBuffer: public Buffer { //, public boost::enable_shared_from_this<Ou
IPAACA_HEADER_EXPORT OutputBuffer(const std::string& basename, const std::string& channel=""); // empty string auto-replaced with __ipaaca_static_option_default_channel
IPAACA_HEADER_EXPORT void _initialize_server();
public:
IPAACA_HEADER_EXPORT static boost::shared_ptr<OutputBuffer> create(const std::string& basename);
IPAACA_HEADER_EXPORT static std::shared_ptr<OutputBuffer> create(const std::string& basename);
/// OutputBuffer destructor will retract all IUs that are still live
IPAACA_HEADER_EXPORT ~OutputBuffer();
IPAACA_HEADER_EXPORT void add(boost::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT boost::shared_ptr<IU> remove(const std::string& iu_uid);
IPAACA_HEADER_EXPORT boost::shared_ptr<IU> remove(boost::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT boost::shared_ptr<IUInterface> get(const std::string& iu_uid) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT std::set<boost::shared_ptr<IUInterface> > get_ius() _IPAACA_OVERRIDE_;
typedef boost::shared_ptr<OutputBuffer> ptr;
IPAACA_HEADER_EXPORT void add(std::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT std::shared_ptr<IU> remove(const std::string& iu_uid);
IPAACA_HEADER_EXPORT std::shared_ptr<IU> remove(std::shared_ptr<IU> iu);
IPAACA_HEADER_EXPORT std::shared_ptr<IUInterface> get(const std::string& iu_uid) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT std::set<std::shared_ptr<IUInterface> > get_ius() _IPAACA_OVERRIDE_;
typedef std::shared_ptr<OutputBuffer> ptr;
};
//}}}
......@@ -293,26 +304,26 @@ class OutputBuffer: public Buffer { //, public boost::enable_shared_from_this<Ou
*
* Use Buffer::register_handler() to register a handler that will respond to relevant remote IUs.
*/
class InputBuffer: public Buffer { //, public boost::enable_shared_from_this<InputBuffer> {//{{{
class InputBuffer: public Buffer {
friend class IU;
friend class RemotePushIU;
friend class InputBufferRsbAdaptor;
friend class ipaaca::backend::Listener;
#ifdef IPAACA_EXPOSE_FULL_RSB_API
protected:
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, rsb::ListenerPtr> _listener_store;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, rsb::patterns::RemoteServerPtr> _remote_server_store;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, ipaaca::backend::Listener::ptr> _listener_store;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, ipaaca::backend::RemoteServer::ptr> _remote_server_store;
IPAACA_MEMBER_VAR_EXPORT RemotePushIUStore _iu_store;
IPAACA_HEADER_EXPORT rsb::patterns::RemoteServerPtr _get_remote_server(const std::string& unique_server_name);
IPAACA_HEADER_EXPORT rsb::ListenerPtr _create_category_listener_if_needed(const std::string& category);
IPAACA_HEADER_EXPORT void _handle_iu_events(rsb::EventPtr event);
IPAACA_HEADER_EXPORT void _trigger_resend_request(rsb::EventPtr event);
IPAACA_HEADER_EXPORT ipaaca::backend::RemoteServer::ptr _get_remote_server(const std::string& unique_server_name);
IPAACA_HEADER_EXPORT ipaaca::backend::Listener::ptr _create_category_listener_if_needed(const std::string& category);
IPAACA_HEADER_EXPORT void _handle_iu_events(ipaaca::backend::Event::ptr event);
IPAACA_HEADER_EXPORT void _trigger_resend_request(ipaaca::backend::Event::ptr event);
#endif
protected:
IPAACA_HEADER_EXPORT inline void _send_iu_link_update(IUInterface* iu, bool is_delta, revision_t revision, const LinkMap& new_links, const LinkMap& links_to_remove, const std::string& writer_name="undef") _IPAACA_OVERRIDE_
{
IPAACA_WARNING("(ERROR) InputBuffer::_send_iu_link_update() should never be invoked")
}
IPAACA_HEADER_EXPORT inline void _publish_iu_resend(boost::shared_ptr<IU> iu, const std::string& hidden_scope_name) _IPAACA_OVERRIDE_
IPAACA_HEADER_EXPORT inline void _publish_iu_resend(std::shared_ptr<IU> iu, const std::string& hidden_scope_name) _IPAACA_OVERRIDE_
{
IPAACA_WARNING("(ERROR) InputBuffer::_publish_iu_resend() should never be invoked")
}
......@@ -345,28 +356,28 @@ class InputBuffer: public Buffer { //, public boost::enable_shared_from_this<Inp
IPAACA_HEADER_EXPORT void set_resend(bool resendActive);
IPAACA_HEADER_EXPORT bool get_resend();
/// Create InputBuffer according to configuration in BufferConfiguration object
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const BufferConfiguration& bufferconfiguration);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const BufferConfiguration& bufferconfiguration);
/// Create InputBuffer from name and set of category interests
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::set<std::string>& category_interests);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::set<std::string>& category_interests);
/// Create InputBuffer from name and vector of category interests
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::vector<std::string>& category_interests);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::vector<std::string>& category_interests);
/// Convenience function: create InputBuffer from name and one category interest
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1);
/// Convenience function: create InputBuffer from name and two category interests [DEPRECATED]
[[deprecated("Use create(string, set<string>) instead")]]
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2);
/// Convenience function: create InputBuffer from name and three category interests [DEPRECATED]
[[deprecated("Use create(string, set<string>) instead")]]
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3);
/// Convenience function: create InputBuffer from name and four category interests [DEPRECATED]
[[deprecated("Use create(string, set<string>) instead")]]
IPAACA_HEADER_EXPORT static boost::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3, const std::string& category_interest4);
IPAACA_HEADER_EXPORT static std::shared_ptr<InputBuffer> create(const std::string& basename, const std::string& category_interest1, const std::string& category_interest2, const std::string& category_interest3, const std::string& category_interest4);
IPAACA_HEADER_EXPORT ~InputBuffer() {
IPAACA_IMPLEMENT_ME
}
IPAACA_HEADER_EXPORT boost::shared_ptr<IUInterface> get(const std::string& iu_uid) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT std::set<boost::shared_ptr<IUInterface> > get_ius() _IPAACA_OVERRIDE_;
typedef boost::shared_ptr<InputBuffer> ptr;
IPAACA_HEADER_EXPORT std::shared_ptr<IUInterface> get(const std::string& iu_uid) _IPAACA_OVERRIDE_;
IPAACA_HEADER_EXPORT std::set<std::shared_ptr<IUInterface> > get_ius() _IPAACA_OVERRIDE_;
typedef std::shared_ptr<InputBuffer> ptr;
};
//}}}
......@@ -380,8 +391,10 @@ class IUPayloadUpdate {//{{{
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, PayloadDocumentEntry::ptr> new_items;
IPAACA_MEMBER_VAR_EXPORT std::vector<std::string> keys_to_remove;
IPAACA_MEMBER_VAR_EXPORT std::string payload_type; // to handle legacy mode
IPAACA_MEMBER_VAR_EXPORT std::string request_uid; // for lightweight back-ends
IPAACA_MEMBER_VAR_EXPORT std::string request_endpoint; // for lightweight back-ends
friend std::ostream& operator<<(std::ostream& os, const IUPayloadUpdate& obj);
typedef boost::shared_ptr<IUPayloadUpdate> ptr;
typedef std::shared_ptr<IUPayloadUpdate> ptr;
};//}}}
/// Internal, transport-independent, representation of link updates
......@@ -393,8 +406,10 @@ class IULinkUpdate {//{{{
IPAACA_MEMBER_VAR_EXPORT bool is_delta;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, std::set<std::string> > new_links;
IPAACA_MEMBER_VAR_EXPORT std::map<std::string, std::set<std::string> > links_to_remove;
IPAACA_MEMBER_VAR_EXPORT std::string request_uid; // for lightweight back-ends
IPAACA_MEMBER_VAR_EXPORT std::string request_endpoint; // for lightweight back-ends
friend std::ostream& operator<<(std::ostream& os, const IULinkUpdate& obj);
typedef boost::shared_ptr<IULinkUpdate> ptr;
typedef std::shared_ptr<IULinkUpdate> ptr;
};//}}}
......