Skip to content

Commit

Permalink
Merge branch 'chore/one-branch-only'
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimkarlsson committed Jul 18, 2015
2 parents 42b4a36 + 1cc92ec commit 1f055e5
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 31 deletions.
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 2.8.8)

project(snowhouse)

option(SNOWHOUSE_BUILD_TESTS "Build the Snowhouse tests" ON)
option(SNOWHOUSE_RUN_TESTS "Run the Snowhouse tests" ON)
option(SNOWHOUSE_IS_CPP11 "Whether to build this as a C++11 project" OFF)

include_directories("${PROJECT_SOURCE_DIR}")

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./bin)

set(CMAKE_CXX_FLAGS "-Wfatal-errors -Wall -W -Werror -Wfloat-equal -Wundef -Wendif-labels -Wshadow -pedantic-errors")

if(${cfg} STREQUAL "C++11")
if(SNOWHOUSE_IS_CPP11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated")

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
Expand All @@ -28,10 +34,16 @@ endif()

message(${CMAKE_CXX_FLAGS})

FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
if (SNOWHOUSE_BUILD_TESTS)
FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
endif()

add_custom_command(TARGET snowhouse-tests
POST_BUILD
COMMAND snowhouse-tests
WORKING_DIRECTORY ./bin)
if (SNOWHOUSE_BUILD_TESTS AND SNOWHOUSE_RUN_TESTS)
add_custom_command(TARGET snowhouse-tests
POST_BUILD
COMMAND snowhouse-tests
WORKING_DIRECTORY ./bin)
elseif (SNOWHOUSE_RUN_TESTS)
message(WARNING "Unable to run snowhouse tests - set:\n option(SNOWHOUSE_BUILD_TESTS, \"Build the Snowhouse tests\" ON)\nand clear your CMakeCache.txt")
endif()
44 changes: 25 additions & 19 deletions cross_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
STATUS=""

function build_for {
CC=$1
CXX=$2
local CC=$1
local CXX=$2
local CXX_VERSION=$3

BUILD_DIR=build-$CC-CXX
mkdir $BUILD_DIR
pushd $BUILD_DIR
CC=$CC CXX=$CXX cmake -Dcfg=C++ ../..
make
STATUS="$STATUS\n$BUILD_DIR - Status: $?"
popd
echo "Compiling for $CC, $CXX, $CXX_VERSION..."

BUILD_DIR=build-$CC-CXX11
if [[ "$CXX_VERSION" == "CXX" ]]; then
local SNOWHOUSE_IS_CPP11=OFF
else
local SNOWHOUSE_IS_CPP11=ON
fi

echo "SNOWHOUSE_IS_CPP11=$SNOWHOUSE_IS_CPP11"

BUILD_DIR=build-$CC-$CXX_VERSION
mkdir $BUILD_DIR
pushd $BUILD_DIR
CC=$CC CXX=$CXX cmake -Dcfg=C++11 ../..
CC=$CC CXX=$CXX cmake -DSNOWHOUSE_IS_CPP11=$SNOWHOUSE_IS_CPP11 ../..
make
STATUS="$STATUS\n$BUILD_DIR - Status: $?"
popd

}

if [[ -d builds ]]; then
Expand All @@ -31,13 +33,17 @@ fi
mkdir builds
pushd builds


build_for gcc-4.5 g++-4.5
build_for gcc-4.6 g++-4.6
build_for gcc-4.7 g++-4.7
build_for gcc-4.8 g++-4.8
build_for gcc-4.9 g++-4.9
build_for clang clang++
build_for gcc-4.5 g++-4.5 CXX
build_for gcc-4.6 g++-4.6 CXX
build_for gcc-4.6 g++-4.6 CXX11
build_for gcc-4.7 g++-4.7 CXX
build_for gcc-4.7 g++-4.7 CXX11
build_for gcc-4.8 g++-4.8 CXX
build_for gcc-4.8 g++-4.8 CXX11
build_for gcc-4.9 g++-4.9 CXX
build_for gcc-4.9 g++-4.9 CXX11
build_for clang clang++ CXX
build_for clang clang++ CXX11
popd

echo "============================================"
Expand Down
10 changes: 10 additions & 0 deletions snowhouse/assertionexception.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ namespace snowhouse {
: m_message(message), m_fileName(fileName), m_line(line)
{}

#if __cplusplus > 199711L
AssertionException(const AssertionException&) = default;
#endif

#if __cplusplus > 199711L
virtual ~AssertionException() noexcept
{
}
#else
virtual ~AssertionException() throw()
{
}
#endif

std::string GetMessage() const
{
Expand Down
7 changes: 6 additions & 1 deletion snowhouse/constraints/equalscontainerconstraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ namespace snowhouse {
const BinaryPredicate predicate_;

private:
EqualsContainerConstraint& operator=(const EqualsContainerConstraint&) { return *this; }

#if __cplusplus > 199711L
#else
EqualsContainerConstraint& operator=(const EqualsContainerConstraint&) { return *this; }
#endif

};

template< typename ExpectedType>
Expand Down
9 changes: 6 additions & 3 deletions snowhouse/fluent/operators/constraintoperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
#include "invalidexpressionexception.h"

namespace snowhouse {

struct ConstraintOperator
{
#if __cplusplus > 199711L
#else
virtual ~ConstraintOperator() {}

#endif

virtual void PerformOperation(ResultStack& result) = 0;
virtual int Precedence() const = 0;

template <typename ConstraintListType, typename ActualType>
static bool EvaluateElementAgainstRestOfExpression(ConstraintListType& list, const ActualType& actual)
{
Expand Down
9 changes: 9 additions & 0 deletions snowhouse/snowhouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

#define SNOWHOUSE_VERSION "1.0.2"

#if __cplusplus > 199711L
#ifdef _MSC_VER
// Visual Studio (including 2013) does not support the noexcept keyword
#define _ALLOW_KEYWORD_MACROS
#define noexcept
#endif
#endif


#include <iostream>
#include <map>
#include <vector>
Expand Down

0 comments on commit 1f055e5

Please sign in to comment.