@@ -19,6 +19,22 @@ set(REPORTED_PKGCONFIG_VERSION "1.1.1")
1919# Defer enabling C and CXX languages.
2020project (AWSLC VERSION "${SOFTWARE_VERSION} " LANGUAGES NONE )
2121
22+ option (BUILD_TESTING "Build all test targets for AWS-LC" ON )
23+ option (BUILD_LIBSSL "Build libssl for AWS-LC" ON )
24+ option (BUILD_TOOL "Build bssl tool for AWS-LC" ON )
25+ option (DISABLE_PERL "Disable Perl for AWS-LC" OFF )
26+ option (DISABLE_GO "Disable Go for AWS-LC" OFF )
27+ # Keeping this flag for now, for compatibility with existing build configs.
28+ option (ENABLE_FIPS_ENTROPY_CPU_JITTER "Enable FIPS entropy source: CPU Jitter" OFF )
29+ option (ENABLE_DATA_INDEPENDENT_TIMING "Enable automatic setting/resetting Data-Independent Timing
30+ (DIT) flag in cryptographic functions. Currently only applicable to Arm64 (except on Windows)" OFF )
31+ option (ENABLE_PRE_SONAME_BUILD "Build AWS-LC without SONAME configuration for shared library builds" ON )
32+ option (ENABLE_SOURCE_MODIFICATION "Allow the build to update files in the source directory. This is typically done to update versioning." ON )
33+ option (DISABLE_CPU_JITTER_ENTROPY "Disable usage of CPU Jitter Entropy as an entropy source. This option cannot be used with the FIPS build. With this configuration, randomness generation might not use two independent entropy sources." OFF )
34+ option (GENERATE_RUST_BINDINGS "Generate Rust bindings using bindgen-cli" OFF )
35+ option (ENABLE_DIST_PKG "Enables a set of packaging that take highest presedence to any other packaging configuration i.e. ENABLE_PRE_SONAME_BUILD" OFF )
36+ option (ENABLE_DIST_PKG_OPENSSL_SHIM "Controls whether the OpenSSL shim componenets are installed when ENABLE_DIST_PKG is enabled" OFF )
37+
2238if (MSVC )
2339 # On Windows, prefer cl over gcc if both are available. By default most of
2440 # the CMake generators prefer gcc, even on Windows.
@@ -81,36 +97,47 @@ function(target_add_awslc_include_paths)
8197 target_include_directories (${arg_TARGET} BEFORE ${arg_SCOPE}
8298 $<$<BOOL :${INCLUDE_PREFIX_HEADERS} >:$<BUILD_INTERFACE :${AWSLC_BINARY_DIR} /symbol_prefix_include >>
8399 $<BUILD_INTERFACE :${AWSLC_SOURCE_DIR} /include >
84- $<INSTALL_INTERFACE :include >)
100+ $<INSTALL_INTERFACE :${AWSLC_INSTALL_INCLUDEDIR} >)
85101endfunction ()
86102
87- option (BUILD_TESTING "Build all test targets for AWS-LC" ON )
88- option (BUILD_LIBSSL "Build libssl for AWS-LC" ON )
89- option (BUILD_TOOL "Build bssl tool for AWS-LC" ON )
90- option (DISABLE_PERL "Disable Perl for AWS-LC" OFF )
91- option (DISABLE_GO "Disable Go for AWS-LC" OFF )
92- # Keeping this flag for now, for compatibility with existing build configs.
93- option (ENABLE_FIPS_ENTROPY_CPU_JITTER "Enable FIPS entropy source: CPU Jitter" OFF )
94- option (ENABLE_DATA_INDEPENDENT_TIMING "Enable automatic setting/resetting Data-Independent Timing
95- (DIT) flag in cryptographic functions. Currently only applicable to Arm64 (except on Windows)" OFF )
96- option (ENABLE_PRE_SONAME_BUILD "Build AWS-LC without SONAME configuration for shared library builds" ON )
97- option (ENABLE_SOURCE_MODIFICATION "Allow the build to update files in the source directory. This is typically done to update versioning." ON )
98- option (DISABLE_CPU_JITTER_ENTROPY "Disable usage of CPU Jitter Entropy as an entropy source. This option cannot be used with the FIPS build. With this configuration, randomness generation might not use two independent entropy sources." OFF )
99- option (GENERATE_RUST_BINDINGS "Generate Rust bindings using bindgen-cli" OFF )
103+
100104set (RUST_BINDINGS_TARGET_VERSION "1.70" CACHE STRING "Minimum Rust version for generated bindings" )
101105
102106include (cmake/go.cmake )
103107
104- if (NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE )
105- set (PERFORM_SONAME_BUILD 1)
108+ if (ENABLE_DIST_PKG AND UNIX AND NOT APPLE )
109+ set (SET_LIB_SONAME 1)
110+ set (COHABITANT_HEADERS 1)
111+ if (ENABLE_DIST_PKG_OPENSSL_SHIM)
112+ set (INSTALL_OPENSSL_SHIM 1)
113+ else ()
114+ set (INSTALL_OPENSSL_SHIM 0)
115+ endif ()
116+ elseif (NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE )
117+ set (SET_LIB_SONAME 1)
118+ set (COHABITANT_HEADERS 0)
119+ set (INSTALL_OPENSSL_SHIM 1)
120+ else ()
121+ set (SET_LIB_SONAME 0)
122+ set (COHABITANT_HEADERS 0)
123+ set (INSTALL_OPENSSL_SHIM 1)
124+ endif ()
125+
126+ if (SET_LIB_SONAME)
106127 set (CRYPTO_LIB_NAME "${CRYPTO_LIB_NAME} -${SOFTWARE_NAME} " )
107128 set (SSL_LIB_NAME "${SSL_LIB_NAME} -${SOFTWARE_NAME} " )
129+ endif ()
130+
131+ # Set the install include directory based on whether a prefix subdirectory is desired
132+ if (COHABITANT_HEADERS)
133+ set (AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR} /aws-lc" )
108134else ()
109- set (PERFORM_SONAME_BUILD 0 )
135+ set (AWSLC_INSTALL_INCLUDEDIR " ${CMAKE_INSTALL_INCLUDEDIR} " )
110136endif ()
111137
112- message (STATUS "ENABLE_PRE_SONAME_BUILD: ${ENABLE_PRE_SONAME_BUILD} " )
113- message (STATUS "PERFORM_SONAME_BUILD: ${PERFORM_SONAME_BUILD} " )
138+ if (NOT ENABLE_PRE_SONAME_BUILD)
139+ message (WARNING "ENABLE_PRE_SONAME_BUILD option will be deprecated in a future release. Please see ENABLE_DIST_PKG and ENABLE_DIST_PKG_OPENSSL_SHIM" )
140+ endif ()
114141
115142enable_language (C )
116143
@@ -168,8 +195,6 @@ else()
168195 message (STATUS "Entropy source configured: Dynamic (default: CPU Jitter)" )
169196endif ()
170197
171-
172-
173198if (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
174199 # OpenBSD by defaults links with --execute-only this is problematic for two reasons:
175200 # 1. The FIPS shared and static builds need to compute the module signature hash by reading the .text section
@@ -263,7 +288,7 @@ elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
263288endif ()
264289
265290install (DIRECTORY include/openssl
266- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
291+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
267292 COMPONENT Development
268293 PATTERN boringssl_prefix_symbols.h EXCLUDE
269294 PATTERN boringssl_prefix_symbols_asm.h EXCLUDE
@@ -364,7 +389,7 @@ if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND GO_EXECUTABLE)
364389 symbol_prefix_include/openssl/boringssl_prefix_symbols_nasm.inc )
365390
366391 install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /symbol_prefix_include/openssl
367- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
392+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
368393 COMPONENT Development
369394 )
370395elseif (BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
@@ -384,7 +409,7 @@ elseif(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
384409 add_custom_target (boringssl_prefix_symbols )
385410
386411 install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /symbol_prefix_include/openssl
387- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
412+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
388413 COMPONENT Development
389414 )
390415elseif (BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND NOT GO_EXECUTABLE)
@@ -398,7 +423,7 @@ else()
398423 add_custom_target (boringssl_prefix_symbols )
399424
400425 install (DIRECTORY include/openssl
401- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
426+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
402427 COMPONENT Development
403428 FILES_MATCHING
404429 PATTERN boringssl_prefix_symbols.h
@@ -1466,15 +1491,22 @@ endif()
14661491file (GLOB OPENSSL_PKGCONFIGS "pkgconfig/*.pc.in" )
14671492
14681493include (cmake/JoinPaths.cmake )
1469- join_paths (libdir_for_pc_file "\$ {prefix}" "${CMAKE_INSTALL_LIBDIR} " )
1470- join_paths (includedir_for_pc_file "\$ {prefix}" "${CMAKE_INSTALL_INCLUDEDIR} " )
1471-
1472- foreach (in_file ${OPENSSL_PKGCONFIGS} )
1473- file (RELATIVE_PATH in_file ${AWSLC_SOURCE_DIR} ${in_file} )
1474- string (REPLACE ".in" "" pc_file ${in_file} )
1475- configure_file (${in_file} ${CMAKE_CURRENT_BINARY_DIR} /${pc_file} @ONLY )
1476- install (FILES ${CMAKE_CURRENT_BINARY_DIR} /${pc_file} DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
1477- endforeach ()
1494+ join_paths (LIBDIR_FOR_PC_FILE "\$ {prefix}" "${CMAKE_INSTALL_LIBDIR} " )
1495+ join_paths (INCLUDEDIR_FOR_PC_FILE "\$ {prefix}" "${AWSLC_INSTALL_INCLUDEDIR} " )
1496+
1497+ function (install_pkgconfig_file )
1498+ set (options "" )
1499+ set (oneValueArgs TEMPLATE DEST)
1500+ set (multiValueArgs)
1501+ if (CMAKE_VERSION VERSION_LESS "3.7" )
1502+ cmake_parse_arguments (arg "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
1503+ else ()
1504+ cmake_parse_arguments (PARSE_ARGV 0 arg "${options} " "${oneValueArgs} " "${multiValueArgs} " )
1505+ endif ()
1506+
1507+ configure_file (pkgconfig/${arg_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR} /pkgconfig/${arg_DEST} @ONLY )
1508+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /pkgconfig/${arg_DEST} DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
1509+ endfunction ()
14781510
14791511if (ENABLE_SOURCE_MODIFICATION)
14801512 configure_file (include /openssl/base.h.in ${AWSLC_SOURCE_DIR} /include/openssl/base.h @ONLY )
@@ -1483,3 +1515,42 @@ if(ENABLE_SOURCE_MODIFICATION)
14831515 configure_file (util/check-linkage.sh.in check-linkage.sh @ONLY )
14841516 endif ()
14851517endif ()
1518+
1519+ install_pkgconfig_file (TEMPLATE product.pc.in DEST aws-lc.pc )
1520+ install_pkgconfig_file (TEMPLATE libcrypto.pc.in DEST lib${CRYPTO_LIB_NAME}.pc )
1521+ install_pkgconfig_file (TEMPLATE libssl.pc.in DEST lib${SSL_LIB_NAME}.pc )
1522+
1523+ if (INSTALL_OPENSSL_SHIM)
1524+ install_pkgconfig_file (TEMPLATE product.pc.in DEST openssl.pc )
1525+
1526+ # Create OpenSSL compatibility symlinks
1527+ if (BUILD_SHARED_LIBS )
1528+ if (SET_LIB_SONAME)
1529+ # When SONAME build is enabled, libraries have -awslc suffix
1530+ install (CODE "
1531+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1532+ lib${CRYPTO_LIB_NAME} .so \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libcrypto.so\" )
1533+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1534+ lib${SSL_LIB_NAME} .so \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libssl.so\" )
1535+ " )
1536+ endif ()
1537+ else ()
1538+ if (SET_LIB_SONAME)
1539+ # When SONAME build is enabled, libraries have -awslc suffix
1540+ install (CODE "
1541+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1542+ lib${CRYPTO_LIB_NAME} .a \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libcrypto.a\" )
1543+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1544+ lib${SSL_LIB_NAME} .a \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libssl.a\" )
1545+ " COMPONENT Development)
1546+ endif ()
1547+ endif ()
1548+
1549+ if (COHABITANT_HEADERS)
1550+ # Always create the include directory symlink for OpenSSL compatibility
1551+ install (CODE "
1552+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1553+ aws-lc/openssl \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR} /openssl\" )
1554+ " COMPONENT Development)
1555+ endif ()
1556+ endif ()
0 commit comments