From 5eeb260c08035599fd444f36c971bc01e600353b Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Fri, 22 Apr 2022 12:55:00 +0300 Subject: [PATCH] mdbx-cmake: rework making `MDBX_BUILD_TARGET` value. --- CMakeLists.txt | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cc50da2..56a89392 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -861,16 +861,33 @@ endif() # make a build-target triplet if(CMAKE_C_COMPILER_TARGET) set(MDBX_BUILD_TARGET "${CMAKE_C_COMPILER_TARGET}") -elseif(CMAKE_C_PLATFORM_ID AND NOT CMAKE_C_PLATFORM_ID STREQUAL CMAKE_SYSTEM_NAME) - string(STRIP "${CMAKE_C_PLATFORM_ID}-${CMAKE_SYSTEM_NAME}" MDBX_BUILD_TARGET) -elseif(CMAKE_LIBRARY_ARCHITECTURE) - string(STRIP "${CMAKE_LIBRARY_ARCHITECTURE}-${CMAKE_SYSTEM_NAME}" MDBX_BUILD_TARGET) -elseif(CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_C_PLATFORM_ID STREQUAL CMAKE_SYSTEM_NAME) - string(STRIP "${CMAKE_GENERATOR_PLATFORM}-${CMAKE_SYSTEM_NAME}" MDBX_BUILD_TARGET) -elseif(CMAKE_SYSTEM_ARCH) - string(STRIP "${CMAKE_SYSTEM_ARCH}-${CMAKE_SYSTEM_NAME}" MDBX_BUILD_TARGET) else() - string(STRIP "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}" MDBX_BUILD_TARGET) + if(CMAKE_C_COMPILER_ARCHITECTURE_ID) + string(STRIP "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MDBX_BUILD_TARGET) + elseif(CMAKE_GENERATOR_PLATFORM AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL CMAKE_SYSTEM_NAME) + string(STRIP "${CMAKE_GENERATOR_PLATFORM}" MDBX_BUILD_TARGET) + elseif(CMAKE_SYSTEM_ARCH) + string(STRIP "${CMAKE_SYSTEM_ARCH}" MDBX_BUILD_TARGET) + elseif(CMAKE_LIBRARY_ARCHITECTURE) + string(STRIP "${CMAKE_LIBRARY_ARCHITECTURE}" MDBX_BUILD_TARGET) + elseif(CMAKE_SYSTEM_PROCESSOR) + string(STRIP "${CMAKE_SYSTEM_PROCESSOR}" MDBX_BUILD_TARGET) + else() + set(MDBX_BUILD_TARGET "unknown") + endif() + if(CMAKE_C_COMPILER_ABI + AND NOT (CMAKE_C_COMPILER_ABI MATCHES ".*${MDBX_BUILD_TARGET}.*" OR MDBX_BUILD_TARGET MATCHES ".*${CMAKE_C_COMPILER_ABI}.*")) + string(APPEND MDBX_BUILD_TARGET "-${CMAKE_C_COMPILER_ABI}") + endif() + if(CMAKE_C_PLATFORM_ID + AND NOT (CMAKE_SYSTEM_NAME + AND (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_SYSTEM_NAME}.*" OR CMAKE_SYSTEM_NAME MATCHES ".*${CMAKE_C_PLATFORM_ID}.*")) + AND NOT (CMAKE_C_PLATFORM_ID MATCHES ".*${CMAKE_C_PLATFORM_ID}.*" OR MDBX_BUILD_TARGET MATCHES ".*${CMAKE_C_PLATFORM_ID}.*")) + string(APPEND MDBX_BUILD_TARGET "-${CMAKE_C_COMPILER_ABI}") + endif() + if(CMAKE_SYSTEM_NAME) + string(APPEND MDBX_BUILD_TARGET "-${CMAKE_SYSTEM_NAME}") + endif() endif() # provide build-type