Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Oct 27, 2014
2 parents 33751f9 + 12df801 commit 446f407
Show file tree
Hide file tree
Showing 164 changed files with 5,803 additions and 2,064 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Expand Up @@ -11,6 +11,7 @@ cmake_install.cmake
*.opensdf
*.ipch
*.dir
*.lib
Win32
Debug
Release
Expand All @@ -30,4 +31,9 @@ autowiring-*-*.dmg
autowiring-*-*.deb
autowiring-*-*.rpm
autowiring-*-*.msi
autowiring.xcodeproj
autowiring.xcodeproj
autowiring/AutowiringConfig.h
*.nupkg
lib/*.*
autowiring-*-*.zip
_CPack_Packages
67 changes: 48 additions & 19 deletions .travis.yml
@@ -1,39 +1,68 @@
language: cpp
compiler: g++
os: linux

before_install:
# Enforce whitespace guidelines
- ./scripts/whitespace_check.sh

# Enforce Leap Motion copyright notice
- ./scripts/copyright_check.sh

# g++4.8.1
- if [ "$CXX" == "g++" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
- if [ "$CXX" == "g++" ]; then export CXX; fi
- if [ "$CXX" == "g++" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
&& export CXX;
fi

# clang 3.4
- if [ "$CXX" == "clang++" ]; then sudo add-apt-repository -y ppa:h-rayflood/llvm; fi
- if [ "$CXX" == "clang++" ]; then
sudo add-apt-repository -y ppa:h-rayflood/llvm;
fi

- sudo apt-get remove gcc-4.6 g++-4.6
- sudo apt-get update -qq
- sudo apt-get remove gcc-4.6 g++-4.6 cmake
- sudo apt-get -qq update

install:
# CMake 3.0
- sudo apt-get -qq install libc6-i386
&& wget http://www.cmake.org/files/v3.0/cmake-3.0.2-Linux-i386.tar.gz
&& tar -xzf cmake-3.0.2-Linux-i386.tar.gz
&& sudo cp -fR cmake-3.0.2-Linux-i386/* /usr

# g++4.8.1
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq gcc-4.8 g++-4.8; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
- sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
- sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++

- if [ "$CXX" = "g++" ]; then
sudo apt-get install -qq gcc-4.8 g++-4.8
&& export CXX="g++-4.8"
&& sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
&& sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++;
fi

# clang 3.4
- if [ "$CXX" == "clang++" ]; then sudo apt-get install --allow-unauthenticated -qq clang-3.4; fi
- if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.4"; fi

- if [ "$CXX" == "clang++" ]; then
sudo apt-get install --allow-unauthenticated -qq clang-3.4
&& export CXX="clang++-3.4";
fi

before_script:
- cmake .
script:
- export CPATH=/usr/include/c++/4.8:/usr/include/x86_64-linux-gnu/c++/4.8/:$CPATH
- export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8:$LD_LIBRARY_PATH
- cmake . -DCMAKE_BUILD_TYPE=Release

script:
# Build Autowriring, run unit tests, and install
- make -j 8 || make
- make test
- ctest --output-on-failure
- sudo make install

# Package
- sudo cpack || (cat _CPack_Packages/Linux/TGZ/InstallOutput.log; exit 1)

# Build examples from installed Autowiring
- cd examples
&& cmake .
&& make
&& cd ..

after_failure:
- cat Testing/Temporary/LastTest.log 2> /dev/null
os:
- linux
- osx
192 changes: 192 additions & 0 deletions Autowiring.nuspec

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions AutowiringConfig.h.in
@@ -0,0 +1,17 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once

//
// Define preprocessor macros from CMake variables
//

// Are we building autonet?
#cmakedefine01 AUTOWIRING_BUILD_AUTONET

// Are we linking with C++11 STL?
#cmakedefine01 USE_LIBCXX
#if USE_LIBCXX
#define AUTOWIRING_USE_LIBCXX 1
#else
#define AUTOWIRING_USE_LIBCXX 0
#endif
131 changes: 90 additions & 41 deletions CMakeLists.txt
@@ -1,13 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(autowiring)
cmake_minimum_required(VERSION 3.0)
include(version.cmake)
project(autowiring VERSION ${autowiring_VERSION})
include(CTest)

# TODO: Use the VERSION attribute for the "project" setting instead after upgrading
# the cmake_minimum_required to version 3.0
set(autowiring_VERSION_MAJOR 0)
set(autowiring_VERSION_MINOR 1)
set(autowiring_VERSION_PATCH 0)

# Determine whether Autowiring has been embedded in another project
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(AUTOWIRING_IS_EMBEDDED)
Expand All @@ -31,25 +26,22 @@ else()
endif()
endif()

# Macro for deprecated functionality needed to comply with c++98 std implementations
if(NOT USE_LIBCXX)
add_definitions(-DAUTOWIRING_UNSAFE_HASHTABLE)
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
endif()

if(USE_LIBCXX)
# Clang needs special additional flags to build with C++11
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
message("AppleClang C++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("Clang C++11")
if (APPLE)
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
else()
set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("GCC C++11")
set(CMAKE_CXX_FLAGS "-std=c++11")
endif()
endif()

Expand All @@ -64,17 +56,34 @@ set(AUTOWIRING_BUILD_AUTONET_DEFAULT ON)
get_filename_component(AUTOWIRING_ROOT_DIR . ABSOLUTE)
if(AUTOWIRING_IS_EMBEDDED)
set(AUTOWIRING_BUILD_TESTS_DEFAULT OFF)
set(AUTOWIRING_BUILD_EXAMPLES_DEFAULT OFF)
else()
set(AUTOWIRING_BUILD_TESTS_DEFAULT ON)
set(AUTOWIRING_BUILD_EXAMPLES_DEFAULT ON)

# All of our binaries go to one place: The binaries output directory. We only want to tinker
# with this if we're building by ourselves, otherwise we just do whatever the enclosing project
# wants us to do.
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Libraries not only all wind up in the libraries directory, but we also keep them all together
# here by putting them in the same place, regardless of whether they are debug or release. This
# makes globbing them together much easier.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
endif()

# 64-bit installations should suffix with 64
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
set(CMAKE_DEBUG_POSTFIX "64")
set(CMAKE_RELEASE_POSTFIX "64")
endif()

# Postfix on all debug libraries should be "d"
set(CMAKE_DEBUG_POSTFIX d${CMAKE_DEBUG_POSTFIX})

option(AUTOWIRING_BUILD_TESTS "Build Autowiring unit tests" ${AUTOWIRING_BUILD_TESTS_DEFAULT})
function(add_googletest dirname)
if(AUTOWIRING_BUILD_TESTS)
Expand Down Expand Up @@ -107,45 +116,85 @@ include_directories(
contrib
contrib/websocketpp
)
add_subdirectory(src)
add_subdirectory(contrib)

# Build examples
option(AUTOWIRING_BUILD_EXAMPLES "Build Autowiring examples" ${AUTOWIRING_BUILD_EXAMPLES_DEFAULT})
if(AUTOWIRING_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# CMake configurations
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
set(autowiring_ARCHITECTURE "64")
else()
set(autowiring_ARCHITECTURE "32")
endif()
configure_file(autowiring-config.cmake.in autowiring-config.cmake @ONLY)
configure_file(autowiring-configVersion.cmake.in autowiring-configVersion.cmake @ONLY)
configure_file(AutowiringConfig.h.in ${PROJECT_SOURCE_DIR}/autowiring/AutowiringConfig.h @ONLY)

# Recurse through source directories
add_subdirectory(src)

# Export library
export(EXPORT AutowiringTargets FILE AutowiringTargets.cmake NAMESPACE Autowiring::)

# Only attempt to do anything with cpack if we're being built stand-alone
if(NOT AUTOWIRING_IS_EMBEDDED)
# Install autowiring-config.cmake and autowiring-configVersion.cmake
install (FILES
"${CMAKE_BINARY_DIR}/contrib/autowiring/autowiring-config.cmake"
"${CMAKE_BINARY_DIR}/contrib/autowiring/autowiring-configVersion.cmake"
DESTINATION "${CMAKE_SOURCE_DIR}/cmake"
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/autowiring-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/autowiring-configVersion.cmake"
DESTINATION "cmake"
COMPONENT autowiring
)

# Install public header files
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/autowiring/
DESTINATION include/autowiring
COMPONENT autowiring
FILES_MATCHING PATTERN "*.h"
)

# Targets file is needed in order to describe how to link Autowiring to the rest of the system
install(EXPORT AutowiringTargets FILE AutowiringTargets.cmake COMPONENT autowiring NAMESPACE Autowiring:: DESTINATION cmake CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})

# 64-bit installations get a different upgrade GUID
if(CMAKE_SIZEOF_VOID_P STREQUAL 8)
set(autowiring_GUID_LAST_CHAR E)
else()
set(autowiring_GUID_LAST_CHAR D)
endif()

# This is the upgrade GUID. Part of the GUID is derived from the major version number. Any time
# the major version number is adjusted, the upgrade GUID changes. This allows multiple versions
# of the same product to be installed on a user's system at the same time, but also means that
# manual uninstallation of older versions is required.
#
# For more information on the rationale for this process, see the discussion on semantic versioning
# found at http://semver.org/
SET(CPACK_WIX_UPGRADE_GUID "{060E5EDD-229${autowiring_VERSION_MAJOR}-4AD8-BAFA-A303D5696A2D}")
SET(CPACK_WIX_UPGRADE_GUID "{060E5EDD-229${autowiring_VERSION_MAJOR}-4AD8-BAFA-A303D5696A2${autowiring_GUID_LAST_CHAR}}")

# Need a custom wix installation template so that we update the CMake package registry correctly
# Only really needed on Windows; Mac and Linux have pretty good default search behavior, so we
# leave those alone.
SET(CPACK_WIX_TEMPLATE autowiring.wxs)
SET(CPACK_WIX_TEMPLATE "${CMAKE_SOURCE_DIR}/autowiring.wxs")
SET(CPACK_MONOLITHIC_INSTALL ON)

# Run the script that will grab the debug and release configurations and install them during packaging
set(CPACK_INSTALL_COMMANDS
"${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --config Debug"
"${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --config Release"
"${CMAKE_COMMAND} -DBUILD_TYPE=Debug -P \\\"${CMAKE_SOURCE_DIR}/cmake_package.cmake\\\""
"${CMAKE_COMMAND} -DBUILD_TYPE=Release -P \\\"${CMAKE_SOURCE_DIR}/cmake_package.cmake\\\""
)

# Pick the generator in an appropriate way
if(WIN32)
set(CPACK_GENERATOR WIX ZIP)
elseif(APPLE)
# TODO: Add Bundle as a generator here
set(CPACK_GENERATOR TGZ)
else()
set(CPACK_GENERATOR TGZ DEB)
endif()

# Packaging stuff, if an installer is being made insteadINCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_GENERATOR "WIX")
# Packaging stuff, if an installer is being made instead
SET(CPACK_PACKAGE_VENDOR "Leap Motion")
SET(CPACK_PACKAGE_CONTACT "cmercenary@gmail.com")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
Expand All @@ -155,6 +204,6 @@ if(NOT AUTOWIRING_IS_EMBEDDED)
SET(CPACK_PACKAGE_VERSION_MINOR "${autowiring_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${autowiring_VERSION_PATCH}")
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "autowiring")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "autowiring ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "autowiring")
INCLUDE(CPack)
endif()
15 changes: 11 additions & 4 deletions autowiring-config.cmake.in
@@ -1,7 +1,14 @@
# - Config file for the websocketpp package
# - Config file for the autowiring package
# It defines the following variables
# AUTOWIRING_FOUND - indicates that the module was found
# AUTOWIRING_INCLUDE_DIR - include directories
# autowiring_FOUND - indicates that the module was found
# autowiring_INCLUDE_DIR - include directories

# Check if local build
if ("@CMAKE_CURRENT_BINARY_DIR@" STREQUAL CMAKE_CURRENT_LIST_DIR)
set(autowiring_INCLUDE_DIR "@PROJECT_SOURCE_DIR@")
else()
set(autowiring_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../include")
endif()

include("${CMAKE_CURRENT_LIST_DIR}/AutowiringTargets.cmake")
set(autowiring_FOUND TRUE)
set(autowiring_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@")
9 changes: 8 additions & 1 deletion autowiring-configVersion.cmake.in
@@ -1,4 +1,11 @@
set(PACKAGE_VERSION "@AUTOWIRING_VERSION@")
set(PACKAGE_VERSION "@autowiring_VERSION@")

# Verify that we have a bit depth matching the bit depth desired by the customer
if(NOT ${CMAKE_SIZEOF_VOID_P} STREQUAL @CMAKE_SIZEOF_VOID_P@)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
set(PACKAGE_VERSION_UNSUITABLE TRUE)
return()
endif()

# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
Expand Down
12 changes: 9 additions & 3 deletions autowiring/AnySharedPointer.h
Expand Up @@ -8,12 +8,12 @@ struct AnySharedPointer {
new (m_space) SharedPointerSlot;
}

AnySharedPointer(const AnySharedPointer& rhs) {
explicit AnySharedPointer(const AnySharedPointer& rhs) {
new (m_space) SharedPointerSlot(*rhs.slot());
}

template<class T>
AnySharedPointer(const std::shared_ptr<T>& rhs) {
explicit AnySharedPointer(const std::shared_ptr<T>& rhs) {
// Delegate the remainder to the assign operation:
new (m_space) SharedPointerSlotT<T>(rhs);
}
Expand Down Expand Up @@ -46,6 +46,11 @@ struct AnySharedPointer {
return *slot() == *rhs.slot();
}

template<class T>
bool operator==(const std::shared_ptr<T>& rhs) const {
return *slot() == rhs;
}

/// <summary>
/// Default for std library sorting of unique elements
/// </summary>
Expand Down Expand Up @@ -111,4 +116,5 @@ inline bool operator==(const std::shared_ptr<T>& lhs, const AnySharedPointer& rh
return rhs == lhs;
}

static_assert(!std::is_polymorphic<AnySharedPointer>::value, "The shared pointer cannot be polymorphic");
static_assert(sizeof(AnySharedPointerT<int>) == sizeof(AnySharedPointer), "AnySharedPointer realization cannot have members");
static_assert(!std::is_polymorphic<AnySharedPointer>::value, "The shared pointer cannot be polymorphic, this prevents the root type from being aliased correctly");

0 comments on commit 446f407

Please sign in to comment.