@@ -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.
@@ -52,6 +68,52 @@ if(POLICY CMP0077)
5268 cmake_policy (SET CMP0077 NEW ) #option does nothing when a normal variable of the same name exists.
5369endif ()
5470
71+ set (RUST_BINDINGS_TARGET_VERSION "1.70" CACHE STRING "Minimum Rust version for generated bindings" )
72+
73+ include (cmake/go.cmake )
74+
75+ if (ENABLE_DIST_PKG AND UNIX AND NOT APPLE )
76+ set (SET_LIB_SONAME 1)
77+ set (COHABITANT_HEADERS 1)
78+ if (ENABLE_DIST_PKG_OPENSSL_SHIM)
79+ set (INSTALL_OPENSSL_SHIM 1)
80+ else ()
81+ set (INSTALL_OPENSSL_SHIM 0)
82+ endif ()
83+ elseif (NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE )
84+ set (SET_LIB_SONAME 1)
85+ set (COHABITANT_HEADERS 0)
86+ set (INSTALL_OPENSSL_SHIM 1)
87+ else ()
88+ set (SET_LIB_SONAME 0)
89+ set (COHABITANT_HEADERS 0)
90+ set (INSTALL_OPENSSL_SHIM 1)
91+ endif ()
92+
93+ if (SET_LIB_SONAME)
94+ set (CRYPTO_LIB_NAME "${CRYPTO_LIB_NAME} -${SOFTWARE_NAME} " )
95+ set (SSL_LIB_NAME "${SSL_LIB_NAME} -${SOFTWARE_NAME} " )
96+ endif ()
97+
98+ if (NOT WIN32 AND NOT APPLE )
99+ include (GNUInstallDirs )
100+ elseif (NOT DEFINED CMAKE_INSTALL_LIBDIR)
101+ set (CMAKE_INSTALL_LIBDIR "lib" )
102+ set (CMAKE_INSTALL_INCLUDEDIR "include" )
103+ set (CMAKE_INSTALL_BINDIR "bin" )
104+ endif ()
105+
106+ # Set the install include directory based on whether a prefix subdirectory is desired
107+ if (COHABITANT_HEADERS)
108+ set (AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR} /aws-lc" )
109+ else ()
110+ set (AWSLC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR} " )
111+ endif ()
112+
113+ if (NOT ENABLE_PRE_SONAME_BUILD)
114+ 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" )
115+ endif ()
116+
55117function (target_add_awslc_include_paths )
56118 set (options EXCLUDE_PREFIX_HEADERS)
57119 set (oneValueArgs TARGET SCOPE)
@@ -81,37 +143,9 @@ function(target_add_awslc_include_paths)
81143 target_include_directories (${arg_TARGET} BEFORE ${arg_SCOPE}
82144 $<$<BOOL :${INCLUDE_PREFIX_HEADERS} >:$<BUILD_INTERFACE :${AWSLC_BINARY_DIR} /symbol_prefix_include >>
83145 $<BUILD_INTERFACE :${AWSLC_SOURCE_DIR} /include >
84- $<INSTALL_INTERFACE :include >)
146+ $<INSTALL_INTERFACE :${AWSLC_INSTALL_INCLUDEDIR} >)
85147endfunction ()
86148
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 )
100- set (RUST_BINDINGS_TARGET_VERSION "1.70" CACHE STRING "Minimum Rust version for generated bindings" )
101-
102- include (cmake/go.cmake )
103-
104- if (NOT ENABLE_PRE_SONAME_BUILD AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE )
105- set (PERFORM_SONAME_BUILD 1)
106- set (CRYPTO_LIB_NAME "${CRYPTO_LIB_NAME} -${SOFTWARE_NAME} " )
107- set (SSL_LIB_NAME "${SSL_LIB_NAME} -${SOFTWARE_NAME} " )
108- else ()
109- set (PERFORM_SONAME_BUILD 0)
110- endif ()
111-
112- message (STATUS "ENABLE_PRE_SONAME_BUILD: ${ENABLE_PRE_SONAME_BUILD} " )
113- message (STATUS "PERFORM_SONAME_BUILD: ${PERFORM_SONAME_BUILD} " )
114-
115149enable_language (C )
116150
117151# Validate Rust bindings prerequisites
@@ -168,8 +202,6 @@ else()
168202 message (STATUS "Entropy source configured: Dynamic (default: CPU Jitter)" )
169203endif ()
170204
171-
172-
173205if (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
174206 # OpenBSD by defaults links with --execute-only this is problematic for two reasons:
175207 # 1. The FIPS shared and static builds need to compute the module signature hash by reading the .text section
@@ -254,16 +286,8 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
254286 set (GCC 1)
255287endif ()
256288
257- if (NOT WIN32 AND NOT APPLE )
258- include (GNUInstallDirs )
259- elseif (NOT DEFINED CMAKE_INSTALL_LIBDIR)
260- set (CMAKE_INSTALL_LIBDIR "lib" )
261- set (CMAKE_INSTALL_INCLUDEDIR "include" )
262- set (CMAKE_INSTALL_BINDIR "bin" )
263- endif ()
264-
265289install (DIRECTORY include/openssl
266- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
290+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
267291 COMPONENT Development
268292 PATTERN boringssl_prefix_symbols.h EXCLUDE
269293 PATTERN boringssl_prefix_symbols_asm.h EXCLUDE
@@ -364,7 +388,7 @@ if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND GO_EXECUTABLE)
364388 symbol_prefix_include/openssl/boringssl_prefix_symbols_nasm.inc )
365389
366390 install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /symbol_prefix_include/openssl
367- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
391+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
368392 COMPONENT Development
369393 )
370394elseif (BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
@@ -384,7 +408,7 @@ elseif(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_HEADERS)
384408 add_custom_target (boringssl_prefix_symbols )
385409
386410 install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /symbol_prefix_include/openssl
387- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
411+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
388412 COMPONENT Development
389413 )
390414elseif (BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS AND NOT GO_EXECUTABLE)
@@ -398,7 +422,7 @@ else()
398422 add_custom_target (boringssl_prefix_symbols )
399423
400424 install (DIRECTORY include/openssl
401- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR }
425+ DESTINATION ${AWSLC_INSTALL_INCLUDEDIR }
402426 COMPONENT Development
403427 FILES_MATCHING
404428 PATTERN boringssl_prefix_symbols.h
@@ -1466,15 +1490,22 @@ endif()
14661490file (GLOB OPENSSL_PKGCONFIGS "pkgconfig/*.pc.in" )
14671491
14681492include (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 ()
1493+ join_paths (LIBDIR_FOR_PC_FILE "\$ {prefix}" "${CMAKE_INSTALL_LIBDIR} " )
1494+ join_paths (INCLUDEDIR_FOR_PC_FILE "\$ {prefix}" "${AWSLC_INSTALL_INCLUDEDIR} " )
1495+
1496+ function (install_pkgconfig_file )
1497+ set (options "" )
1498+ set (oneValueArgs TEMPLATE DEST)
1499+ set (multiValueArgs)
1500+ if (CMAKE_VERSION VERSION_LESS "3.7" )
1501+ cmake_parse_arguments (arg "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
1502+ else ()
1503+ cmake_parse_arguments (PARSE_ARGV 0 arg "${options} " "${oneValueArgs} " "${multiValueArgs} " )
1504+ endif ()
1505+
1506+ configure_file (pkgconfig/${arg_TEMPLATE} ${CMAKE_CURRENT_BINARY_DIR} /pkgconfig/${arg_DEST} @ONLY )
1507+ install (FILES ${CMAKE_CURRENT_BINARY_DIR} /pkgconfig/${arg_DEST} DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
1508+ endfunction ()
14781509
14791510if (ENABLE_SOURCE_MODIFICATION)
14801511 configure_file (include /openssl/base.h.in ${AWSLC_SOURCE_DIR} /include/openssl/base.h @ONLY )
@@ -1483,3 +1514,42 @@ if(ENABLE_SOURCE_MODIFICATION)
14831514 configure_file (util/check-linkage.sh.in check-linkage.sh @ONLY )
14841515 endif ()
14851516endif ()
1517+
1518+ install_pkgconfig_file (TEMPLATE product.pc.in DEST aws-lc.pc )
1519+ install_pkgconfig_file (TEMPLATE libcrypto.pc.in DEST lib${CRYPTO_LIB_NAME}.pc )
1520+ install_pkgconfig_file (TEMPLATE libssl.pc.in DEST lib${SSL_LIB_NAME}.pc )
1521+
1522+ if (INSTALL_OPENSSL_SHIM)
1523+ install_pkgconfig_file (TEMPLATE product.pc.in DEST openssl.pc )
1524+
1525+ # Create OpenSSL compatibility symlinks
1526+ if (BUILD_SHARED_LIBS )
1527+ if (SET_LIB_SONAME)
1528+ # When SONAME build is enabled, libraries have -awslc suffix
1529+ install (CODE "
1530+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1531+ lib${CRYPTO_LIB_NAME} .so \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libcrypto.so\" )
1532+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1533+ lib${SSL_LIB_NAME} .so \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libssl.so\" )
1534+ " )
1535+ endif ()
1536+ else ()
1537+ if (SET_LIB_SONAME)
1538+ # When SONAME build is enabled, libraries have -awslc suffix
1539+ install (CODE "
1540+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1541+ lib${CRYPTO_LIB_NAME} .a \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libcrypto.a\" )
1542+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1543+ lib${SSL_LIB_NAME} .a \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} /libssl.a\" )
1544+ " COMPONENT Development)
1545+ endif ()
1546+ endif ()
1547+
1548+ if (COHABITANT_HEADERS)
1549+ # Always create the include directory symlink for OpenSSL compatibility
1550+ install (CODE "
1551+ execute_process(COMMAND \$ {CMAKE_COMMAND} -E create_symlink
1552+ aws-lc/openssl \"\$ ENV{DESTDIR}\$ {CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR} /openssl\" )
1553+ " COMPONENT Development)
1554+ endif ()
1555+ endif ()
0 commit comments