Module: kamailio
Branch: master
Commit: 0b7c938c3c2c652ee1fa8d55ce28135c6ab4b777
URL: 
https://github.com/kamailio/kamailio/commit/0b7c938c3c2c652ee1fa8d55ce28135c6ab4b777

Author: Xenofon Karamanos <x...@gilawa.com>
Committer: Xenofon Karamanos <x...@gilawa.com>
Date: 2025-08-26T11:11:30Z

cmake: Adopt x86_64 options from make

---

Modified: cmake/compiler-specific.cmake

---

Diff:  
https://github.com/kamailio/kamailio/commit/0b7c938c3c2c652ee1fa8d55ce28135c6ab4b777.diff
Patch: 
https://github.com/kamailio/kamailio/commit/0b7c938c3c2c652ee1fa8d55ce28135c6ab4b777.patch

---

diff --git a/cmake/compiler-specific.cmake b/cmake/compiler-specific.cmake
index 5ac44eedaa0..f7a8a8fb956 100644
--- a/cmake/compiler-specific.cmake
+++ b/cmake/compiler-specific.cmake
@@ -26,23 +26,42 @@ if(TARGET_ARCH MATCHES "x86_64")
   if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
     target_compile_definitions(common_compiler_flags INTERFACE CC_GCC_LIKE_ASM)
 
-    target_compile_options(
-      common_compiler_flags INTERFACE -Wall -funroll-loops -Wcast-align
-                                      -Werror=implicit-function-declaration 
-Werror=implicit-int
-    )
+    target_compile_options(common_compiler_flags INTERFACE -funroll-loops 
-Wcast-align)
 
-    # If GCC version is greater than 4.2.0, enable the following flags
-    if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2.0)
+    # If GCC version is greater than 4.2, enable the following flags
+    if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2)
+      set_if_empty(CPUTYPE "generic")
       target_compile_options(
         common_compiler_flags INTERFACE -m64 -minline-all-stringops 
-falign-loops -ftree-vectorize
-                                        -fno-strict-overflow -mtune=generic
+                                        -fno-strict-overflow -mtune=${CPUTYPE}
       )
       target_link_options(common_compiler_flags INTERFACE -m64)
+    elseif(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.0)
+      set_if_empty(CPUTYPE "athlon64")
+      target_compile_options(
+        common_compiler_flags INTERFACE -m64 -minline-all-stringops 
-falign-loops -ftree-vectorize
+                                        -mtune=${CPUTYPE}
+      )
+      target_link_options(common_compiler_flags INTERFACE -m64)
+    else()
+      message(
+        WARNING
+          "You are using an old and unsupported gcc version 
${CMAKE_C_COMPILER_VERSION}, compile at your own risk!"
+      )
     endif()
   elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+    set_if_empty(CPUTYPE "opteron")
     target_compile_definitions(common_compiler_flags INTERFACE CC_GCC_LIKE_ASM)
     target_compile_options(common_compiler_flags INTERFACE -m64)
     target_link_options(common_compiler_flags INTERFACE -m64)
+  elseif(CMAKE_C_COMPILER_ID STREQUAL "Intel")
+    target_compile_definitions(common_compiler_flags INTERFACE CC_GCC_LIKE_ASM)
+    target_compile_options(common_compiler_flags INTERFACE -O3 -ipo -ipo_obj 
-unroll -tpp6 -xK)
+  else()
+    message(
+      WARNING
+        "Unsupported compiler (${CMAKE_C_COMPILER_ID}) for x86_64. Try GCC, 
Clang, or ICC. Compile at your own risk!"
+    )
   endif()
 
 elseif(TARGET_ARCH MATCHES "i386")

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to