diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..92a9595 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 2.8) + +# ensure c++11 on all compilers +include(set_cxx_norm.cmake) +set_cxx_norm (${CXX_NORM_CXX11}) + +macro (add_sources) + file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + foreach (_src ${ARGN}) + if (_relPath) + list (APPEND SRCS "${_relPath}/${_src}") + else() + list (APPEND SRCS "${_src}") + endif() + endforeach() + if (_relPath) + # propagate SRCS to parent directory + set (SRCS ${SRCS} PARENT_SCOPE) + endif() +endmacro() + +add_subdirectory(src) +add_subdirectory(include) + +include_directories(${CMAKE_SOURCE_DIR}/include) +add_library(amqp-cpp STATIC ${SRCS}) +target_include_directories(amqp-cpp SYSTEM PUBLIC ${CMAKE_SOURCE_DIR}) + diff --git a/amqpcpp.h b/amqpcpp.h index 0708362..0ca4c9d 100644 --- a/amqpcpp.h +++ b/amqpcpp.h @@ -20,7 +20,7 @@ // base C include files #include #include -#include +#include // forward declarations #include diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..a5aaa3b --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,28 @@ +add_sources( +array.h +booleanset.h +channel.h +channelhandler.h +channelimpl.h +classes.h +compat_endian.h +connection.h +connectionhandler.h +connectionimpl.h +decimalfield.h +entityimpl.h +envelope.h +exchangetype.h +field.h +fieldproxy.h +flags.h +login.h +message.h +metadata.h +numericfield.h +outbuffer.h +receivedframe.h +stringfield.h +table.h +watchable.h +) diff --git a/include/compat_endian.h b/include/compat_endian.h new file mode 100644 index 0000000..97c60fc --- /dev/null +++ b/include/compat_endian.h @@ -0,0 +1,31 @@ +#ifndef __AMQP_CPP_COMPAT_ENDIAN_H__ +#define __AMQP_CPP_COMPAT_ENDIAN_H__ + +#if defined(__APPLE__) + +#include + +#include + +#define htobe16(x) OSSwapHostToBigInt16(x) +#define htole16(x) OSSwapHostToLittleInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#define le16toh(x) OSSwapLittleToHostInt16(x) + +#define htobe32(x) OSSwapHostToBigInt32(x) +#define htole32(x) OSSwapHostToLittleInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#define le32toh(x) OSSwapLittleToHostInt32(x) + +#define htobe64(x) OSSwapHostToBigInt64(x) +#define htole64(x) OSSwapHostToLittleInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) + +#else + +#include + +#endif + +#endif diff --git a/set_cxx_norm.cmake b/set_cxx_norm.cmake new file mode 100644 index 0000000..1d73651 --- /dev/null +++ b/set_cxx_norm.cmake @@ -0,0 +1,55 @@ +# Version +cmake_minimum_required(VERSION 2.6.3) + +set(CXX_NORM_CXX98 1) # C++98 +set(CXX_NORM_CXX03 2) # C++03 +set(CXX_NORM_CXX11 3) # C++11 + +# - Set the wanted C++ norm +# Adds the good argument to the command line in function of the compiler +# Currently only works with g++ and clang++ +macro(set_cxx_norm NORM) + + # Extract c++ compiler --version output + exec_program( + ${CMAKE_CXX_COMPILER} + ARGS --version + OUTPUT_VARIABLE _compiler_output + ) + # Keep only the first line + string(REGEX REPLACE + "(\n.*$)" + "" + cxx_compiler_version "${_compiler_output}" + ) + # Extract the version number + string(REGEX REPLACE + "([^0-9.])|([0-9.][^0-9.])" + "" + cxx_compiler_version "${cxx_compiler_version}" + ) + + if(CMAKE_COMPILER_IS_GNUCXX) + + if(${NORM} EQUAL ${CXX_NORM_CXX98}) + add_definitions("-std=c++98") + elseif(${NORM} EQUAL ${CXX_NORM_CXX03}) + add_definitions("-std=c++03") + elseif(${NORM} EQUAL ${CXX_NORM_CXX11}) + if(${cxx_compiler_version} VERSION_LESS "4.7.0") + add_definitions("-std=c++0x") + else() + add_definitions("-std=c++11") + endif() + endif() + + elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + + if(${NORM} EQUAL ${CXX_NORM_CXX11}) + add_definitions("-std=c++0x") + endif() + + endif() + +endmacro() + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..ca51b25 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,90 @@ +add_sources( +array.cpp +basicackframe.h +basiccancelframe.h +basiccancelokframe.h +basicconsumeframe.h +basicconsumeokframe.h +basicdeliverframe.h +basicframe.h +basicgetemptyframe.h +basicgetframe.h +basicgetokframe.h +basicheaderframe.h +basicnackframe.h +basicpublishframe.h +basicqosframe.h +basicqosokframe.h +basicrecoverasyncframe.h +basicrecoverframe.h +basicrecoverokframe.h +basicrejectframe.h +basicreturnframe.h +bodyframe.h +channelcloseframe.h +channelcloseokframe.h +channelflowframe.h +channelflowokframe.h +channelframe.h +channelimpl.cpp +channelopenframe.h +channelopenokframe.h +connectioncloseframe.h +connectioncloseokframe.h +connectionframe.h +connectionimpl.cpp +connectionopenframe.h +connectionopenokframe.h +connectionsecureframe.h +connectionsecureokframe.h +connectionstartframe.h +connectionstartokframe.h +connectiontuneframe.h +connectiontuneokframe.h +consumedmessage.h +exception.h +exchangebindframe.h +exchangebindokframe.h +exchangedeclareframe.h +exchangedeclareokframe.h +exchangedeleteframe.h +exchangedeleteokframe.h +exchangeframe.h +exchangeunbindframe.h +exchangeunbindokframe.h +extframe.h +field.cpp +flags.cpp +frame.h +framecheck.h +headerframe.h +heartbeatframe.h +includes.h +messageimpl.h +methodframe.h +monitor.h +protocolexception.h +protocolheaderframe.h +queuebindframe.h +queuebindokframe.h +queuedeclareframe.h +queuedeclareokframe.h +queuedeleteframe.h +queuedeleteokframe.h +queueframe.h +queuepurgeframe.h +queuepurgeokframe.h +queueunbindframe.h +queueunbindokframe.h +receivedframe.cpp +returnedmessage.h +table.cpp +transactioncommitframe.h +transactioncommitokframe.h +transactionframe.h +transactionrollbackframe.h +transactionrollbackokframe.h +transactionselectframe.h +transactionselectokframe.h +watchable.cpp +)