From 1c14830944bf2509a4bc29dc6da10ec5cd1edd87 Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:26:54 -0700
Subject: [PATCH 01/10] Create cmake.yml

---
 .github/workflows/cmake.yml | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 .github/workflows/cmake.yml

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
new file mode 100644
index 0000000..d11d132
--- /dev/null
+++ b/.github/workflows/cmake.yml
@@ -0,0 +1,37 @@
+name: CMake
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+env:
+  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
+  BUILD_TYPE: Release
+
+jobs:
+  build:
+    # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
+    # You can convert this to a matrix build if you need cross-platform coverage.
+    # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Configure CMake
+      # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
+      # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
+      run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
+
+    - name: Build
+      # Build your program with the given configuration
+      run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
+
+    - name: Test
+      working-directory: ${{github.workspace}}/build
+      # Execute tests defined by the CMake configuration.  
+      # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
+      run: ctest -C ${{env.BUILD_TYPE}}
+      

From 06c56f6832ac400c69fc1bd45706c551ffe1a8f4 Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:30:55 -0700
Subject: [PATCH 02/10] FIx CI to configure with tests, example

---
 .github/workflows/cmake.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index d11d132..ec03b9f 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -23,7 +23,7 @@ jobs:
     - name: Configure CMake
       # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
       # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
-      run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
+      run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWITH_TESTS=ON -DWITH_EXAMPLE=ON
 
     - name: Build
       # Build your program with the given configuration

From 7b5e13852be2564471182ff4d297f766976e2240 Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:45:51 -0700
Subject: [PATCH 03/10] Fix cmakefile to enable testing so CI can run tests
 through ctest

---
 CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28da614..7a07f69 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1)
 project(docopt.cpp VERSION 0.6.2)
 
 include(GNUInstallDirs)
+enable_testing()
 
 #============================================================================
 # Settable options

From 278ee5f652446ab18c9aedb4f811a6f5e7c37b21 Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:48:08 -0700
Subject: [PATCH 04/10] Fix the syntax of add_test to add the test properly to
 cmake

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a07f69..858b006 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ if(WITH_TESTS)
 			"${CMAKE_CURRENT_BINARY_DIR}/run_tests"
 			ESCAPE_QUOTES
 	)
-	add_test("Testcases docopt" ${TESTPROG})
+	add_test(NAME "Testcases docopt" COMMAND ${TESTPROG})
 endif()
 
 #============================================================================

From fe9a3fb966352a9b7287a8387d0a7c88b8fe1e1b Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:49:14 -0700
Subject: [PATCH 05/10] FIx test name as spaces aren't allowed

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 858b006..2decb68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ if(WITH_TESTS)
 			"${CMAKE_CURRENT_BINARY_DIR}/run_tests"
 			ESCAPE_QUOTES
 	)
-	add_test(NAME "Testcases docopt" COMMAND ${TESTPROG})
+	add_test(NAME Testcases COMMAND ${TESTPROG})
 endif()
 
 #============================================================================

From dc0a1f2d40e5d824efa207c57ff5dcc0be2978e0 Mon Sep 17 00:00:00 2001
From: Edgar Friendly <thelema@users.noreply.github.com>
Date: Sat, 26 Mar 2022 13:51:59 -0700
Subject: [PATCH 06/10] Further adjust how tests are run to make readme

---
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2decb68..f88c2ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,9 @@ if(WITH_TESTS)
 			"${CMAKE_CURRENT_BINARY_DIR}/run_tests"
 			ESCAPE_QUOTES
 	)
-	add_test(NAME Testcases COMMAND ${TESTPROG})
+	add_test(NAME Testcases_docopt 
+	COMMAND python run_tests.py 
+	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 endif()
 
 #============================================================================

From e771fb900e01479fb6a873a3ff9f5ec9f9f4d51b Mon Sep 17 00:00:00 2001
From: Eric Norige <eric.norige@gmail.com>
Date: Sat, 26 Mar 2022 14:02:24 -0700
Subject: [PATCH 07/10] Fix command to run tests (readme was wrong)

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f88c2ba..029e431 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -84,7 +84,7 @@ if(WITH_TESTS)
 			ESCAPE_QUOTES
 	)
 	add_test(NAME Testcases_docopt 
-	COMMAND python run_tests.py 
+	COMMAND python "${CMAKE_CURRENT_BINARY_DIR}/run_tests"
 	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 endif()
 

From 0e7ed0617c5839fea37fcd1745a7254d5c89859b Mon Sep 17 00:00:00 2001
From: Eric Norige <eric.norige@gmail.com>
Date: Sat, 26 Mar 2022 14:04:27 -0700
Subject: [PATCH 08/10] Add build/ and .vscode to .gitignore

---
 .gitignore | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.gitignore b/.gitignore
index 6d7eb1c..b8ca4a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,9 @@ docopt-config-version.cmake
 
 # Files configured by CMake
 run_tests
+
+# cmake build directory
+build/
+
+# VS Code directory
+.vscode/
\ No newline at end of file

From a11b9ffeddd8b18b1697fb3f5ed3ff6b45107548 Mon Sep 17 00:00:00 2001
From: Eric Norige <eric.norige@gmail.com>
Date: Sat, 26 Mar 2022 14:14:31 -0700
Subject: [PATCH 09/10] Add dependency on python to WITH_TESTS

This is borrowed/stolen from @ClausKlein's commit
---
 CMakeLists.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 029e431..4b63001 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,6 +74,7 @@ endif()
 # Tests
 #============================================================================
 if(WITH_TESTS)
+	find_program(PYTHON python REQUIRED)
 	set(TESTPROG "${CMAKE_CURRENT_BINARY_DIR}/run_testcase")
 	set(TESTCASES "${PROJECT_SOURCE_DIR}/testcases.docopt")
 	add_executable(run_testcase run_testcase.cpp)
@@ -84,7 +85,7 @@ if(WITH_TESTS)
 			ESCAPE_QUOTES
 	)
 	add_test(NAME Testcases_docopt 
-	COMMAND python "${CMAKE_CURRENT_BINARY_DIR}/run_tests"
+	COMMAND ${PYTHON} "${CMAKE_CURRENT_BINARY_DIR}/run_tests"
 	WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 endif()
 

From 044b16e2114f400c335c61adce2f3d67a377b8ba Mon Sep 17 00:00:00 2001
From: Eric Norige <eric.norige@gmail.com>
Date: Fri, 1 Apr 2022 22:18:53 -0700
Subject: [PATCH 10/10] Remove REQUIRED keyword not suported in old cmake

---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4b63001..bf733f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,7 +74,7 @@ endif()
 # Tests
 #============================================================================
 if(WITH_TESTS)
-	find_program(PYTHON python REQUIRED)
+	find_program(PYTHON python)
 	set(TESTPROG "${CMAKE_CURRENT_BINARY_DIR}/run_testcase")
 	set(TESTCASES "${PROJECT_SOURCE_DIR}/testcases.docopt")
 	add_executable(run_testcase run_testcase.cpp)