Module: kamailio
Branch: master
Commit: b540392ef910a63f2bda1b78d5970298edc87308
URL:
https://github.com/kamailio/kamailio/commit/b540392ef910a63f2bda1b78d597029…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-12-11T15:38:02+01:00
cmake: support for intel 32b cpu architectures
- identified with i386, i486, i586 and i686
- target cpu arch aliased it i386, like in old-makefiles, some code
depending on it
---
Modified: cmake/compiler-specific.cmake
Modified: cmake/defs.cmake
---
Diff:
https://github.com/kamailio/kamailio/commit/b540392ef910a63f2bda1b78d597029…
Patch:
https://github.com/kamailio/kamailio/commit/b540392ef910a63f2bda1b78d597029…
---
diff --git a/cmake/compiler-specific.cmake b/cmake/compiler-specific.cmake
index 58b8b9cc998..f6bd54c2655 100644
--- a/cmake/compiler-specific.cmake
+++ b/cmake/compiler-specific.cmake
@@ -37,6 +37,35 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
target_link_options(common INTERFACE -m64)
endif()
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i486|i586|i686")
+
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_compile_definitions(common INTERFACE CC_GCC_LIKE_ASM)
+
+ target_compile_options(
+ common INTERFACE -O0
+ # <$<$<BOOL:${PROFILE}>:-pg>
+ )
+
+ target_compile_options(
+ common
+ INTERFACE -Wall -funroll-loops -Wcast-align
+ -Werror=implicit-function-declaration -Werror=implicit-int
+ )
+
+ # If GCC version is greater than 4.2.0, enable the following flags
+ if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2.0)
+ target_compile_options(
+ common INTERFACE -m32 -minline-all-stringops -falign-loops
+ -ftree-vectorize -fno-strict-overflow -mtune=generic
+ )
+ endif()
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_compile_definitions(common INTERFACE CC_GCC_LIKE_ASM)
+ target_compile_options(common INTERFACE -m32)
+ target_link_options(common INTERFACE -m32)
+ endif()
+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
diff --git a/cmake/defs.cmake b/cmake/defs.cmake
index 1d151646c05..0509cad4fca 100644
--- a/cmake/defs.cmake
+++ b/cmake/defs.cmake
@@ -12,12 +12,17 @@ message(STATUS "OS: ${OS}")
set(OSREL ${CMAKE_SYSTEM_VERSION})
message(STATUS "OS version: ${OSREL}")
# set(HOST_ARCH "__CPU_${CMAKE_HOST_SYSTEM_PROCESSOR}")
-set(TARGET_ARCH "__CPU_${CMAKE_SYSTEM_PROCESSOR}")
+
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i486|i586|i686")
+ set(TARGET_ARCH "i386")
+else()
+ set(TARGET_ARCH "${CMAKE_SYSTEM_PROCESSOR}")
+endif()
message(STATUS "Host Processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
# message(STATUS "Processor compile definition: ${HOST_ARCH}")
message(STATUS "Target Processor: ${CMAKE_SYSTEM_PROCESSOR}")
-message(STATUS "Target Processor compile definition: ${TARGET_ARCH}")
+message(STATUS "Target Processor Alias: ${TARGET_ARCH}")
# TODO Check if target arch is supported if(NOT TARGET_ARCH IN_LIST
# supported_archs) message(FATAL_ERROR "Target architecture not supported")
@@ -138,7 +143,7 @@ option(USE_FAST_LOCK "Use fast locking if available" ON)
#
if(USE_FAST_LOCK)
if(CMAKE_SYSTEM_PROCESSOR MATCHES
- "i386|x86_64|sparc64|sparc|ppc|ppc64|alpha|mips2|mips64"
+ "i386|i486|i586|i686|x86_64|sparc64|sparc|ppc|ppc64|alpha|mips2|mips64"
)
set(USE_FAST_LOCK YES)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
@@ -296,9 +301,9 @@ include(${CMAKE_SOURCE_DIR}/cmake/os-specific.cmake)
set(COMPILER_NAME ${CMAKE_C_COMPILER_ID})
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
- set(COMPILER_NAME "gcc")
+ set(COMPILER_NAME "gcc")
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- set(COMPILER_NAME "clang")
+ set(COMPILER_NAME "clang")
endif()
string(TOLOWER ${OS} OS_LOWER)
@@ -307,12 +312,12 @@ target_compile_definitions(
INTERFACE
NAME="${MAIN_NAME}"
VERSION="${RELEASE}"
- ARCH="${CMAKE_HOST_SYSTEM_PROCESSOR}"
+ ARCH="${TARGET_ARCH}"
OS=${OS}
OS_QUOTED="${OS}"
COMPILER="${COMPILER_NAME} ${CMAKE_C_COMPILER_VERSION}"
# ${HOST_ARCH}
- ${TARGET_ARCH}
+ __CPU_${TARGET_ARCH}
__OS_${OS_LOWER}
VERSIONVAL=${VERSIONVAL}
CFG_DIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}/${CFG_NAME}/"