Skip to content

Commit

Permalink
fix merge conflict in tests/CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
r00t- committed Jan 5, 2015
2 parents 4d5708e + 1d27228 commit a66adb7
Show file tree
Hide file tree
Showing 19 changed files with 664 additions and 231 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -12,7 +12,11 @@ notifications:
irc: "chat.freenode.net#volkszaehler.org"

before_install:

- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -qq
- if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
- sudo apt-get install -y libjson0-dev libcurl4-openssl-dev openssl libmicrohttpd-dev uuid-dev uuid-runtime
# -- get libsml --
- git clone https://github.com/TheCount/libsml.git # or https://github.com/dailab/libsml.git
Expand Down
41 changes: 33 additions & 8 deletions CMakeLists.txt
Expand Up @@ -26,6 +26,12 @@ ADD_DEFINITIONS(-g3)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
include (UseCodeCoverage)

# get git sha1 as additional version:
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
git_describe(GIT_SHALONG --always --abbrev=10 --long --all --dirty )


message("Compiling for target '${TARGET}'")
if( TARGET )
if( ${TARGET} STREQUAL "ar71xx")
Expand Down Expand Up @@ -87,8 +93,9 @@ IF(WIN32)
include(FindCURL_WIN32)
else(WIN32)
# add_definitions(-DCURL_STATICLIB)
include(FindCurl)
include(FindCURL)
include(FindGnutls)
include(FindOpenSSL) # needed by MySmartGrid API...
endif(WIN32)

find_library(LIBUUID uuid)
Expand All @@ -105,12 +112,30 @@ myconfigure_file(
)

add_subdirectory(src)

find_package(Subversion)
if(Subversion_FOUND)
add_subdirectory(gtest)

set(ENABLE_GOOGLEMOCK TRUE)
#disable unit tests on gcc4.6 (problems with googlemock 1.7)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4.8
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GOOGLETEST_GCC_COMPILER_VERSION)
# on travis-ci the CMAKE_CXX_COMPILER_VERSION is empty! message(WARNING "Using compiler: ${CMAKE_CXX_COMPILER_VERSION} ${GOOGLETEST_GCC_COMPILER_VERSION}")
if (GOOGLETEST_GCC_COMPILER_VERSION VERSION_LESS 4.8)
message(WARNING "Disabled googlemock/-test tests due to GCC version < 4.8!")
set(ENABLE_GOOGLEMOCK FALSE)
endif()
endif()


if(Subversion_FOUND AND ENABLE_GOOGLEMOCK)
add_subdirectory(gmock)
add_subdirectory(tests)
else()
message(WARNING "googletest based unit tests disabled due to missing subversion! Please install svn.")
if (ENABLE_GOOGLEMOCK)
message(WARNING "googletest based unit tests disabled due to missing subversion! Please install svn.")
endif()
endif()
# enable unit testing
include(CTest)
Expand All @@ -132,14 +157,14 @@ endif(SML_FOUND)

message(" microhttpd: -L${MICROHTTPD_LIBRARY} -I${MICROHTTPD_INCLUDE_DIR}")

