From 5136295b21aac41709672c17a5a596f996a27735 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 2 Apr 2017 20:11:12 +1000 Subject: OSX: get cache line size --- cmake/cpu_info.cmake | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'cmake/cpu_info.cmake') diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake index 32b98142ace..1772510e72b 100644 --- a/cmake/cpu_info.cmake +++ b/cmake/cpu_info.cmake @@ -15,15 +15,29 @@ # Symbols with information about the CPU. -FIND_PROGRAM(GETCONF getconf) -MARK_AS_ADVANCED(GETCONF) +IF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + FIND_PROGRAM(SYSCTL sysctl) + MARK_AS_ADVANCED(SYSCTL) -IF(GETCONF) - EXECUTE_PROCESS( - COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE - OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE - ) + IF(SYSCTL) + EXECUTE_PROCESS( + COMMAND ${SYSCTL} -n hw.cachelinesize + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() + +ELSE() + FIND_PROGRAM(GETCONF getconf) + MARK_AS_ADVANCED(GETCONF) + + IF(GETCONF) + EXECUTE_PROCESS( + COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() ENDIF() + IF(CPU_LEVEL1_DCACHE_LINESIZE AND CPU_LEVEL1_DCACHE_LINESIZE GREATER 0) ELSE() SET(CPU_LEVEL1_DCACHE_LINESIZE 64) -- cgit v1.2.1