Skip to content

Commit

Permalink
Specify -Iinclude with the crypto target.
Browse files Browse the repository at this point in the history
It's unclear to me whether doing it target-by-target is an improvement
in crypto/fipsmodule, but this otherwise does seem a bit tidier. This
aligns with CMake's documentation and "modern CMake" which prefers this
pattern.

Change-Id: I36c81842bff8b36eeaaf5dd3e0695fb45f3376c9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/56585
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
  • Loading branch information
davidben authored and Boringssl LUCI CQ committed Feb 14, 2023
1 parent de12e3c commit 0e68520
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 55 deletions.
4 changes: 1 addition & 3 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../include)

add_subdirectory(fipsmodule)
add_subdirectory(test)

Expand Down Expand Up @@ -298,7 +296,7 @@ endif()
if(OPENSSL_NASM)
target_sources(crypto PRIVATE ${CRYPTO_SOURCES_NASM})
endif()
target_include_directories(crypto INTERFACE
target_include_directories(crypto PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
Expand Down
16 changes: 5 additions & 11 deletions crypto/fipsmodule/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../../include)

perlasm(BCM_SOURCES aarch64 aesv8-armv8 aes/asm/aesv8-armx.pl)
perlasm(BCM_SOURCES aarch64 aesv8-gcm-armv8 modes/asm/aesv8-gcm-armv8.pl)
perlasm(BCM_SOURCES aarch64 armv8-mont bn/asm/armv8-mont.pl)
Expand Down Expand Up @@ -67,9 +65,8 @@ if(FIPS_DELOCATE)

bcm.c
)

add_dependencies(bcm_c_generated_asm global_target)

target_include_directories(bcm_c_generated_asm PRIVATE ../../include)
set_target_properties(bcm_c_generated_asm PROPERTIES COMPILE_OPTIONS "-S")
set_target_properties(bcm_c_generated_asm PROPERTIES POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -104,9 +101,7 @@ if(FIPS_DELOCATE)

bcm-delocated.S
)

add_dependencies(bcm_hashunset global_target)

set_target_properties(bcm_hashunset PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(bcm_hashunset PROPERTIES LINKER_LANGUAGE C)

Expand All @@ -131,9 +126,8 @@ if(FIPS_DELOCATE)

fips_shared_support.c
)

add_dependencies(fipsmodule global_target)

target_include_directories(fipsmodule PRIVATE ../../include)
set_target_properties(fipsmodule PROPERTIES LINKER_LANGUAGE C)
elseif(FIPS_SHARED)
if(NOT BUILD_SHARED_LIBS)
Expand All @@ -147,8 +141,8 @@ elseif(FIPS_SHARED)

fips_shared_support.c
)

add_dependencies(fipsmodule global_target)
target_include_directories(fipsmodule PRIVATE ../../include)

add_library(
bcm_library
Expand All @@ -158,8 +152,8 @@ elseif(FIPS_SHARED)
bcm.c
${BCM_SOURCES_ASM_USED}
)

add_dependencies(bcm_library global_target)
target_include_directories(bcm_library PRIVATE ../../include)

add_custom_command(
OUTPUT bcm.o
Expand All @@ -179,6 +173,6 @@ else()
fips_shared_support.c
${BCM_SOURCES_ASM_USED}
)

add_dependencies(fipsmodule global_target)
target_include_directories(fipsmodule PRIVATE ../../include)
endif()
6 changes: 0 additions & 6 deletions decrepit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../include)

add_library(
decrepit

Expand All @@ -21,9 +19,7 @@ add_library(
x509/x509_decrepit.c
xts/xts.c
)

add_dependencies(decrepit global_target)

target_link_libraries(decrepit crypto ssl)

add_executable(
Expand All @@ -38,9 +34,7 @@ add_executable(

$<TARGET_OBJECTS:boringssl_gtest_main>
)

add_dependencies(decrepit_test global_target)

target_link_libraries(decrepit_test test_support_lib boringssl_gtest decrepit
crypto)
add_dependencies(all_tests decrepit_test)
5 changes: 1 addition & 4 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
include_directories(../include)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-prototypes")

macro(fuzzer name)
add_executable(${name} ${name}.cc)
add_dependencies(${name} global_target)
target_compile_options(${name} PRIVATE "-Wno-missing-prototypes")
target_link_libraries(${name} crypto ${ARGN})
if(LIBFUZZER_FROM_DEPS)
set_target_properties(${name} PROPERTIES LINK_FLAGS "-fsanitize=fuzzer-no-link")
Expand Down
12 changes: 4 additions & 8 deletions rust/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# additional interop for things like macros and inlined functions
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
add_library(
rust_wrapper
STATIC
rust_wrapper.c
)
# Additional interop for things like macros and inlined functions.
add_library(rust_wrapper STATIC rust_wrapper.c)
target_link_libraries(rust_wrapper crypto)

# generate architecture specific wrappers
# Generate architecture-specific wrappers.
set(WRAPPER_TARGET ${CMAKE_BINARY_DIR}/rust/src/wrapper_${RUST_BINDINGS}.rs)
set(COMMAND ${BINDGEN_EXECUTABLE} "wrapper.h"
-o ${WRAPPER_TARGET}
Expand Down
13 changes: 3 additions & 10 deletions ssl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../include)

add_library(
ssl

Expand Down Expand Up @@ -41,19 +39,16 @@ add_library(
tls13_enc.cc
tls13_server.cc
)
target_include_directories(ssl INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Although libssl also provides headers that require an include directory, the
# flag is already specified by libcrypto, so we omit target_include_directories
# here.
install(TARGETS ssl EXPORT OpenSSLTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
set_property(TARGET ssl PROPERTY EXPORT_NAME SSL)

add_dependencies(ssl global_target)

target_link_libraries(ssl crypto)

add_executable(
Expand All @@ -65,8 +60,6 @@ add_executable(

$<TARGET_OBJECTS:boringssl_gtest_main>
)

add_dependencies(ssl_test global_target)

target_link_libraries(ssl_test test_support_lib boringssl_gtest ssl crypto)
add_dependencies(all_tests ssl_test)
2 changes: 0 additions & 2 deletions ssl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../../include)

add_executable(
bssl_shim

Expand Down
2 changes: 0 additions & 2 deletions tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(../include)

add_executable(
bssl

Expand Down
3 changes: 0 additions & 3 deletions util/fipstools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
include_directories(../../include)

if(FIPS)
add_executable(
test_fips

test_fips.c
)

add_dependencies(test_fips global_target)
target_link_libraries(test_fips crypto)
endif()
4 changes: 0 additions & 4 deletions util/fipstools/acvp/modulewrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
include_directories(../../../../include)

if(FIPS)
add_executable(
modulewrapper

main.cc
modulewrapper.cc
)

add_dependencies(modulewrapper global_target)

target_link_libraries(modulewrapper crypto)
endif()
3 changes: 1 addition & 2 deletions util/generate_build_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,6 @@ def __init__(self):
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()
include_directories(src/include)
'''

def PrintLibrary(self, out, name, files):
Expand Down Expand Up @@ -543,6 +541,7 @@ def WriteFiles(self, files, asm_outputs):

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'])
self.PrintExe(cmake, 'bssl', files['tool'], ['ssl', 'crypto'])

Expand Down

0 comments on commit 0e68520

Please sign in to comment.