if( NOT SML_FOUND)
if( ENABLE_SML AND NOT SML_FOUND)
message(WARNING "libsml was not found.
Install libsml or call cmake -DSML_HOME=path_to_sml_install")
endif( NOT SML_FOUND)
if( NOT MICROHTTPD_FOUND )
endif( ENABLE_SML AND NOT SML_FOUND)
if( ENABLE_LOCAL AND NOT MICROHTTPD_FOUND )
message(FATAL_ERROR "microhttpd ist required.
Install microhttpd or call cmake -DMICROHTTPD_HOME=path_to_microhttpd_install")
endif( NOT MICROHTTPD_FOUND )
endif( ENABLE_LOCAL AND NOT MICROHTTPD_FOUND )

# add some files to the installation target
INSTALL(FILES README INSTALL COPYING DESTINATION
Expand Down
24 changes: 24 additions & 0 deletions gmock/CMakeLists.txt
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 2.8.0)
project(gmock_builder C CXX)
include(ExternalProject)

ExternalProject_Add(googlemock
SVN_REPOSITORY http://googlemock.googlecode.com/svn/tags/release-1.7.0/
CMAKE_ARGS
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# Disable install step
INSTALL_COMMAND ""
# Avoid svn update each time on make
UPDATE_COMMAND ""
)

# Specify include dir
ExternalProject_Get_Property(googlemock source_dir)
set(GMOCK_INCLUDE_DIRS ${source_dir}/include PARENT_SCOPE)
set(GTEST_INCLUDE_DIRS ${source_dir}/gtest/include PARENT_SCOPE)

# Specify MainTest's link libraries
ExternalProject_Get_Property(googlemock binary_dir)
set(GTEST_LIBS_DIR ${binary_dir}/gtest PARENT_SCOPE)
set(GMOCK_LIBS_DIR ${binary_dir} PARENT_SCOPE)

18 changes: 9 additions & 9 deletions include/Reading.hpp
Expand Up @@ -45,8 +45,8 @@ class ReadingIdentifier {
virtual ~ReadingIdentifier(){};

virtual size_t unparse(char *buffer, size_t n) = 0;
virtual bool operator==( ReadingIdentifier &cmp);
bool compare( ReadingIdentifier *lhs, ReadingIdentifier *rhs);
virtual bool operator==( ReadingIdentifier const &cmp) const;
bool compare( ReadingIdentifier const *lhs, ReadingIdentifier const *rhs) const;

virtual const std::string toString() = 0;

Expand All @@ -68,7 +68,7 @@ class ObisIdentifier : public ReadingIdentifier {
virtual ~ObisIdentifier(){};

size_t unparse(char *buffer, size_t n);
bool operator==(ObisIdentifier &cmp);
bool operator==(ObisIdentifier const &cmp) const;
const std::string toString() {
std::ostringstream oss;
oss << "ObisItentifier:" << _obis.toString();
Expand All @@ -92,7 +92,7 @@ class StringIdentifier : public ReadingIdentifier {

void parse(const char *buffer);
size_t unparse(char *buffer, size_t n);
bool operator==(StringIdentifier &cmp);
bool operator==(StringIdentifier const &cmp) const;
const std::string toString() {
std::ostringstream oss;
oss << "StringItentifier:";
Expand All @@ -111,7 +111,7 @@ class ChannelIdentifier : public ReadingIdentifier {

void parse(const char *string);
size_t unparse(char *buffer, size_t n);
bool operator==(ChannelIdentifier &cmp);
bool operator==(ChannelIdentifier const &cmp) const;
const std::string toString() {
std::ostringstream oss;
oss << "ChannelItentifier:";
Expand All @@ -126,7 +126,7 @@ class NilIdentifier : public ReadingIdentifier {
public:
NilIdentifier() {}
size_t unparse(char *buffer, size_t n);
bool operator==(NilIdentifier &cmp);
bool operator==(NilIdentifier const &cmp) const;
const std::string toString() {
std::ostringstream oss;
oss << "NilIdentifier";
Expand All @@ -152,10 +152,10 @@ class Reading {
double value() const { return _value; }

double tvtod() const;
double tvtod(struct timeval tv) const;
double tvtod(struct timeval const &tv) const;
void time() { gettimeofday(&_time, NULL); }
void time(struct timeval &v) { _time = v; }
struct timeval dtotv(double ts);
void time(struct timeval const &v) { _time = v; }
struct timeval dtotv(double const &ts) const; // doesn't set the time, just returns a timeval!

void identifier(ReadingIdentifier *rid) { _identifier.reset(rid); }
const ReadingIdentifier::Ptr identifier() { return _identifier; }
Expand Down
3 changes: 2 additions & 1 deletion include/api/Volkszaehler.hpp
Expand Up @@ -84,7 +84,8 @@ namespace vz {
/**
* Parses JSON encoded exception and stores describtion in err
*/
void api_parse_exception(CURLresponse response, char *err, size_t n);
friend class Volkszaehler_Test;
void api_parse_exception(CURLresponse response, char *err, size_t n);


private:
Expand Down
12 changes: 12 additions & 0 deletions include/gitSha1.h
@@ -0,0 +1,12 @@
/*
solution for git sha based on
http://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake
*/

#ifndef __git_sha1_h_
#define __git_sha1_h_
extern const char g_GIT_SHA1[];
extern const char g_GIT_SHALONG[];

#endif

159 changes: 0 additions & 159 deletions modules/FindCurl.cmake

This file was deleted.

0 comments on commit a66adb7

Please sign in to comment.