Add parallel bundle tests to CMake build

This converts the bundle_adjustment_test to the parallel
version with multiple binaries, as is already in place for
the Bazel build. Additionally, since there is no longer a
need for it, this deletes bundle_adjustment_test.cc.

The test suite now runs on my 6 year old desktop in ~60 seconds!

Change-Id: Ib4a59f8749e823f697e6da5d303977d284303ae3
diff --git a/internal/ceres/generate_bundle_adjustment_tests.py b/internal/ceres/generate_bundle_adjustment_tests.py
index 97b47b0..dcac22a 100644
--- a/internal/ceres/generate_bundle_adjustment_tests.py
+++ b/internal/ceres/generate_bundle_adjustment_tests.py
@@ -74,7 +74,7 @@
   ThreadedSolverConfig='threads',
 )
 
-BUNDLE_ADJUSTMENT_TEST_TEMPLATE = (
+COPYRIGHT_HEADER = (
 """// Ceres Solver - A fast non-linear least squares minimizer
 // Copyright 2018 Google Inc. All rights reserved.
 // http://ceres-solver.org/
@@ -108,9 +108,11 @@
 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
 // THIS FILE IS AUTOGENERATED. DO NOT EDIT.
-//=========================================
+// ========================================
 //
-// This file is generated using generate_bundle_adjustment_tests.py.
+// This file is generated using generate_bundle_adjustment_tests.py.""")
+
+BUNDLE_ADJUSTMENT_TEST_TEMPLATE = (COPYRIGHT_HEADER + """
 
 #include "bundle_adjustment_test_util.h"
 %(preprocessor_conditions_begin)s
@@ -219,14 +221,28 @@
   # All done.
   print 'Generated', filename
 
+  return filename
+
 
 if __name__ == '__main__':
   # Iterate over all the possible configurations and generate the tests.
+  generated_files = []
   for linear_solver, sparse_backend, preconditioner in SOLVER_CONFIGS:
     for ordering in ORDERINGS:
       for thread_config in THREAD_CONFIGS:
-        generate_bundle_test(linear_solver,
-                             sparse_backend,
-                             preconditioner,
-                             ordering,
-                             thread_config)
+        generated_files.append(
+            generate_bundle_test(linear_solver,
+                                 sparse_backend,
+                                 preconditioner,
+                                 ordering,
+                                 thread_config))
+
+  # Generate the CMakeLists.txt as well.
+  with open('generated_bundle_adjustment_tests/CMakeLists.txt', 'w') as fd:
+    fd.write(COPYRIGHT_HEADER.replace('//', '#').replace('http:#', 'http://'))
+    fd.write('\n')
+    fd.write('\n')
+    for generated_file in generated_files:
+      fd.write('ceres_test(%s)\n' %
+               generated_file.split('/')[1].replace('_test.cc', ''))
+