Use sources.cmake for the bssl tool

Bug: 542
Change-Id: I94684f2398a28792cc0a31c8e776eecac8cc3cba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61305
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f3eb37..1529526 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -515,7 +515,6 @@
 add_subdirectory(crypto)
 add_subdirectory(ssl)
 add_subdirectory(ssl/test)
-add_subdirectory(tool)
 add_subdirectory(util/fipstools)
 add_subdirectory(util/fipstools/acvp/modulewrapper)
 add_subdirectory(decrepit)
@@ -572,12 +571,17 @@
   CXX_STANDARD_REQUIRED YES
   COMPILE_FLAGS "${PKI_CXX_FLAGS}")
 
+add_executable(bssl ${BSSL_SOURCES})
+install_if_enabled(TARGETS bssl DESTINATION ${INSTALL_DESTINATION_DEFAULT})
+target_link_libraries(bssl ssl crypto)
+
 # Historically, targets were built in subdirectories. For compatibility with
 # existing tools, we, for now, copy the targets into the subdirectories. This
 # will be removed sometime in 2024.
 copy_post_build(crypto crypto_test urandom_test)
 copy_post_build(ssl ssl_test)
 copy_post_build(decrepit decrepit_test)
+copy_post_build(tool bssl)
 
 if(FUZZ)
   if(LIBFUZZER_FROM_DEPS)
diff --git a/sources.cmake b/sources.cmake
index 3823186..8179d28 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -424,4 +424,26 @@
   crypto/test/file_test_gtest.cc
   crypto/test/test_util.cc
   crypto/test/wycheproof_util.cc
-)
\ No newline at end of file
+)
+
+set(
+  BSSL_SOURCES
+
+  tool/args.cc
+  tool/ciphers.cc
+  tool/client.cc
+  tool/const.cc
+  tool/digest.cc
+  tool/fd.cc
+  tool/file.cc
+  tool/generate_ech.cc
+  tool/generate_ed25519.cc
+  tool/genrsa.cc
+  tool/pkcs12.cc
+  tool/rand.cc
+  tool/server.cc
+  tool/sign.cc
+  tool/speed.cc
+  tool/tool.cc
+  tool/transport_common.cc
+)
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
deleted file mode 100644
index 5047108..0000000
--- a/tool/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-add_executable(
-  bssl
-
-  args.cc
-  ciphers.cc
-  client.cc
-  const.cc
-  digest.cc
-  fd.cc
-  file.cc
-  generate_ech.cc
-  generate_ed25519.cc
-  genrsa.cc
-  pkcs12.cc
-  rand.cc
-  server.cc
-  sign.cc
-  speed.cc
-  tool.cc
-  transport_common.cc
-)
-install_if_enabled(TARGETS bssl DESTINATION ${INSTALL_DESTINATION_DEFAULT})
-target_link_libraries(bssl ssl crypto)
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index eef4ef9..642d4d5 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -759,7 +759,6 @@
                     FindCFiles(os.path.join('src', 'third_party', 'fiat'), NoTestsNorFIPSFragments))
   fips_fragments = FindCFiles(os.path.join('src', 'crypto', 'fipsmodule'), OnlyFIPSFragments)
   ssl_source_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
-  tool_c_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
   tool_h_files = FindHeaderFiles(os.path.join('src', 'tool'), AllFiles)
 
   # BCM shared library C files
@@ -837,7 +836,7 @@
       'ssl_headers': ssl_h_files,
       'ssl_internal_headers': ssl_internal_h_files,
       'ssl_test': PrefixWithSrc(cmake['SSL_TEST_SOURCES']),
-      'tool': tool_c_files,
+      'tool': PrefixWithSrc(cmake['BSSL_SOURCES']),
       'tool_headers': tool_h_files,
       'test_support': PrefixWithSrc(cmake['TEST_SUPPORT_SOURCES']),
       'test_support_headers': test_support_h_files,