Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5962

Finding kernel headers with cmake

$
0
0

I need to include <asm/barrier.h> and <asm/msr.h>. I see them (in /usr/src/linux-headers-6.5.0-27/arch/x86/include/asm but cmake doesn't. I tried:

  find_path(KERNELHEADERS_DIR    include/asm/barrier.h  )

...and:

execute_process(  COMMAND uname -r  OUTPUT_VARIABLE KERNEL_RELEASE  OUTPUT_STRIP_TRAILING_WHITESPACE)string(REPLACE "-generic" "" KERNEL_RELEASE  "${KERNEL_RELEASE}")# Find the headersfind_path(KERNELHEADERS_DIR  include/asm/barrier.h  PATHS /usr/src/linux-headers-${KERNEL_RELEASE})

...and variations thereof, but it stubbornly returns /usr/src/linux-headers-6.5.0-28-generic.

I don't need a super complete solution, I just need it to work on Ubuntu (it's for YOMM2's benchmarks, not a public, documented thing).

Help?

[edit]

I tried again, following @tsyvarev's suggestions, but it doesn't work, even when I specify the literal path to the headers:

$ ls -l /usr/src/linux-headers-6.5.0-27/arch/x86/include/asm/barrier.h-rw-r--r-- 1 root root 2939 Aug 27  2023 /usr/src/linux-headers-6.5.0-27/arch/x86/include/asm/barrier.h
find_path(  KERNEL_INCLUDE_DIR  asm/barrier.h  PATHS /usr/src/linux-headers-6.5.0-27/arch/x86)message(STATUS "KERNEL_INCLUDE_DIR = ${KERNEL_INCLUDE_DIR}")
KERNEL_INCLUDE_DIR = KERNEL_INCLUDE_DIR-NOTFOUND

Viewing all articles
Browse latest Browse all 5962

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>