File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,10 +11,24 @@ add_executable(
1111
1212set_target_properties (PcmMsrDriver PROPERTIES BUNDLE_EXTENSION kext MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR} /PcmMsr-Info.plist )
1313
14+ # For KEXT compilation on macOS, we must explicitly point to the Kernel frameworks within the SDK.
15+ if (APPLE )
16+ # Find the active macOS SDK path
17+ execute_process (
18+ COMMAND xcrun --sdk macosx --show-sdk-path
19+ OUTPUT_VARIABLE MACOSX_SDK_PATH
20+ OUTPUT_STRIP_TRAILING_WHITESPACE
21+ RESULT_VARIABLE XCRUN_RESULT
22+ )
23+ if (NOT XCRUN_RESULT EQUAL 0 OR NOT MACOSX_SDK_PATH)
24+ message (FATAL_ERROR "Failed to find macOS SDK path using xcrun" )
25+ endif ()
26+ message (STATUS "Using SDK for KEXT: ${MACOSX_SDK_PATH} " )
27+ endif ()
1428
1529target_include_directories (PcmMsrDriver PRIVATE
16- ${CMAKE_OSX_SYSROOT }/System/Library/Frameworks/Kernel.framework/PrivateHeaders
17- ${CMAKE_OSX_SYSROOT }/System/Library/Frameworks/Kernel.framework/Headers
30+ " ${MACOSX_SDK_PATH } /System/Library/Frameworks/Kernel.framework/PrivateHeaders"
31+ " ${MACOSX_SDK_PATH } /System/Library/Frameworks/Kernel.framework/Headers"
1832)
1933target_compile_definitions (PcmMsrDriver PRIVATE
2034 -DKERNEL
You can’t perform that action at this time.
0 commit comments