Skip to content

Commit

Permalink
fixed apple incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
EmielBruijntjes committed Aug 14, 2014
2 parents 271cc39 + d2a84b5 commit 3e47191
Show file tree
Hide file tree
Showing 11 changed files with 348 additions and 7 deletions.
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 2.8)

project(amqp-cpp)

# ensure c++11 on all compilers
include(set_cxx_norm.cmake)
set_cxx_norm (${CXX_NORM_CXX11})

macro (add_sources)
file (RELATIVE_PATH _relPath "${PROJECT_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)
add_subdirectory(amqp_boost_test)

include_directories(${CMAKE_SOURCE_DIR}/include)
add_library(amqp-cpp STATIC ${SRCS})
target_include_directories(amqp-cpp SYSTEM PUBLIC ${PROJECT_SOURCE_DIR})

set(AMQP-CPP_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(AMQP-CPP_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
37 changes: 37 additions & 0 deletions amqp_boost_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.55 REQUIRED COMPONENTS thread system)

if(NOT Boost_FOUND)
message( FATAL_ERROR "boost must be installed")
endif()

include_directories(${Boost_INCLUDE_DIRS})

set(SRC main.cpp)

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
set(SPECIFIC_HOST_LIBS rt pthread)
else()
set(SPECIFIC_HOST_LIBS)
endif()

set(LIBS
${Boost_LIBRARIES}
amqp-cpp
)

include_directories(SYSTEM ${CRYPTLIB_INCLUDE_PATH})
link_directories(${Boost_LIBRARY_PATH})

include_directories(SYSTEM ${AMQP-CPP_INCLUDE_PATH})

add_executable(amqp_boost_test ${SRC})
target_link_libraries(amqp_boost_test ${LIBS} ${SPECIFIC_HOST_LIBS})

install(TARGETS amqp_boost_test
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
8 changes: 8 additions & 0 deletions amqp_boost_test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <amqpcpp.h>

int main(int argc, const char* argv[])
{


return 0;
}
4 changes: 3 additions & 1 deletion amqpcpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
// base C include files
#include <stdint.h>
#include <math.h>
#include <endian.h>

// include compatibilities for apple
#include <amqpcpp/apple.h>

// forward declarations
#include <amqpcpp/classes.h>
Expand Down
37 changes: 37 additions & 0 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
add_sources(
array.h
booleanset.h
buffer.h
bytebuffer.h
callbacks.h
channel.h
channelimpl.h
classes.h
compat_endian.h
connection.h
connectionhandler.h
connectionimpl.h
decimalfield.h
deferred.h
deferredcancel.h
deferredconsumer.h
deferreddelete.h
deferredget.h
deferredqueue.h
entityimpl.h
envelope.h
exchangetype.h
field.h
fieldproxy.h
flags.h
login.h
message.h
metadata.h
monitor.h
numericfield.h
outbuffer.h
receivedframe.h
stringfield.h
table.h
watchable.h
)
31 changes: 31 additions & 0 deletions include/apple.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef __AMQP_CPP_COMPAT_ENDIAN_H__
#define __AMQP_CPP_COMPAT_ENDIAN_H__

#if defined(__APPLE__)

#include <machine/endian.h>

#include <libkern/OSByteOrder.h>

#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 <endian.h>

#endif

#endif
1 change: 0 additions & 1 deletion include/bytebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class ByteBuffer : public Buffer
{
return memcpy(buffer, _data + pos, size);
}

};

/**
Expand Down
2 changes: 1 addition & 1 deletion include/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Connection
{
return _implementation.parse(buffer);
}

/**
* Close the connection
* This will close all channels
Expand Down
55 changes: 55 additions & 0 deletions set_cxx_norm.cmake
Original file line number Diff line number Diff line change
@@ -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++11")
endif()

endif()

endmacro()

92 changes: 92 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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
deferredcancel.cpp
deferredconsumer.cpp
deferredget.cpp
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
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
)
Loading

0 comments on commit 3e47191

Please sign in to comment.