Use sources.cmake for pki and pki_test
This achieves much of the same goals as
https://boringssl-review.googlesource.com/c/boringssl/+/61245, but
reuses the existing source.cmake parser in generate_build_files.py.
There are two practical differences here:
First, CMake knows that, if it sees include(sources.cmake), it should
add sources.cmake as a dependency of build.ninja, and re-run cmake if
source.cmake changes. It does not know this for file(STRINGS). This can
be fixed with CMAKE_CONFIGURE_DEPENDS, but since we already have this,
may as well use it.
Second, sources.cmake wants paths rooted at the top-level BoringSSL
source directory, which means we want to define the targets at the top
level, rather than in subdirectories. While it will make the top-level
CMakeLists.txt larger, I think this is a good move:
- ./build/crypto_test --gtest_filter=... is just less annoying to type
than ./build/crypto/crypto_test --gtest_filter=...
- It will (eventually) mean libcrypto.a lives at build/libcrypto.a
instead of build/crypto/libcrypto.a. This means we can pass a single
-L parameter when building things against BoringSSL, without relying
on the install target.
- It aligns with the generated CMake build. I would like, long-term, to
stop maintaining multiple CMake builds, and the generated one seems to
have a better convention. And one that will be more disruptive to
others if we change it.
- Top-level-rooted paths are more convenient for generate_build_files.py
to work with, because that's what we want to output.
As I get further along in 542, I expect I'll move this once again,
possibly to some JSON file, because I'll need my new pregenerate tool to
parse it (and we'll no longer be constrained by what's easy to consume
in CMake), but use this for now.
Bug: 542
Change-Id: I1e8b894057264da5d7624a1fbb92f9e1198ea38e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61266
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index de12398..63e65ef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -519,7 +519,27 @@
add_subdirectory(util/fipstools)
add_subdirectory(util/fipstools/acvp/modulewrapper)
add_subdirectory(decrepit)
-add_subdirectory(pki)
+
+if(APPLE)
+ set(PKI_CXX_FLAGS "-fno-aligned-new")
+endif()
+
+add_library(pki ${PKI_SOURCES})
+target_compile_definitions(pki PRIVATE _BORINGSSL_LIBPKI_)
+target_link_libraries(pki crypto)
+
+add_executable(pki_test ${PKI_TEST_SOURCES})
+target_compile_definitions(pki_test PRIVATE _BORINGSSL_LIBPKI_)
+target_link_libraries(pki_test test_support_lib boringssl_gtest_main pki crypto)
+add_dependencies(all_tests pki_test)
+
+# The PKI library requires C++17.
+set_target_properties(
+ pki pki_test
+ PROPERTIES
+ CXX_STANDARD 17
+ CXX_STANDARD_REQUIRED YES
+ COMPILE_FLAGS "${PKI_CXX_FLAGS}")
if(FUZZ)
if(LIBFUZZER_FROM_DEPS)
diff --git a/pki/CMakeLists.txt b/pki/CMakeLists.txt
deleted file mode 100644
index b808282..0000000
--- a/pki/CMakeLists.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-if(APPLE)
- set(PKI_CXX_FLAGS "-fno-aligned-new")
-endif()
-
-file(STRINGS pki_sources.txt pki_sources)
-file(STRINGS pki_test_sources.txt pki_test_sources)
-
-add_library(
- pki
-
- ${pki_sources}
-)
-set_target_properties(
- pki
- PROPERTIES
- CXX_STANDARD 17
- CXX_STANDARD_REQUIRED YES
- COMPILE_FLAGS "${PKI_CXX_FLAGS}")
-target_compile_definitions(pki PRIVATE _BORINGSSL_LIBPKI_)
-target_link_libraries(pki ssl crypto)
-
-add_executable(
- pki_test
-
- ${pki_test_sources}
-# encode_values_unittest.cc # Currently does a bunch of time goo..
-# ocsp_unittest.cc # Not sure we will keep this here..
-)
-set_target_properties(
- pki_test
- PROPERTIES
- CXX_STANDARD 17
- CXX_STANDARD_REQUIRED YES
- COMPILE_FLAGS "${PKI_CXX_FLAGS}")
-target_compile_definitions(
- pki_test
- PRIVATE
- _BORINGSSL_LIBPKI_)
-target_link_libraries(pki_test test_support_lib boringssl_gtest_main pki ssl crypto)
-add_dependencies(all_tests pki_test)
-
-
diff --git a/pki/pki_sources.txt b/pki/pki_sources.txt
deleted file mode 100644
index e9f39f4..0000000
--- a/pki/pki_sources.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-fillins/ip_address.cc
-fillins/utf_string_conversions.cc
-fillins/string_util.cc
-fillins/base64.cc
-fillins/openssl_util.cc
-string_util.cc
-trust_store.cc
-trust_store_collection.cc
-parse_certificate.cc
-parsed_certificate.cc
-parser.cc
-parse_values.cc
-parse_name.cc
-parsed_certificate.cc
-name_constraints.cc
-input.cc
-tag.cc
-cert_errors.cc
-general_names.cc
-pem.cc
-crl.cc
-revocation_util.cc
-encode_values.cc
-verify_name_match.cc
-cert_errors.cc
-common_cert_errors.cc
-parse_certificate.cc
-parsed_certificate.cc
-extended_key_usage.cc
-certificate_policies.cc
-verify_certificate_chain.cc
-verify_signed_data.cc
-signature_algorithm.cc
-cert_error_id.cc
-cert_error_params.cc
-trust_store.cc
-trust_store_collection.cc
-trust_store_in_memory.cc
-simple_path_builder_delegate.cc
-cert_issuer_source_static.cc
-path_builder.cc
diff --git a/pki/pki_test_sources.txt b/pki/pki_test_sources.txt
deleted file mode 100644
index 707206c..0000000
--- a/pki/pki_test_sources.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-fillins/path_service.cc
-fillins/file_util.cc
-test_helpers.cc
-string_util_unittest.cc
-parser_unittest.cc
-parse_values_unittest.cc
-input_unittest.cc
-signature_algorithm_unittest.cc
-extended_key_usage_unittest.cc
-parse_name_unittest.cc
-verify_name_match_unittest.cc
-verify_signed_data_unittest.cc
-parse_certificate_unittest.cc
-parsed_certificate_unittest.cc
-simple_path_builder_delegate_unittest.cc
-trust_store_collection_unittest.cc
-certificate_policies_unittest.cc
-verify_certificate_chain_unittest.cc
-nist_pkits_unittest.cc
-path_builder_pkits_unittest.cc
-name_constraints_unittest.cc
-cert_issuer_source_static_unittest.cc
-path_builder_unittest.cc
-mock_signature_verify_cache.cc
-path_builder_verify_certificate_chain_unittest.cc
-verify_certificate_chain_pkits_unittest.cc
diff --git a/sources.cmake b/sources.cmake
index 5c7e881..fc0f811 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -238,3 +238,82 @@
third_party/wycheproof_testvectors/x25519_test.txt
third_party/wycheproof_testvectors/xchacha20_poly1305_test.txt
)
+
+set(
+ PKI_SOURCES
+
+ pki/cert_error_id.cc
+ pki/cert_error_params.cc
+ pki/cert_errors.cc
+ pki/cert_errors.cc
+ pki/cert_issuer_source_static.cc
+ pki/certificate_policies.cc
+ pki/common_cert_errors.cc
+ pki/crl.cc
+ pki/encode_values.cc
+ pki/extended_key_usage.cc
+ pki/fillins/base64.cc
+ pki/fillins/ip_address.cc
+ pki/fillins/openssl_util.cc
+ pki/fillins/string_util.cc
+ pki/fillins/utf_string_conversions.cc
+ pki/general_names.cc
+ pki/input.cc
+ pki/name_constraints.cc
+ pki/parse_certificate.cc
+ pki/parse_certificate.cc
+ pki/parse_name.cc
+ pki/parse_values.cc
+ pki/parsed_certificate.cc
+ pki/parsed_certificate.cc
+ pki/parsed_certificate.cc
+ pki/parser.cc
+ pki/path_builder.cc
+ pki/pem.cc
+ pki/revocation_util.cc
+ pki/signature_algorithm.cc
+ pki/simple_path_builder_delegate.cc
+ pki/string_util.cc
+ pki/tag.cc
+ pki/trust_store_collection.cc
+ pki/trust_store_collection.cc
+ pki/trust_store_in_memory.cc
+ pki/trust_store.cc
+ pki/trust_store.cc
+ pki/verify_certificate_chain.cc
+ pki/verify_name_match.cc
+ pki/verify_signed_data.cc
+)
+
+set(
+ PKI_TEST_SOURCES
+
+ pki/cert_issuer_source_static_unittest.cc
+ pki/certificate_policies_unittest.cc
+ pki/encode_values_unittest.cc
+ pki/extended_key_usage_unittest.cc
+ pki/fillins/file_util.cc
+ pki/fillins/path_service.cc
+ pki/input_unittest.cc
+ pki/mock_signature_verify_cache.cc
+ pki/name_constraints_unittest.cc
+ pki/nist_pkits_unittest.cc
+ # pki/ocsp_unittest.cc # Not sure we will keep this here..
+ pki/parse_certificate_unittest.cc
+ pki/parse_name_unittest.cc
+ pki/parse_values_unittest.cc
+ pki/parsed_certificate_unittest.cc
+ pki/parser_unittest.cc
+ pki/path_builder_pkits_unittest.cc
+ pki/path_builder_unittest.cc
+ pki/path_builder_verify_certificate_chain_unittest.cc
+ pki/signature_algorithm_unittest.cc
+ pki/simple_path_builder_delegate_unittest.cc
+ pki/string_util_unittest.cc
+ pki/test_helpers.cc
+ pki/trust_store_collection_unittest.cc
+ pki/verify_certificate_chain_pkits_unittest.cc
+ pki/verify_certificate_chain_unittest.cc
+ pki/verify_name_match_unittest.cc
+ pki/verify_signed_data_unittest.cc
+)
diff --git a/util/all_tests.json b/util/all_tests.json
index 18d4d94..0a5bb40 100644
--- a/util/all_tests.json
+++ b/util/all_tests.json
@@ -47,6 +47,6 @@
"cmd": ["ssl/ssl_test"]
},
{
- "cmd": ["pki/pki_test"]
+ "cmd": ["pki_test"]
}
]