Reputation: 1
I've tried to run my project, but it's complaining about not being able to find a header. The reason it can't find it is because instead of searching my ./include directory, it's loading a framework from somewhere in XCode.
/Users/liam/CLionProjects/Game/Game/../Engine/Engine/Platform/MacOS/WindowService/WindowMetal.h:7:10: fatal error: 'Metal/Metal.hpp' file not found
7 | #include <Metal/Metal.hpp>
| ^~~~~~~~~~~~~~~~~
/Users/liam/CLionProjects/Game/Game/../Engine/Engine/Platform/MacOS/WindowService/WindowMetal.h:7:10: note: did not find header 'Metal.hpp' in framework 'Metal' (loaded from '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks')
This is what my CMake file looks like
cmake_minimum_required(VERSION 3.30)
project(Engine)
set(CMAKE_CXX_STANDARD 26)
add_library(Engine SHARED
/* FILES */
)
target_include_directories(Engine PRIVATE
../Engine
Core/pch
../include/Common
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_include_directories(Engine PRIVATE
../include/Windows
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_include_directories(Engine PRIVATE
../include/Apple
)
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(Engine PRIVATE
dwmapi
)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_libraries(Engine PRIVATE
"-framework Metal"
"-framework MetalKit"
"-framework AppKit"
"-framework Foundation"
"-framework QuartzCore"
)
endif()
The Metal directory exists in ../include/Apple
I've created a seperate cmake project like so
cmake_minimum_required(VERSION 3.30)
project(mac_window)
set(CMAKE_CXX_STANDARD 26)
add_executable(mac_window src/main.cpp)
target_include_directories(mac_window PRIVATE include)
target_link_libraries(mac_window PRIVATE
"-framework Metal"
"-framework MetalKit"
"-framework AppKit"
"-framework Foundation"
"-framework QuartzCore"
)
And it works fine. What's the difference?
Upvotes: 0
Views: 25