summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2024-03-08 17:18:34 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2024-03-08 17:41:03 +0900
commit1a7322da1c4d67bd38c461498126a15dcb014ab0 (patch)
treea3bb662970ca4e9b9de5f1c45fda6314a60987d7
parentf5c200ccf0f8066dbbbc38cf36af10bdc54f5a45 (diff)
downloadk3b-1a7322da1c4d67bd38c461498126a15dcb014ab0.tar.gz
k3b-1a7322da1c4d67bd38c461498126a15dcb014ab0.zip
Fix detection of MMX capabilities on ix86 archs
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--CMakeLists.txt5
-rw-r--r--ConfigureChecks.cmake35
-rw-r--r--config.h.cmake3
-rw-r--r--src/fastscale/CMakeLists.txt19
4 files changed, 52 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f86f821..ab9e4d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,13 +20,10 @@ project( k3b )
##### include essential cmake modules ###########
include( FindPkgConfig )
+include( CheckCSourceCompiles )
include( CheckIncludeFile )
include( CheckLibraryExists )
include( CheckSymbolExists )
-# EXAMPLE:
-# include( CheckTypeSize )
-# include( CheckCSourceCompiles )
-# include( CheckCXXSourceCompiles )
##### include our cmake modules #################
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index c607e06..1bfe83c 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -243,3 +243,38 @@ if( WITH_LAME )
tde_message_fatal( "lame is requested, but was not found on your system" )
endif( )
endif( )
+
+
+##### check architecture
+
+if( NOT CMAKE_ARCHITECTURE )
+ execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -dumpmachine
+ OUTPUT_VARIABLE CMAKE_ARCHITECTURE
+ ERROR_VARIABLE CMAKE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_STRIP_TRAILING_WHITESPACE )
+ set( CMAKE_ARCHITECTURE "${CMAKE_ARCHITECTURE}" CACHE INTERNAL "" FORCE )
+ message( STATUS "Detected ${CMAKE_ARCHITECTURE} target architecture" )
+endif( )
+
+
+##### check specific architecture dependant support
+
+if( ${CMAKE_ARCHITECTURE} MATCHES "i.86" )
+
+ # MMX support
+ message( STATUS "Performing MMX support test" )
+ check_c_source_compiles( "
+ int main() {
+ #if defined(__GNUC__)
+ __asm__(\"pxor %mm0, %mm0\");
+ #else
+ #error Not gcc on x86/x86_64
+ #endif
+ return 0;
+ }"
+ HAVE_X86_MMX
+ )
+
+endif( )
diff --git a/config.h.cmake b/config.h.cmake
index c864e46..5585fa0 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -35,3 +35,6 @@
// #cmakedefine HAVE_RESMGR
#cmakedefine HAVE_TAGLIB
+
+// Defined if you have MMX support
+#cmakedefine HAVE_X86_MMX 1
diff --git a/src/fastscale/CMakeLists.txt b/src/fastscale/CMakeLists.txt
index 66812fd..91bb8c7 100644
--- a/src/fastscale/CMakeLists.txt
+++ b/src/fastscale/CMakeLists.txt
@@ -21,15 +21,22 @@ link_directories(
${TQT_LIBRARY_DIRS}
)
-# Force to use C compiler for asm_scale.S instead of ASM
-# because contains mixed code - ASM with C definitions
-set_source_files_properties( asm_scale.S PROPERTIES LANGUAGE C )
-
-# TODO add assembler flags here (2016-01-14, Fat-Zer)
##### fastscale (static) ########################
+set( fastscale_SRCS scale.cpp )
+
+if( HAVE_X86_MMX )
+ list( APPEND fastscale_SRCS asm_scale.S )
+
+ # Force to use C compiler for asm_scale.S instead of ASM
+ # because it contains mixed code - ASM with C definitions
+ set_source_files_properties( asm_scale.S PROPERTIES LANGUAGE C )
+
+ add_compile_options( -DHAVE_X86_MMX )
+endif( )
+
tde_add_library( fastscale STATIC_PIC AUTOMOC
- SOURCES scale.cpp asm_scale.S
+ SOURCES ${fastscale_SRCS}
LINK tdecore-shared
)