Skip to content

Commit

Permalink
Merge pull request emilybache#43 from pollen-metrology/CMAKE_FOR_CPP
Browse files Browse the repository at this point in the history
feat: Allow to build the CPP flavor using CMake
  • Loading branch information
Emily Bache authored Jul 24, 2019
2 parents 9034394 + d4213bf commit 72f6a8f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
.*
cmake-build-debug
9 changes: 9 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project(Tennis-Refactoring)

add_definitions(-DUSE_CMAKE)
include_directories(${CMAKE_SOURCE_DIR})

add_executable(tennis1_tests tennis1.cc all_tests.cpp all_tests.hpp test_suite.tests.cpp)
add_executable(tennis2_tests tennis2.cc all_tests.cpp all_tests.hpp test_suite.tests.cpp)
add_executable(tennis3_tests tennis3.cc all_tests.cpp all_tests.hpp test_suite.tests.cpp)

15 changes: 15 additions & 0 deletions cpp/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Tennis-Refactoring-Kata C++

## Using CMake, under Windows

Sample setup (in a Windows console, using Git), and considering you are already located in this folder:
```
mkdir build
cd build
cmake .. -G "Visual Studio 14 2015 Win64"
Tennis-Refactoring.sln
```

Visual Studio should start with the projects in it.
You will have three different project, each one for a specific version of initial source code (1, 2 and 3).
Tests are already complete, code is ready to refactor!
18 changes: 16 additions & 2 deletions cpp/all_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
#include "all_tests.hpp"

/* change this to the version of tennis you want to work on */


#ifndef USE_CMAKE
/*
*
* change this to the version of tennis you want to work on
*
* NOTE: If you are using CMake rather than makefile, you
* don't have to touch this.
*
*/
#include "tennis1.cc"
#else
#include <string>
const std::string tennis_score(int p1Score, int p2Score);
#endif

#include <cassert>

Expand Down Expand Up @@ -168,4 +182,4 @@ void test_Winforplayer1_16_14()
void test_Winforplayer2_14_16()
{
assert("Win for player2" == tennis_score(14, 16));
}
}

0 comments on commit 72f6a8f

Please sign in to comment.