Skip to content

Commit 446f407

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 33751f9 + 12df801 commit 446f407

File tree

163 files changed

+5801
-2062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+5801
-2062
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cmake_install.cmake
1111
*.opensdf
1212
*.ipch
1313
*.dir
14+
*.lib
1415
Win32
1516
Debug
1617
Release
@@ -30,4 +31,9 @@ autowiring-*-*.dmg
3031
autowiring-*-*.deb
3132
autowiring-*-*.rpm
3233
autowiring-*-*.msi
33-
autowiring.xcodeproj
34+
autowiring.xcodeproj
35+
autowiring/AutowiringConfig.h
36+
*.nupkg
37+
lib/*.*
38+
autowiring-*-*.zip
39+
_CPack_Packages

.travis.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,68 @@
11
language: cpp
22
compiler: g++
3+
os: linux
4+
35
before_install:
46
# Enforce whitespace guidelines
57
- ./scripts/whitespace_check.sh
68

9+
# Enforce Leap Motion copyright notice
10+
- ./scripts/copyright_check.sh
11+
712
# g++4.8.1
8-
- if [ "$CXX" == "g++" ]; then sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test; fi
9-
- if [ "$CXX" == "g++" ]; then export CXX; fi
13+
- if [ "$CXX" == "g++" ]; then
14+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
15+
&& export CXX;
16+
fi
1017

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

14-
- sudo apt-get remove gcc-4.6 g++-4.6
15-
- sudo apt-get update -qq
23+
- sudo apt-get remove gcc-4.6 g++-4.6 cmake
24+
- sudo apt-get -qq update
1625

1726
install:
27+
# CMake 3.0
28+
- sudo apt-get -qq install libc6-i386
29+
&& wget http://www.cmake.org/files/v3.0/cmake-3.0.2-Linux-i386.tar.gz
30+
&& tar -xzf cmake-3.0.2-Linux-i386.tar.gz
31+
&& sudo cp -fR cmake-3.0.2-Linux-i386/* /usr
32+
1833
# g++4.8.1
19-
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq gcc-4.8 g++-4.8; fi
20-
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8"; fi
21-
- sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
22-
- sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++
23-
34+
- if [ "$CXX" = "g++" ]; then
35+
sudo apt-get install -qq gcc-4.8 g++-4.8
36+
&& export CXX="g++-4.8"
37+
&& sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
38+
&& sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++;
39+
fi
40+
2441
# clang 3.4
25-
- if [ "$CXX" == "clang++" ]; then sudo apt-get install --allow-unauthenticated -qq clang-3.4; fi
26-
- if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.4"; fi
27-
42+
- if [ "$CXX" == "clang++" ]; then
43+
sudo apt-get install --allow-unauthenticated -qq clang-3.4
44+
&& export CXX="clang++-3.4";
45+
fi
46+
2847
before_script:
29-
- cmake .
30-
script:
3148
- export CPATH=/usr/include/c++/4.8:/usr/include/x86_64-linux-gnu/c++/4.8/:$CPATH
3249
- export LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8:$LD_LIBRARY_PATH
50+
- cmake . -DCMAKE_BUILD_TYPE=Release
51+
52+
script:
53+
# Build Autowriring, run unit tests, and install
3354
- make -j 8 || make
34-
- make test
55+
- ctest --output-on-failure
56+
- sudo make install
57+
58+
# Package
59+
- sudo cpack || (cat _CPack_Packages/Linux/TGZ/InstallOutput.log; exit 1)
60+
61+
# Build examples from installed Autowiring
62+
- cd examples
63+
&& cmake .
64+
&& make
65+
&& cd ..
66+
3567
after_failure:
3668
- cat Testing/Temporary/LastTest.log 2> /dev/null
37-
os:
38-
- linux
39-
- osx

Autowiring.nuspec

Lines changed: 192 additions & 0 deletions
Large diffs are not rendered by default.

AutowiringConfig.h.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
2+
#pragma once
3+
4+
//
5+
// Define preprocessor macros from CMake variables
6+
//
7+
8+
// Are we building autonet?
9+
#cmakedefine01 AUTOWIRING_BUILD_AUTONET
10+
11+
// Are we linking with C++11 STL?
12+
#cmakedefine01 USE_LIBCXX
13+
#if USE_LIBCXX
14+
#define AUTOWIRING_USE_LIBCXX 1
15+
#else
16+
#define AUTOWIRING_USE_LIBCXX 0
17+
#endif

CMakeLists.txt

Lines changed: 90 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
cmake_minimum_required(VERSION 2.8)
2-
project(autowiring)
1+
cmake_minimum_required(VERSION 3.0)
2+
include(version.cmake)
3+
project(autowiring VERSION ${autowiring_VERSION})
34
include(CTest)
45

5-
# TODO: Use the VERSION attribute for the "project" setting instead after upgrading
6-
# the cmake_minimum_required to version 3.0
7-
set(autowiring_VERSION_MAJOR 0)
8-
set(autowiring_VERSION_MINOR 1)
9-
set(autowiring_VERSION_PATCH 0)
10-
116
# Determine whether Autowiring has been embedded in another project
127
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
138
set(AUTOWIRING_IS_EMBEDDED)
@@ -31,25 +26,22 @@ else()
3126
endif()
3227
endif()
3328

34-
# Macro for deprecated functionality needed to comply with c++98 std implementations
35-
if(NOT USE_LIBCXX)
36-
add_definitions(-DAUTOWIRING_UNSAFE_HASHTABLE)
29+
if(NOT WIN32)
30+
set(CMAKE_CXX_FLAGS "-std=c++11")
31+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
3732
endif()
38-
3933
if(USE_LIBCXX)
4034
# Clang needs special additional flags to build with C++11
41-
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
35+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
36+
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
37+
message("AppleClang C++11")
38+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
39+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
40+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
4241
message("Clang C++11")
43-
if (APPLE)
44-
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead
45-
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
46-
else()
47-
set(CMAKE_CXX_FLAGS "-std=c++11")
48-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
49-
endif()
42+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
5043
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
5144
message("GCC C++11")
52-
set(CMAKE_CXX_FLAGS "-std=c++11")
5345
endif()
5446
endif()
5547

@@ -64,17 +56,34 @@ set(AUTOWIRING_BUILD_AUTONET_DEFAULT ON)
6456
get_filename_component(AUTOWIRING_ROOT_DIR . ABSOLUTE)
6557
if(AUTOWIRING_IS_EMBEDDED)
6658
set(AUTOWIRING_BUILD_TESTS_DEFAULT OFF)
67-
set(AUTOWIRING_BUILD_EXAMPLES_DEFAULT OFF)
6859
else()
6960
set(AUTOWIRING_BUILD_TESTS_DEFAULT ON)
70-
set(AUTOWIRING_BUILD_EXAMPLES_DEFAULT ON)
7161

7262
# All of our binaries go to one place: The binaries output directory. We only want to tinker
7363
# with this if we're building by ourselves, otherwise we just do whatever the enclosing project
7464
# wants us to do.
75-
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
65+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
66+
67+
# Libraries not only all wind up in the libraries directory, but we also keep them all together
68+
# here by putting them in the same place, regardless of whether they are debug or release. This
69+
# makes globbing them together much easier.
70+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
71+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
72+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
73+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
74+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/lib)
75+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/lib)
76+
endif()
77+
78+
# 64-bit installations should suffix with 64
79+
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
80+
set(CMAKE_DEBUG_POSTFIX "64")
81+
set(CMAKE_RELEASE_POSTFIX "64")
7682
endif()
7783

84+
# Postfix on all debug libraries should be "d"
85+
set(CMAKE_DEBUG_POSTFIX d${CMAKE_DEBUG_POSTFIX})
86+
7887
option(AUTOWIRING_BUILD_TESTS "Build Autowiring unit tests" ${AUTOWIRING_BUILD_TESTS_DEFAULT})
7988
function(add_googletest dirname)
8089
if(AUTOWIRING_BUILD_TESTS)
@@ -107,45 +116,85 @@ include_directories(
107116
contrib
108117
contrib/websocketpp
109118
)
110-
add_subdirectory(src)
111-
add_subdirectory(contrib)
112-
113-
# Build examples
114-
option(AUTOWIRING_BUILD_EXAMPLES "Build Autowiring examples" ${AUTOWIRING_BUILD_EXAMPLES_DEFAULT})
115-
if(AUTOWIRING_BUILD_EXAMPLES)
116-
add_subdirectory(examples)
117-
endif()
118119

119120
# CMake configurations
121+
if(${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
122+
set(autowiring_ARCHITECTURE "64")
123+
else()
124+
set(autowiring_ARCHITECTURE "32")
125+
endif()
120126
configure_file(autowiring-config.cmake.in autowiring-config.cmake @ONLY)
121127
configure_file(autowiring-configVersion.cmake.in autowiring-configVersion.cmake @ONLY)
128+
configure_file(AutowiringConfig.h.in ${PROJECT_SOURCE_DIR}/autowiring/AutowiringConfig.h @ONLY)
129+
130+
# Recurse through source directories
131+
add_subdirectory(src)
132+
133+
# Export library
134+
export(EXPORT AutowiringTargets FILE AutowiringTargets.cmake NAMESPACE Autowiring::)
122135

123136
# Only attempt to do anything with cpack if we're being built stand-alone
124137
if(NOT AUTOWIRING_IS_EMBEDDED)
125138
# Install autowiring-config.cmake and autowiring-configVersion.cmake
126-
install (FILES
127-
"${CMAKE_BINARY_DIR}/contrib/autowiring/autowiring-config.cmake"
128-
"${CMAKE_BINARY_DIR}/contrib/autowiring/autowiring-configVersion.cmake"
129-
DESTINATION "${CMAKE_SOURCE_DIR}/cmake"
139+
install(FILES
140+
"${CMAKE_CURRENT_BINARY_DIR}/autowiring-config.cmake"
141+
"${CMAKE_CURRENT_BINARY_DIR}/autowiring-configVersion.cmake"
142+
DESTINATION "cmake"
143+
COMPONENT autowiring
144+
)
145+
146+
# Install public header files
147+
install(
148+
DIRECTORY ${PROJECT_SOURCE_DIR}/autowiring/
149+
DESTINATION include/autowiring
130150
COMPONENT autowiring
151+
FILES_MATCHING PATTERN "*.h"
131152
)
132153

154+
# Targets file is needed in order to describe how to link Autowiring to the rest of the system
155+
install(EXPORT AutowiringTargets FILE AutowiringTargets.cmake COMPONENT autowiring NAMESPACE Autowiring:: DESTINATION cmake CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
156+
157+
# 64-bit installations get a different upgrade GUID
158+
if(CMAKE_SIZEOF_VOID_P STREQUAL 8)
159+
set(autowiring_GUID_LAST_CHAR E)
160+
else()
161+
set(autowiring_GUID_LAST_CHAR D)
162+
endif()
163+
133164
# This is the upgrade GUID. Part of the GUID is derived from the major version number. Any time
134165
# the major version number is adjusted, the upgrade GUID changes. This allows multiple versions
135166
# of the same product to be installed on a user's system at the same time, but also means that
136167
# manual uninstallation of older versions is required.
137168
#
138169
# For more information on the rationale for this process, see the discussion on semantic versioning
139170
# found at http://semver.org/
140-
SET(CPACK_WIX_UPGRADE_GUID "{060E5EDD-229${autowiring_VERSION_MAJOR}-4AD8-BAFA-A303D5696A2D}")
171+
SET(CPACK_WIX_UPGRADE_GUID "{060E5EDD-229${autowiring_VERSION_MAJOR}-4AD8-BAFA-A303D5696A2${autowiring_GUID_LAST_CHAR}}")
141172

142173
# Need a custom wix installation template so that we update the CMake package registry correctly
143174
# Only really needed on Windows; Mac and Linux have pretty good default search behavior, so we
144175
# leave those alone.
145-
SET(CPACK_WIX_TEMPLATE autowiring.wxs)
176+
SET(CPACK_WIX_TEMPLATE "${CMAKE_SOURCE_DIR}/autowiring.wxs")
177+
SET(CPACK_MONOLITHIC_INSTALL ON)
178+
179+
# Run the script that will grab the debug and release configurations and install them during packaging
180+
set(CPACK_INSTALL_COMMANDS
181+
"${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --config Debug"
182+
"${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --config Release"
183+
"${CMAKE_COMMAND} -DBUILD_TYPE=Debug -P \\\"${CMAKE_SOURCE_DIR}/cmake_package.cmake\\\""
184+
"${CMAKE_COMMAND} -DBUILD_TYPE=Release -P \\\"${CMAKE_SOURCE_DIR}/cmake_package.cmake\\\""
185+
)
186+
187+
# Pick the generator in an appropriate way
188+
if(WIN32)
189+
set(CPACK_GENERATOR WIX ZIP)
190+
elseif(APPLE)
191+
# TODO: Add Bundle as a generator here
192+
set(CPACK_GENERATOR TGZ)
193+
else()
194+
set(CPACK_GENERATOR TGZ DEB)
195+
endif()
146196

147-
# Packaging stuff, if an installer is being made insteadINCLUDE(InstallRequiredSystemLibraries)
148-
SET(CPACK_GENERATOR "WIX")
197+
# Packaging stuff, if an installer is being made instead
149198
SET(CPACK_PACKAGE_VENDOR "Leap Motion")
150199
SET(CPACK_PACKAGE_CONTACT "cmercenary@gmail.com")
151200
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
@@ -155,6 +204,6 @@ if(NOT AUTOWIRING_IS_EMBEDDED)
155204
SET(CPACK_PACKAGE_VERSION_MINOR "${autowiring_VERSION_MINOR}")
156205
SET(CPACK_PACKAGE_VERSION_PATCH "${autowiring_VERSION_PATCH}")
157206
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "autowiring")
158-
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "autowiring ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
207+
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "autowiring")
159208
INCLUDE(CPack)
160209
endif()

autowiring-config.cmake.in

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
# - Config file for the websocketpp package
1+
# - Config file for the autowiring package
22
# It defines the following variables
3-
# AUTOWIRING_FOUND - indicates that the module was found
4-
# AUTOWIRING_INCLUDE_DIR - include directories
3+
# autowiring_FOUND - indicates that the module was found
4+
# autowiring_INCLUDE_DIR - include directories
55

6+
# Check if local build
7+
if ("@CMAKE_CURRENT_BINARY_DIR@" STREQUAL CMAKE_CURRENT_LIST_DIR)
8+
set(autowiring_INCLUDE_DIR "@PROJECT_SOURCE_DIR@")
9+
else()
10+
set(autowiring_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../include")
11+
endif()
12+
13+
include("${CMAKE_CURRENT_LIST_DIR}/AutowiringTargets.cmake")
614
set(autowiring_FOUND TRUE)
7-
set(autowiring_INCLUDE_DIR "@INSTALL_INCLUDE_DIR@")

autowiring-configVersion.cmake.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
set(PACKAGE_VERSION "@AUTOWIRING_VERSION@")
1+
set(PACKAGE_VERSION "@autowiring_VERSION@")
2+
3+
# Verify that we have a bit depth matching the bit depth desired by the customer
4+
if(NOT ${CMAKE_SIZEOF_VOID_P} STREQUAL @CMAKE_SIZEOF_VOID_P@)
5+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
6+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
7+
return()
8+
endif()
29

310
# Check whether the requested PACKAGE_FIND_VERSION is compatible
411
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")

autowiring/AnySharedPointer.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ struct AnySharedPointer {
88
new (m_space) SharedPointerSlot;
99
}
1010

11-
AnySharedPointer(const AnySharedPointer& rhs) {
11+
explicit AnySharedPointer(const AnySharedPointer& rhs) {
1212
new (m_space) SharedPointerSlot(*rhs.slot());
1313
}
1414

1515
template<class T>
16-
AnySharedPointer(const std::shared_ptr<T>& rhs) {
16+
explicit AnySharedPointer(const std::shared_ptr<T>& rhs) {
1717
// Delegate the remainder to the assign operation:
1818
new (m_space) SharedPointerSlotT<T>(rhs);
1919
}
@@ -46,6 +46,11 @@ struct AnySharedPointer {
4646
return *slot() == *rhs.slot();
4747
}
4848

49+
template<class T>
50+
bool operator==(const std::shared_ptr<T>& rhs) const {
51+
return *slot() == rhs;
52+
}
53+
4954
/// <summary>
5055
/// Default for std library sorting of unique elements
5156
/// </summary>
@@ -111,4 +116,5 @@ inline bool operator==(const std::shared_ptr<T>& lhs, const AnySharedPointer& rh
111116
return rhs == lhs;
112117
}
113118

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

0 commit comments

Comments
 (0)