Fix the generated CMake build
This fixes two issues introduced in
0e68520eb27b1f37038e9d0772cfee1d015b50c3. First, libssl never had a
dependency on libcrypto, so the include directory did not get passed
along. Second, although this build (unlike the other CMake build)
doesn't define an install target, gRPC includes it and then pulls it
into its own install target. That then runs afoul of CMake's check
against include directories in install targets.
To avoid this, condition the src/include directory on
$<BUILD_INTERFACE:...> but omit a corresponding
$<INSTALL_INTERFACE:...>. Since we're not the ones providing an install
target, we don't actually know the value to use.
Per [0], using the generator expression means we need to manually make
it absolute ourselves.
[0] https://cmake.org/cmake/help/latest/command/target_include_directories.html
Change-Id: I2a25cc8382116c5957d94f65641220559b7af87d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/57685
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/util/generate_build_files.py b/util/generate_build_files.py
index aec36be..386910b 100644
--- a/util/generate_build_files.py
+++ b/util/generate_build_files.py
@@ -489,7 +489,7 @@
'''
- def PrintLibrary(self, out, name, files):
+ def PrintLibrary(self, out, name, files, libs=[]):
out.write('add_library(\n')
out.write(' %s\n\n' % name)
@@ -497,6 +497,8 @@
out.write(' %s\n' % PathOf(f))
out.write(')\n\n')
+ if libs:
+ out.write('target_link_libraries(%s %s)\n\n' % (name, ' '.join(libs)))
def PrintExe(self, out, name, files, libs):
out.write('add_executable(\n')
@@ -541,8 +543,8 @@
self.PrintLibrary(cmake, 'crypto',
files['crypto'] + ['${CRYPTO_SOURCES_ASM_USED}'])
- cmake.write('target_include_directories(crypto PUBLIC src/include)\n')
- self.PrintLibrary(cmake, 'ssl', files['ssl'])
+ cmake.write('target_include_directories(crypto PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/include>)\n\n')
+ self.PrintLibrary(cmake, 'ssl', files['ssl'], ['crypto'])
self.PrintExe(cmake, 'bssl', files['tool'], ['ssl', 'crypto'])
cmake.write(