From a42f28b1f2c63f4b8ba19c660d63461f665c946b Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 3 Oct 2017 21:24:14 +0100
Subject: Create gitignore and add Clion
---
.gitignore | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d574d28
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,53 @@
+#########
+# CLion #
+#########
+
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff:
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/dictionaries
+
+# Sensitive or high-churn files:
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.xml
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+
+# Gradle:
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# CMake
+cmake-build-debug/
+
+# Mongo Explorer plugin:
+.idea/**/mongoSettings.xml
+
+## File-based project format:
+*.iws
+
+## Plugin-specific files:
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
\ No newline at end of file
--
cgit v1.2.1
From cacda71be04d2aab6e88cc1fc47d6a61385214c8 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 3 Oct 2017 21:26:09 +0100
Subject: Add CLion basic project, including CMake build
---
.idea/GeneralSolitaireSolver.iml | 2 ++
.idea/misc.xml | 4 ++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
CMakeLists.txt | 7 +++++++
main.cpp | 6 ++++++
6 files changed, 33 insertions(+)
create mode 100644 .idea/GeneralSolitaireSolver.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 CMakeLists.txt
create mode 100644 main.cpp
diff --git a/.idea/GeneralSolitaireSolver.iml b/.idea/GeneralSolitaireSolver.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/GeneralSolitaireSolver.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..79b3c94
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..882d001
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..1199237
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.8)
+project(GeneralSolitaireSolver)
+
+set(CMAKE_CXX_STANDARD 17)
+
+set(SOURCE_FILES main.cpp)
+add_executable(GeneralSolitaireSolver ${SOURCE_FILES})
\ No newline at end of file
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..f253cbe
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,6 @@
+#include
+
+int main() {
+ std::cout << "Hello, World!" << std::endl;
+ return 0;
+}
\ No newline at end of file
--
cgit v1.2.1
From c5064699ca59935cda93be77555ad77650bd00e1 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 3 Oct 2017 23:40:54 +0100
Subject: Create proper CMake build (install & resources)
---
.idea/.name | 1 +
CMakeLists.txt | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
main.cpp | 6 ------
src/main/main.cpp | 6 ++++++
4 files changed, 60 insertions(+), 11 deletions(-)
create mode 100644 .idea/.name
delete mode 100644 main.cpp
create mode 100644 src/main/main.cpp
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..a8eb715
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+solitaire_pip
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1199237..b29582d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,55 @@
-cmake_minimum_required(VERSION 3.8)
-project(GeneralSolitaireSolver)
+# File based on solitaire_pip at https://stackoverflow.com/questions/21163188/most-simple-but-complete-cmake-example
-set(CMAKE_CXX_STANDARD 17)
+cmake_minimum_required(VERSION 3.0)
+project(solitaire_pip)
-set(SOURCE_FILES main.cpp)
-add_executable(GeneralSolitaireSolver ${SOURCE_FILES})
\ No newline at end of file
+set(CMAKE_CXX_STANDARD 14)
+
+###############################################################################
+## file globbing ##############################################################
+###############################################################################
+
+# these instructions search the directory tree when cmake is
+# invoked and put all files that match the pattern in the variables
+# `sources` and `data`
+file(GLOB_RECURSE sources src/main/*.cpp src/main/*.h)
+file(GLOB_RECURSE sources_test src/test/*.cpp)
+file(GLOB_RECURSE data resources/*)
+
+###############################################################################
+## target definitions #########################################################
+###############################################################################
+
+# add the data to the target, so it becomes visible in some IDE
+add_executable(solitaire_pip ${sources} ${data})
+
+# just for example add some compiler flags
+target_compile_options(solitaire_pip PUBLIC -std=c++1y -Wall -Wfloat-conversion)
+
+# this lets me include files relative to the root src dir with a <> pair
+target_include_directories(solitaire_pip PUBLIC src/main)
+
+# this copies all resource files in the build directory
+# we need this, because we want to work with paths relative to the executable
+file(COPY ${data} DESTINATION resources)
+
+###############################################################################
+## packaging ##################################################################
+###############################################################################
+
+# all install commands get the same destination. this allows us to use paths
+# relative to the executable.
+install(TARGETS solitaire_pip DESTINATION solitaire_pip)
+# this is basically a repeat of the file copy instruction that copies the
+# resources in the build directory, but here we tell cmake that we want it
+# in the package
+install(DIRECTORY resources DESTINATION solitaire_pip)
+
+set(CPACK_OUTPUT_FILE_PREFIX installer)
+set(CPACK_PACKAGE_VERSION "1.0.0")
+
+# we don't want to split our program up into several things
+set(CPACK_MONOLITHIC_INSTALL 1)
+
+# This must be last
+include(CPack)
\ No newline at end of file
diff --git a/main.cpp b/main.cpp
deleted file mode 100644
index f253cbe..0000000
--- a/main.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include
-
-int main() {
- std::cout << "Hello, World!" << std::endl;
- return 0;
-}
\ No newline at end of file
diff --git a/src/main/main.cpp b/src/main/main.cpp
new file mode 100644
index 0000000..f253cbe
--- /dev/null
+++ b/src/main/main.cpp
@@ -0,0 +1,6 @@
+#include
+
+int main() {
+ std::cout << "Hello, World!" << std::endl;
+ return 0;
+}
\ No newline at end of file
--
cgit v1.2.1
From f2dba3b2d3caeb89f28a1c84594a8a440731352e Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Wed, 4 Oct 2017 11:10:42 +0100
Subject: Add build instructions file
---
build-instructions.md | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 build-instructions.md
diff --git a/build-instructions.md b/build-instructions.md
new file mode 100644
index 0000000..69a6ac0
--- /dev/null
+++ b/build-instructions.md
@@ -0,0 +1,17 @@
+# How to build / run the project
+
+The project uses the CMake build system generator. there are several stages for
+building the project, running the program, and creating an installer.
+
+## Generate Build System
+
+`cmake -Bcmake-build-debug -H.`
+
+## Build project
+
+`cmake --build cmake-build-debug`
+
+## Create project installer
+
+`cpack --config cmake-build-debug/CPackConfig.cmake`
+
--
cgit v1.2.1
From 43591b71e8d69e2184cf1eafb8de05988b8dab53 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Wed, 4 Oct 2017 11:53:16 +0100
Subject: Add conan.io to project & add Boost to Hello World
---
CMakeLists.txt | 14 ++++++++++++++
build-instructions.md | 8 ++++++++
conanfile.txt | 5 +++++
src/main/main.cpp | 13 +++++++++++--
4 files changed, 38 insertions(+), 2 deletions(-)
create mode 100644 conanfile.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b29582d..d70caad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,17 @@ file(GLOB_RECURSE sources src/main/*.cpp src/main/*.h)
file(GLOB_RECURSE sources_test src/test/*.cpp)
file(GLOB_RECURSE data resources/*)
+###############################################################################
+## conan.io setup #############################################################
+###############################################################################
+
+if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+ conan_basic_setup()
+else()
+ message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
+endif()
+
###############################################################################
## target definitions #########################################################
###############################################################################
@@ -29,6 +40,9 @@ target_compile_options(solitaire_pip PUBLIC -std=c++1y -Wall -Wfloat-conversion)
# this lets me include files relative to the root src dir with a <> pair
target_include_directories(solitaire_pip PUBLIC src/main)
+# link conan libraries
+target_link_libraries(solitaire_pip ${CONAN_LIBS})
+
# this copies all resource files in the build directory
# we need this, because we want to work with paths relative to the executable
file(COPY ${data} DESTINATION resources)
diff --git a/build-instructions.md b/build-instructions.md
index 69a6ac0..02459b4 100644
--- a/build-instructions.md
+++ b/build-instructions.md
@@ -3,6 +3,10 @@
The project uses the CMake build system generator. there are several stages for
building the project, running the program, and creating an installer.
+## Installing dependencies
+
+`cd cmake-build-debug; conan install ..; cd ..`
+
## Generate Build System
`cmake -Bcmake-build-debug -H.`
@@ -11,6 +15,10 @@ building the project, running the program, and creating an installer.
`cmake --build cmake-build-debug`
+## Run executable
+
+`./cmake-build-debug/bin/solitaire_pip`
+
## Create project installer
`cpack --config cmake-build-debug/CPackConfig.cmake`
diff --git a/conanfile.txt b/conanfile.txt
new file mode 100644
index 0000000..2bcb821
--- /dev/null
+++ b/conanfile.txt
@@ -0,0 +1,5 @@
+[requires]
+Boost/1.60.0@lasote/stable
+
+[generators]
+cmake
diff --git a/src/main/main.cpp b/src/main/main.cpp
index f253cbe..0c9e38a 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -1,6 +1,15 @@
+#include
#include
+#include
+
+int main()
+{
+ std::string hello( "Hello, world!\n" );
+
+ BOOST_FOREACH( char ch, hello )
+ {
+ std::cout << ch;
+ }
-int main() {
- std::cout << "Hello, World!" << std::endl;
return 0;
}
\ No newline at end of file
--
cgit v1.2.1
From f3527383760c2eb497a895a86fd5f3679ee0066c Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Wed, 4 Oct 2017 15:32:39 +0100
Subject: Add release as well as debug build
---
.gitignore | 3 ++-
build-instructions.md | 24 ++++++++++++++----------
clean-build.sh | 16 ++++++++++++++++
3 files changed, 32 insertions(+), 11 deletions(-)
create mode 100755 clean-build.sh
diff --git a/.gitignore b/.gitignore
index d574d28..dfd52ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@
# CMake
cmake-build-debug/
+cmake-build-release/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
@@ -50,4 +51,4 @@ atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
-fabric.properties
\ No newline at end of file
+fabric.properties
diff --git a/build-instructions.md b/build-instructions.md
index 02459b4..8ecb321 100644
--- a/build-instructions.md
+++ b/build-instructions.md
@@ -3,23 +3,27 @@
The project uses the CMake build system generator. there are several stages for
building the project, running the program, and creating an installer.
-## Installing dependencies
+### Installing dependencies
-`cd cmake-build-debug; conan install ..; cd ..`
+`cd cmake-build-[debug|release]; conan install ..; cd ..`
-## Generate Build System
+### Generate Build System
-`cmake -Bcmake-build-debug -H.`
+`cmake -Bcmake-build-[debug|release] -H.`
-## Build project
+### Build project
-`cmake --build cmake-build-debug`
+`cmake --build cmake-build-[debug|release]`
-## Run executable
+### Run executable
-`./cmake-build-debug/bin/solitaire_pip`
+`./cmake-build-[debug|release]/bin/solitaire_pip`
-## Create project installer
+### Create project installer
-`cpack --config cmake-build-debug/CPackConfig.cmake`
+`cpack --config cmake-build-[debug|release]/CPackConfig.cmake`
+## A Note on CLion
+
+If CLion complains that a dependency is missing, you may need to run the conan
+install command, and then in Clion run 'File->Reload CMake Project
diff --git a/clean-build.sh b/clean-build.sh
new file mode 100755
index 0000000..b9847a3
--- /dev/null
+++ b/clean-build.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo "Cleaning..."
+rm -r cmake-build-release/*; rm -r cmake-build-debug/*
+
+echo "Installing..."
+cd cmake-build-debug; conan install ..; cd ..
+cd cmake-build-release; conan install ..; cd ..
+
+echo "Generating build..."
+cmake -Bcmake-build-debug -H.
+cmake -Bcmake-build-release -H.
+
+echo "Building..."
+cmake --build cmake-build-debug
+cmake --build cmake-build-release
--
cgit v1.2.1
From 33f3a5e1a340a96d2481d2ef62d12bb26fa8d1bb Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Thu, 5 Oct 2017 00:04:52 +0100
Subject: Add GTest library to build and basic unit tests
---
CMakeLists.txt | 24 ++++++++++++++++++++----
build-instructions.md | 3 ++-
clean-build.sh | 6 ++++--
conanfile.txt | 4 ++++
src/test/all_tests.cpp | 10 ++++++++++
src/test/main_test.cpp | 19 +++++++++++++++++++
6 files changed, 59 insertions(+), 7 deletions(-)
create mode 100644 src/test/all_tests.cpp
create mode 100644 src/test/main_test.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d70caad..0ff92bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,9 +12,8 @@ set(CMAKE_CXX_STANDARD 14)
# these instructions search the directory tree when cmake is
# invoked and put all files that match the pattern in the variables
# `sources` and `data`
-file(GLOB_RECURSE sources src/main/*.cpp src/main/*.h)
-file(GLOB_RECURSE sources_test src/test/*.cpp)
-file(GLOB_RECURSE data resources/*)
+set(sources src/main/main.cpp)
+set(sources_test src/test/all_tests.cpp src/test/main_test.cpp)
###############################################################################
## conan.io setup #############################################################
@@ -32,7 +31,7 @@ endif()
###############################################################################
# add the data to the target, so it becomes visible in some IDE
-add_executable(solitaire_pip ${sources} ${data})
+add_executable(solitaire_pip ${sources})
# just for example add some compiler flags
target_compile_options(solitaire_pip PUBLIC -std=c++1y -Wall -Wfloat-conversion)
@@ -47,6 +46,23 @@ target_link_libraries(solitaire_pip ${CONAN_LIBS})
# we need this, because we want to work with paths relative to the executable
file(COPY ${data} DESTINATION resources)
+###############################################################################
+## testing ####################################################################
+###############################################################################
+
+add_executable(unit_tests ${sources_test})
+
+# this allows us to use our executable as a link library
+# therefore we can inherit all compiler options and library dependencies
+set_target_properties(solitaire_pip PROPERTIES ENABLE_EXPORTS on)
+
+target_link_libraries(unit_tests ${CONAN_LIBS} solitaire_pip)
+
+ENABLE_TESTING()
+ADD_TEST(NAME unit_tests
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+ COMMAND unit_tests)
+
###############################################################################
## packaging ##################################################################
###############################################################################
diff --git a/build-instructions.md b/build-instructions.md
index 8ecb321..1240c7b 100644
--- a/build-instructions.md
+++ b/build-instructions.md
@@ -5,7 +5,8 @@ building the project, running the program, and creating an installer.
### Installing dependencies
-`cd cmake-build-[debug|release]; conan install ..; cd ..`
+`cd cmake-build-[debug|release]; conan install .. --build missing -s \
+compiler=gcc -s compiler.version=6.3 -s compiler.libcxx=libstdc++11; cd ..`
### Generate Build System
diff --git a/clean-build.sh b/clean-build.sh
index b9847a3..d566226 100755
--- a/clean-build.sh
+++ b/clean-build.sh
@@ -4,8 +4,10 @@ echo "Cleaning..."
rm -r cmake-build-release/*; rm -r cmake-build-debug/*
echo "Installing..."
-cd cmake-build-debug; conan install ..; cd ..
-cd cmake-build-release; conan install ..; cd ..
+cd cmake-build-debug; conan install .. --build missing -s compiler=gcc \
+ -s compiler.version=6.3 -s compiler.libcxx=libstdc++11; cd ..
+cd cmake-build-release; conan install .. --build missing -s compiler=gcc \
+ -s compiler.version=6.3 -s compiler.libcxx=libstdc++11; cd ..
echo "Generating build..."
cmake -Bcmake-build-debug -H.
diff --git a/conanfile.txt b/conanfile.txt
index 2bcb821..f181ce5 100644
--- a/conanfile.txt
+++ b/conanfile.txt
@@ -1,5 +1,9 @@
[requires]
Boost/1.60.0@lasote/stable
+gtest/1.8.0@lasote/stable
+
+[options]
+gtest:shared=False
[generators]
cmake
diff --git a/src/test/all_tests.cpp b/src/test/all_tests.cpp
new file mode 100644
index 0000000..7dce333
--- /dev/null
+++ b/src/test/all_tests.cpp
@@ -0,0 +1,10 @@
+//
+// Created by thecharlesblake on 10/4/17.
+//
+
+#include
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/src/test/main_test.cpp b/src/test/main_test.cpp
new file mode 100644
index 0000000..3f2081f
--- /dev/null
+++ b/src/test/main_test.cpp
@@ -0,0 +1,19 @@
+//
+// Created by thecharlesblake on 10/4/17.
+//
+
+#include
+
+const int actualValTrue = 4;
+const int actualValFalse = 8;
+const int expectVal = 4;
+
+namespace {
+ TEST(StrCompare, CStrEqual) {
+ EXPECT_EQ(expectVal, actualValTrue);
+ }
+
+ TEST(StrCompare, CStrNotEqual) {
+ EXPECT_NE(expectVal, actualValFalse);
+ }
+}
--
cgit v1.2.1
From bc6914fb1088cededf32d558db85d1e3b14d4bea Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 10 Oct 2017 14:07:39 +0100
Subject: Add compile options and integrate into build
---
CMakeLists.txt | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ff92bb..b33bf3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,12 +6,9 @@ project(solitaire_pip)
set(CMAKE_CXX_STANDARD 14)
###############################################################################
-## file globbing ##############################################################
+## source files ###############################################################
###############################################################################
-# these instructions search the directory tree when cmake is
-# invoked and put all files that match the pattern in the variables
-# `sources` and `data`
set(sources src/main/main.cpp)
set(sources_test src/test/all_tests.cpp src/test/main_test.cpp)
@@ -21,21 +18,37 @@ set(sources_test src/test/all_tests.cpp src/test/main_test.cpp)
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+ # Disable warnings/errors for conan libraries
+ set(CONAN_SYSTEM_INCLUDES On)
conan_basic_setup()
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
+###############################################################################
+## compile options ############################################################
+###############################################################################
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pedantic -Wall -Wextra \
+-Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wformat=2 -Winit-self \
+-Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept \
+-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow \
+-Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror")
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -s -DNDEBUG -Wl,-O1")
+
###############################################################################
## target definitions #########################################################
###############################################################################
+# Default to building the 'Debug' configuration
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug CACHE STRING "The build configuration" FORCE)
+endif()
+
# add the data to the target, so it becomes visible in some IDE
add_executable(solitaire_pip ${sources})
-# just for example add some compiler flags
-target_compile_options(solitaire_pip PUBLIC -std=c++1y -Wall -Wfloat-conversion)
-
# this lets me include files relative to the root src dir with a <> pair
target_include_directories(solitaire_pip PUBLIC src/main)
--
cgit v1.2.1
From dca474290c5a6b722ecd86c5b5f51f91c37ea547 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 10 Oct 2017 14:08:21 +0100
Subject: Edit cmd-line build instructions to gen IDE files
---
build-instructions.md | 2 +-
clean-build.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/build-instructions.md b/build-instructions.md
index 1240c7b..85a7043 100644
--- a/build-instructions.md
+++ b/build-instructions.md
@@ -10,7 +10,7 @@ compiler=gcc -s compiler.version=6.3 -s compiler.libcxx=libstdc++11; cd ..`
### Generate Build System
-`cmake -Bcmake-build-[debug|release] -H.`
+`cmake [-G "CodeBlocks - Unix Makefiles"] -DCMAKE_BUILD_TYPE=[DEBUG|RELEASE] -Bcmake-build-[debug|release] -H.`
### Build project
diff --git a/clean-build.sh b/clean-build.sh
index d566226..d037403 100755
--- a/clean-build.sh
+++ b/clean-build.sh
@@ -10,8 +10,8 @@ cd cmake-build-release; conan install .. --build missing -s compiler=gcc \
-s compiler.version=6.3 -s compiler.libcxx=libstdc++11; cd ..
echo "Generating build..."
-cmake -Bcmake-build-debug -H.
-cmake -Bcmake-build-release -H.
+cmake -G "CodeBlocks - Unix Makefiles" -DCMAKE_BUILD_TYPE=DEBUG --target solitaire_pip -Bcmake-build-debug -H.
+cmake -G "CodeBlocks - Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE --target solitaire_pip -Bcmake-build-release -H.
echo "Building..."
cmake --build cmake-build-debug
--
cgit v1.2.1
From adf21a916da27743dc6a6468532af5d40f4e68c6 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Tue, 10 Oct 2017 14:29:46 +0100
Subject: Change project name to Solvitaire
---
.idea/GeneralSolitaireSolver.iml | 2 --
.idea/Solvitaire.iml | 2 ++
.idea/modules.xml | 4 ++--
README.md | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
delete mode 100644 .idea/GeneralSolitaireSolver.iml
create mode 100644 .idea/Solvitaire.iml
diff --git a/.idea/GeneralSolitaireSolver.iml b/.idea/GeneralSolitaireSolver.iml
deleted file mode 100644
index f08604b..0000000
--- a/.idea/GeneralSolitaireSolver.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/Solvitaire.iml b/.idea/Solvitaire.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/Solvitaire.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 882d001..98d02a1 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
-
\ No newline at end of file
+
diff --git a/README.md b/README.md
index db744db..2e9f657 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# General Solitaire Solver
+# Solvitaire
A solver for a variety of single-player, perfect
information solitaire card games.
--
cgit v1.2.1
From a70e9a857ece06da65d7ce7c6d271dcd39968d55 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Wed, 11 Oct 2017 11:00:50 +0100
Subject: Add basic logging to project
---
src/main/main.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 0c9e38a..54bc493 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -1,9 +1,19 @@
#include
#include
#include
+#include
+
+namespace logging = boost::log;
int main()
{
+
+#ifndef NDEBUG
+ BOOST_LOG_TRIVIAL(debug) << "Log debug";
+#endif
+ BOOST_LOG_TRIVIAL(info) << "Log info";
+ BOOST_LOG_TRIVIAL(warning) << "Log warning";
+
std::string hello( "Hello, world!\n" );
BOOST_FOREACH( char ch, hello )
--
cgit v1.2.1
From 6132bc9f3a8b7ce9dc1a17dd027166170697943b Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Wed, 11 Oct 2017 11:30:29 +0100
Subject: Add logging macros
---
src/main/main.cpp | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 54bc493..3b4b00b 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -3,16 +3,21 @@
#include
#include
-namespace logging = boost::log;
+#if defined NDEBUG
+ #define LOG_DEBUG(msg)
+#else
+ #define LOG_DEBUG(msg) BOOST_LOG_TRIVIAL(debug) << msg
+#endif
+#define LOG_INFO(msg) BOOST_LOG_TRIVIAL(info) << msg
+#define LOG_WARNING(msg) BOOST_LOG_TRIVIAL(warning) << msg
+#define LOG_ERROR(msg) BOOST_LOG_ERROR(error) << msg
int main()
{
-#ifndef NDEBUG
- BOOST_LOG_TRIVIAL(debug) << "Log debug";
-#endif
- BOOST_LOG_TRIVIAL(info) << "Log info";
- BOOST_LOG_TRIVIAL(warning) << "Log warning";
+ LOG_DEBUG("Log debug");
+ LOG_INFO("Log info");
+ LOG_WARNING("Log warning");
std::string hello( "Hello, world!\n" );
--
cgit v1.2.1
From c04bec7b528aa3fe953f6a9b838c771d02c4f3b8 Mon Sep 17 00:00:00 2001
From: thecharlesblake
Date: Thu, 12 Oct 2017 11:19:23 +0100
Subject: Basic Black Hole solver
---
CMakeLists.txt | 2 +-
src/main/Card.cpp | 25 +++++++++++++
src/main/Card.h | 19 ++++++++++
src/main/main.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++----
4 files changed, 144 insertions(+), 9 deletions(-)
create mode 100644 src/main/Card.cpp
create mode 100644 src/main/Card.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b33bf3d..196acdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD 14)
## source files ###############################################################
###############################################################################
-set(sources src/main/main.cpp)
+set(sources src/main/main.cpp src/main/Card.h src/main/Card.cpp)
set(sources_test src/test/all_tests.cpp src/test/main_test.cpp)
###############################################################################
diff --git a/src/main/Card.cpp b/src/main/Card.cpp
new file mode 100644
index 0000000..ead2fd5
--- /dev/null
+++ b/src/main/Card.cpp
@@ -0,0 +1,25 @@
+//
+// Created by thecharlesblake on 10/11/17.
+//
+
+#include "Card.h"
+#include
+
+Card::Card(const int r, const std::string s): rank(r), suit(s) {}
+
+std::ostream & operator<<(std::ostream & Str, Card const & c) {
+ std::string r;
+ if (c.rank == 1) {
+ r = "A";
+ } else if (c.rank <= 10) {
+ r = std::to_string(c.rank);
+ } else if (c.rank == 11) {
+ r = "J";
+ } else if (c.rank == 12) {
+ r = "Q";
+ } else if (c.rank == 13) {
+ r = "K";
+ }
+
+ return Str << r << c.suit;
+}
\ No newline at end of file
diff --git a/src/main/Card.h b/src/main/Card.h
new file mode 100644
index 0000000..651df71
--- /dev/null
+++ b/src/main/Card.h
@@ -0,0 +1,19 @@
+//
+// Created by thecharlesblake on 10/11/17.
+//
+
+#ifndef SOLITAIRE_PIP_CARD_H
+#define SOLITAIRE_PIP_CARD_H
+
+#include
+
+struct Card {
+ Card(const int, const std::string);
+ const int rank;
+ const std::string suit;
+};
+
+std::ostream & operator<<(std::ostream &, Card const &);
+
+
+#endif //SOLITAIRE_PIP_CARD_H
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 3b4b00b..1b75252 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -1,6 +1,10 @@
#include
#include
-#include
+#include
+#include