Skip to content

Commit

Permalink
EnclosedContextTestBase useful enough to merit creation of new project
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Aug 2, 2014
1 parent 18cffbc commit abb0cf3
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 19 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Expand Up @@ -23,6 +23,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-std=c++11")
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(CMakeModules/pch.cmake)

# We don't build tests unless we're being built by ourselves in our own source tree
Expand Down Expand Up @@ -52,6 +53,21 @@ function(add_googletest dirname)
endif()
endfunction()

function(rewrite_header_paths target_SRC_VAR)
# All include files are located in /autowiring from here, so prepend that to all sources
set(SRCS_TEMP ${${target_SRC_VAR}})
set(SRCS)
foreach(i ${SRCS_TEMP})
string(REGEX MATCH ".*\\.h" hfile ${i})
if(hfile)
list(APPEND SRCS ${PROJECT_SOURCE_DIR}/autowiring/${i})
else()
list(APPEND SRCS ${i})
endif()
endforeach()
set(${target_SRC_VAR} ${SRCS} PARENT_SCOPE)
endfunction()

# We have unit test projects via googletest, they're added in the places where they are defined
enable_testing()

Expand Down
@@ -1,5 +1,7 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once
#include <autowiring/autowiring.h>
#include <gtest/gtest.h>
#include MEMORY_HEADER

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -18,3 +18,4 @@ endif()

add_subdirectory(autonet)
add_subdirectory(autowiring)
add_subdirectory(autotesting)
9 changes: 9 additions & 0 deletions src/autotesting/CMakeLists.txt
@@ -0,0 +1,9 @@
set(AutoTesting_SOURCES
EnclosedContextTestBase.h
EnclosedContextTestBase.cpp
)

rewrite_header_paths(AutoTesting_SOURCES)
add_library(AutoTesting ${AutoTesting_SOURCES})
set_property(TARGET AutoTesting PROPERTY FOLDER "Autowiring")
target_link_libraries(AutoTesting Autowiring)
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "EnclosedContextTestBase.hpp"
#include "EnclosedContextTestBase.h"

struct TestInfoProxy {
TestInfoProxy(const testing::TestInfo& info) :
Expand Down
Expand Up @@ -16,10 +16,10 @@ int g_argc;
char** g_argv;

template<class T, int n>
const char (&ArraySizer(const T (&vals)[n]))[n];
const char(&ArraySizer(const T(&vals)[n]))[n];
#define ARYLEN(x) sizeof(ArraySizer(x))

int main(int argc, char* argv[])
int main(int argc, char* argv [])
{
g_argc = argc;
g_argv = argv;
Expand Down
2 changes: 2 additions & 0 deletions src/autotesting/stdafx.cpp
@@ -0,0 +1,2 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#include "stdafx.h"
21 changes: 21 additions & 0 deletions src/autotesting/stdafx.h
@@ -0,0 +1,21 @@
// Copyright (C) 2012-2014 Leap Motion, Inc. All rights reserved.
#pragma once

// Only include these headers in cases where a pch can be generated
// Currently this is only supported on MSVC
#ifdef _MSC_VER
#include <thread>
#define NOMINMAX
#endif

#ifndef _MSC_VER
#include <stdlib.h>
#endif

// C++11 glue logic, for platforms that have incomplete C++11 support
#include "contrib/C++11/cpp11.h"


template<class T, int n>
const char(&ArraySize(const T(&vals)[n]))[n];
#define ARRAYCOUNT(x) sizeof(ArraySize(x))
13 changes: 1 addition & 12 deletions src/autowiring/CMakeLists.txt
Expand Up @@ -149,18 +149,7 @@ else()
set(Autowiring_SRCS ${Autowiring_Unix_SRCS} ${Autowiring_SRCS})
endif()

# All include files are located in /autowiring from here, so prepend that to all sources
set(Autowiring_SRCS_TEMP ${Autowiring_SRCS})
set(Autowiring_SRCS)
foreach(i ${Autowiring_SRCS_TEMP})
string(REGEX MATCH ".*\\.h" hfile ${i})
if(hfile)
list(APPEND Autowiring_SRCS ${PROJECT_SOURCE_DIR}/autowiring/${i})
else()
list(APPEND Autowiring_SRCS ${i})
endif()
endforeach()

rewrite_header_paths(Autowiring_SRCS)
ADD_MSVC_PRECOMPILED_HEADER("stdafx.h" "stdafx.cpp" Autowiring_SRCS)
add_library(Autowiring STATIC ${Autowiring_SRCS})
set_property(TARGET Autowiring PROPERTY FOLDER "Autowiring")
Expand Down
5 changes: 1 addition & 4 deletions src/autowiring/test/CMakeLists.txt
Expand Up @@ -41,8 +41,6 @@ set(AutowiringTest_SRCS
DispatchQueueTest.cpp
DtorCorrectnessTest.hpp
DtorCorrectnessTest.cpp
EnclosedContextTestBase.hpp
EnclosedContextTestBase.cpp
ExceptionFilterTest.hpp
ExceptionFilterTest.cpp
EventReceiverTest.hpp
Expand Down Expand Up @@ -88,7 +86,6 @@ set(AutowiringTest_SRCS
TestFixtures/MultiInherit.hpp
UuidTest.hpp
UuidTest.cpp
gtest-all-guard.cpp
)

set(
Expand All @@ -105,7 +102,7 @@ set_property(TARGET AutowiringFixture PROPERTY FOLDER "Autowiring")

ADD_MSVC_PRECOMPILED_HEADER("stdafx.h" "stdafx.cpp" AutowiringTest_SRCS)
add_executable(AutowiringTest ${AutowiringTest_SRCS})
target_link_libraries(AutowiringTest Autowiring AutowiringFixture)
target_link_libraries(AutowiringTest Autowiring AutowiringFixture AutoTesting)
set_property(TARGET AutowiringTest PROPERTY FOLDER "Autowiring")

# This is a unit test, let CMake know this
Expand Down

0 comments on commit abb0cf3

Please sign in to comment.