Skip to content

Commit

Permalink
use convenient variable LINUX and BSD to judge their platform
Browse files Browse the repository at this point in the history
Signed-off-by: Fs <[email protected]>
  • Loading branch information
Fsu0413 committed Jan 20, 2024
1 parent 67f98e5 commit 0a198cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ project(OpenSSL
LANGUAGES C CXX
)

if (CMAKE_VERSION VERSION_LESS 3.25)
# set variable LINUX and BSD (which wasn't introduced until CMake 3.25)
# Note: We don't actually judge the variant of Linux or BSD so just make it "if"-compatible
if (CMAKE_SYSTEM_NAME MATCHES "[Ll]inux")
set(LINUX true)
elseif (CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME STREQUAL "DragonFly")
set(BSD "${CMAKE_SYSTEM_NAME}")
endif()
endif()

get_filename_component(OPENSSL_C_COMPILER "${CMAKE_C_COMPILER}" NAME_WLE)

# for generating opensslv.h
Expand Down Expand Up @@ -315,7 +325,7 @@ foreach (_CIPHER IN ITEMS
if (_CIPHER STREQUAL "bulk")
cmake_dependent_option("${_CIPHER_STR}" "${_CIPHER_HELP}" "${_CIPHER_DEFAULT}" "BUILD_SHARED_LIBS;OPENSSL_DSO" ON)
elseif (_CIPHER STREQUAL "afalgeng")
cmake_dependent_option("${_CIPHER_STR}" "${_CIPHER_HELP}" "${_CIPHER_DEFAULT}" "CMAKE_SYSTEM_NAME MATCHES \"[Ll]inux\";OPENSSL_ENGINE" OFF)
cmake_dependent_option("${_CIPHER_STR}" "${_CIPHER_HELP}" "${_CIPHER_DEFAULT}" "LINUX;OPENSSL_ENGINE" OFF)
elseif (_CIPHER STREQUAL "mdc2")
cmake_dependent_option("${_CIPHER_STR}" "${_CIPHER_HELP}" "${_CIPHER_DEFAULT}" "OPENSSL_DES" OFF)
elseif (_CIPHER STREQUAL "ed2m")
Expand Down Expand Up @@ -612,7 +622,7 @@ elseif (ANDROID)
else()
set(OPENSSL_BUILD_PLATFORM "android")
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "[Ll]inux")
elseif (LINUX)
if (OPENSSL_TARGET_ARCH STREQUAL "x64")
if (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
set(OPENSSL_BUILD_PLATFORM "linux-x86_64-clang")
Expand All @@ -636,7 +646,7 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "[Ll]inux")
set(OPENSSL_BUILD_PLATFORM "linux-generic32")
endif()
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "BSD")
elseif (BSD)
if (OPENSSL_TARGET_ARCH STREQUAL "x64")
set(OPENSSL_BUILD_PLATFORM "BSD-x86_64")
elseif (OPENSSL_TARGET_ARCH STREQUAL "x86")
Expand Down
24 changes: 12 additions & 12 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ endif()
if ( WIN32
OR ( ANDROID AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "x64" ) ) )
OR APPLE
OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" )
OR BSD
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) # TODO: Solaris on sparcv7 and sparcv9-64 have RC4_CHAR
)
set(OPENSSL_RC4_INT "int")
Expand All @@ -64,11 +64,11 @@ else()
endif()

