Skip to content

Commit

Permalink
build DEF only in shared builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsu0413 committed Feb 25, 2024
1 parent a9b3ee5 commit b1e98ff
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
36 changes: 20 additions & 16 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,15 @@ if (WIN32)
set(LIBCRYPTO_RUNTIME_OUTPUT_NAME libcrypto-1_1)
endif()

add_custom_command(
OUTPUT crypto.def
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/crypto.def" -DPLATFORM=_WIN32 -P "${CMAKE_CURRENT_SOURCE_DIR}/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num"
DEPENDS mkdef.cmake
)
set(LIBCRYPTO_SOURCES ${LIBCRYPTO_SOURCES} crypto.def)
if (BUILD_SHARED_LIBS)
add_custom_command(
OUTPUT crypto.def
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/crypto.def" -DPLATFORM=_WIN32 -P "${CMAKE_CURRENT_SOURCE_DIR}/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num"
DEPENDS mkdef.cmake
)
set(LIBCRYPTO_SOURCES ${LIBCRYPTO_SOURCES} crypto.def)
endif()
endif()
add_library(crypto
${CMAKE_BINARY_DIR}/include/openssl/opensslconf.h
Expand Down Expand Up @@ -594,15 +596,17 @@ if (WIN32)
)
endif()
elseif ( ( CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang" ) AND NOT APPLE AND NOT ( CMAKE_SYSTEM_NAME MATCHES "SunOS") )
add_custom_command(
OUTPUT crypto.map
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/crypto.map" -DPLATFORM=ELF -P "${CMAKE_CURRENT_SOURCE_DIR}/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num"
DEPENDS mkdef.cmake
)
add_custom_target(crypto_map SOURCES crypto.map)
add_dependencies(crypto crypto_map)
target_link_options(crypto PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/crypto.map")
if (BUILD_SHARED_LIBS)
add_custom_command(
OUTPUT crypto.map
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/crypto.map" -DPLATFORM=ELF -P "${CMAKE_CURRENT_SOURCE_DIR}/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libcrypto.num"
DEPENDS mkdef.cmake
)
add_custom_target(crypto_map SOURCES crypto.map)
add_dependencies(crypto crypto_map)
target_link_options(crypto PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/crypto.map")
endif()
endif()
set_target_properties(crypto PROPERTIES
SOVERSION 1.1
Expand Down
36 changes: 20 additions & 16 deletions ssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ if (WIN32)
set(LIBSSL_RUNTIME_OUTPUT_NAME libssl-1_1)
endif()

add_custom_command(
OUTPUT ssl.def
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libssl.num" -DLIBRARY_FILE="${LIBSSL_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/ssl.def" -DPLATFORM=_WIN32 -P "${CMAKE_CURRENT_SOURCE_DIR}/../crypto/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libssl.num"
DEPENDS ../crypto/mkdef.cmake
)
set(LIBSSL_SOURCES ${LIBSSL_SOURCES} ssl.def)
if (BUILD_SHARED_LIBS)
add_custom_command(
OUTPUT ssl.def
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libssl.num" -DLIBRARY_FILE="${LIBSSL_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/ssl.def" -DPLATFORM=_WIN32 -P "${CMAKE_CURRENT_SOURCE_DIR}/../crypto/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libssl.num"
DEPENDS ../crypto/mkdef.cmake
)
set(LIBSSL_SOURCES ${LIBSSL_SOURCES} ssl.def)
endif()
endif()
add_library(ssl
${LIBSSL_SOURCES}
Expand All @@ -113,15 +115,17 @@ if (WIN32)
)
endif()
elseif ( ( CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang" ) AND NOT APPLE AND NOT ( CMAKE_SYSTEM_NAME MATCHES "SunOS") )
add_custom_command(
OUTPUT ssl.map
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libssl.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/ssl.map" -DPLATFORM=ELF -P "${CMAKE_CURRENT_SOURCE_DIR}/../crypto/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libssl.num"
DEPENDS ../crypto/mkdef.cmake
)
add_custom_target(ssl_map SOURCES ssl.map)
add_dependencies(ssl ssl_map)
target_link_options(ssl PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/ssl.map")
if (BUILD_SHARED_LIBS)
add_custom_command(
OUTPUT ssl.map
COMMAND "${CMAKE_COMMAND}" -DNUMFILE="${CMAKE_SOURCE_DIR}/openssl/util/libssl.num" -DLIBRARY_FILE="${LIBCRYPTO_RUNTIME_OUTPUT_NAME}" -DBINARY_DIR="${CMAKE_BINARY_DIR}" -DOUTPUT_FILE="${CMAKE_CURRENT_BINARY_DIR}/ssl.map" -DPLATFORM=ELF -P "${CMAKE_CURRENT_SOURCE_DIR}/../crypto/mkdef.cmake"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/openssl/util/libssl.num"
DEPENDS ../crypto/mkdef.cmake
)
add_custom_target(ssl_map SOURCES ssl.map)
add_dependencies(ssl ssl_map)
target_link_options(ssl PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/ssl.map")
endif()
endif()
set_target_properties(ssl PROPERTIES
SOVERSION 1.1
Expand Down

0 comments on commit b1e98ff

Please sign in to comment.