#cmakedefine BN_LLONG
if ( ( ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) )
if ( ( BSD AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) )
OR ( CYGWIN AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) )
OR ( WIN32 AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) )
OR ( ANDROID AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "arm32" ) ) )
OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "arm32" ) ) )
OR ( LINUX AND ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) OR ( OPENSSL_TARGET_ARCH STREQUAL "arm32" ) ) )
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" AND ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) ) # # TODO: Solaris on sparcv7 and sparcv9-64 have BN_LLONG
)
set(BN_LLONG YES)
Expand Down Expand Up @@ -116,11 +116,11 @@ else()
message(FATAL_ERROR "OpenSSL currently supports only 64-bit and 32-bit platform. Other platform is no longer supported.")
endif()
if (OPENSSL_DSO)
if ( ( CMAKE_SYSTEM_NAME MATCHES "BSD" )
if ( BSD
OR CYGWIN
OR ANDROID
OR APPLE
OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" )
OR LINUX
OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" )
)
set(DSO_WIN32 OFF)
Expand Down Expand Up @@ -163,7 +163,7 @@ if (OPENSSL_ASM OR OPENSSL_UPLINK)
set(OPENSSL_PERLASM_SCHEME "win32")
elseif (ANDROID)
set(OPENSSL_PERLASM_SCHEME "android")
elseif( CMAKE_SYSTEM_NAME MATCHES "BSD" OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
elseif( BSD OR LINUX OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
set(OPENSSL_PERLASM_SCHEME "elf")
endif()
elseif ( OPENSSL_TARGET_ARCH STREQUAL "x64" )
Expand All @@ -173,28 +173,28 @@ if (OPENSSL_ASM OR OPENSSL_UPLINK)
set(OPENSSL_PERLASM_SCHEME "mingw64")
elseif (MSVC)
set(OPENSSL_PERLASM_SCHEME "masm")
elseif ( ANDROID OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
elseif ( ANDROID OR BSD OR LINUX OR ( CMAKE_SYSTEM_NAME MATCHES "SunOS" ) )
set(OPENSSL_PERLASM_SCHEME "elf")
elseif ( APPLE AND NOT IOS )
set(OPENSSL_PERLASM_SCHEME "macosx")
elseif (IOS)
set(OPENSSL_PERLASM_SCHEME "osx32")
endif()
elseif ( OPENSSL_TARGET_ARCH STREQUAL "arm32" )
if ( ANDROID OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) )
if ( ANDROID OR LINUX )
set(OPENSSL_PERLASM_SCHEME "linux32")
elseif (APPLE)
set(OPENSSL_PERLASM_SCHEME "ios32")
endif()
elseif ( OPENSSL_TARGET_ARCH STREQUAL "arm64" )
if ( ANDROID OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) OR ( CMAKE_SYSTEM_NAME MATCHES "BSD" ) )
if ( ANDROID OR LINUX OR BSD )
set(OPENSSL_PERLASM_SCHEME "linux64")
elseif (APPLE)
set(OPENSSL_PERLASM_SCHEME "ios64")
endif()
endif()

if ( NOT OPENSSL_PERLASM_SCHEME AND ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" ) )
if ( NOT OPENSSL_PERLASM_SCHEME AND LINUX )
set(OPENSSL_PERLASM_SCHEME "void")
endif()

Expand Down Expand Up @@ -281,11 +281,11 @@ if (OPENSSL_SSE2)
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-DOPENSSL_IA32_SSE2")
endif()
if (OPENSSL_THREADS)
if ( ( CMAKE_SYSTEM_NAME MATCHES "BSD" ))
if (BSD)
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-D_THREAD_SAFE" "-D_REENTRANT")
elseif ( ANDROID
OR APPLE
OR ( CMAKE_SYSTEM_NAME MATCHES "[Ll]inux" )
OR LINUX
)
set(LIBCRYPTO_CFLAGS ${LIBCRYPTO_CFLAGS} "-D_REENTRANT")
elseif (WIN32 AND NOT MSVC)
Expand Down
11 changes: 0 additions & 11 deletions crypto/_cryptoDir/objects.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,9 @@ if (OPENSSL_ASM)
x86_64cpuid${OPENSSL_ASM_PREPROCESSED}
)
elseif ( ( OPENSSL_TARGET_ARCH STREQUAL "x86" ) AND ( NOT OPENSSL_386 ) )
# TODO: properly set up applink and uplink
set(LIBCRYPTO_CURRENTDIR_ASM_SOURCES
x86cpuid.S${OPENSSL_ASM_PREPROCESSED_X86}
)
if (false)
if ( WIN32 )
set(LIBCRYPTO_CURRENTDIR_ASM_SOURCES
${LIBCRYPTO_CRYPTODIR_ASM_SOURCES}
${CMAKE_SOURCE_DIR}/ms/applink.c
${CMAKE_SOURCE_DIR}/ms/uplink.c
uplink-x86.s
)
endif()
endif()
elseif ( OPENSSL_TARGET_ARCH STREQUAL "arm32" )
set(LIBCRYPTO_CURRENTDIR_ASM_SOURCES
armv4cpuid.S
Expand Down

0 comments on commit 0a198cd

Please sign in to comment.