refactor(build): update CMake configurations and toolchain for macOS
- Modified CMake settings to ensure consistent use of the Homebrew LLVM/Clang installation on macOS. - Added a new toolchain file to specify the correct compiler and header search paths, resolving potential conflicts. - Updated CMake presets to enable the EMU build and set appropriate compiler flags. Benefits: - Enhances build reliability and compatibility on macOS by utilizing the Homebrew LLVM toolchain. - Streamlines the build process with improved configuration management.
This commit is contained in:
13
.clangd
13
.clangd
@@ -1,8 +1,5 @@
|
|||||||
CompileFlags:
|
CompileFlags:
|
||||||
Add:
|
CompilationDatabase: build
|
||||||
- -std=c++23
|
|
||||||
- -Wall
|
|
||||||
- -Wextra
|
|
||||||
Remove:
|
Remove:
|
||||||
- -mllvm
|
- -mllvm
|
||||||
- -xclang
|
- -xclang
|
||||||
@@ -20,14 +17,16 @@ Hover:
|
|||||||
ShowAKA: Yes
|
ShowAKA: Yes
|
||||||
|
|
||||||
Diagnostics:
|
Diagnostics:
|
||||||
|
MissingIncludes: Strict
|
||||||
ClangTidy:
|
ClangTidy:
|
||||||
Add:
|
Add:
|
||||||
# - readability-*
|
|
||||||
# - modernize-*
|
|
||||||
- performance-*
|
- performance-*
|
||||||
Remove:
|
- bugprone-*
|
||||||
- readability-*
|
- readability-*
|
||||||
- modernize-*
|
- modernize-*
|
||||||
|
Remove:
|
||||||
|
# - readability-*
|
||||||
|
# - modernize-*
|
||||||
- modernize-use-trailing-return-type
|
- modernize-use-trailing-return-type
|
||||||
- readability-braces-around-statements
|
- readability-braces-around-statements
|
||||||
- readability-magic-numbers
|
- readability-magic-numbers
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "Minimum policy version for su
|
|||||||
|
|
||||||
# Set policies for compatibility
|
# Set policies for compatibility
|
||||||
cmake_policy(SET CMP0091 NEW)
|
cmake_policy(SET CMP0091 NEW)
|
||||||
|
|
||||||
|
# Ensure we consistently use the dynamic MSVC runtime (/MD, /MDd) even when cached
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE STRING "" FORCE)
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
cmake_policy(SET CMP0077 NEW)
|
cmake_policy(SET CMP0077 NEW)
|
||||||
|
|
||||||
@@ -22,11 +25,6 @@ else()
|
|||||||
LANGUAGES CXX C)
|
LANGUAGES CXX C)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Align Windows static builds (MSVC, clang-cl) with vcpkg's /MT runtime
|
|
||||||
if(MSVC OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND WIN32))
|
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Enable ccache for faster rebuilds if available
|
# Enable ccache for faster rebuilds if available
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
if(CCACHE_FOUND)
|
if(CCACHE_FOUND)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
"YAZE_BUILD_APP": "ON",
|
"YAZE_BUILD_APP": "ON",
|
||||||
"YAZE_BUILD_LIB": "ON",
|
"YAZE_BUILD_LIB": "ON",
|
||||||
"YAZE_BUILD_Z3ED": "ON",
|
"YAZE_BUILD_Z3ED": "ON",
|
||||||
"YAZE_BUILD_EMU": "OFF"
|
"YAZE_BUILD_EMU": "ON"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -57,8 +57,12 @@
|
|||||||
"lhs": "${hostSystemName}",
|
"lhs": "${hostSystemName}",
|
||||||
"rhs": "Darwin"
|
"rhs": "Darwin"
|
||||||
},
|
},
|
||||||
|
"toolchainFile": "${sourceDir}/cmake/llvm-brew.toolchain.cmake",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0"
|
"CMAKE_OSX_DEPLOYMENT_TARGET": "11.0",
|
||||||
|
"CMAKE_C_COMPILER": "/opt/homebrew/opt/llvm@18/bin/clang",
|
||||||
|
"CMAKE_CXX_COMPILER": "/opt/homebrew/opt/llvm@18/bin/clang++",
|
||||||
|
"CMAKE_CXX_FLAGS": "-isystem /opt/homebrew/opt/llvm@18/include/c++/v1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -162,6 +166,7 @@
|
|||||||
"displayName": "macOS z3ed",
|
"displayName": "macOS z3ed",
|
||||||
"description": "macOS z3ed CLI with agent support",
|
"description": "macOS z3ed CLI with agent support",
|
||||||
"inherits": "mac-ai",
|
"inherits": "mac-ai",
|
||||||
|
"toolchainFile": "${sourceDir}/cmake/llvm-brew.toolchain.cmake",
|
||||||
"binaryDir": "${sourceDir}/build",
|
"binaryDir": "${sourceDir}/build",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"Z3ED_AI": "ON",
|
"Z3ED_AI": "ON",
|
||||||
@@ -170,8 +175,6 @@
|
|||||||
"YAZE_BUILD_Z3ED": "ON",
|
"YAZE_BUILD_Z3ED": "ON",
|
||||||
"YAZE_BUILD_EMU": "ON",
|
"YAZE_BUILD_EMU": "ON",
|
||||||
"YAZE_BUILD_TESTS": "ON",
|
"YAZE_BUILD_TESTS": "ON",
|
||||||
"YAZE_ENABLE_UI_TESTS": "ON",
|
|
||||||
"YAZE_ENABLE_IMGUI_TEST_ENGINE": "ON",
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
45
cmake/llvm-brew.toolchain.cmake
Normal file
45
cmake/llvm-brew.toolchain.cmake
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# cmake/toolchains/homebrew-llvm.toolchain.cmake
|
||||||
|
#
|
||||||
|
# CMake Toolchain File for using the Homebrew LLVM/Clang installation on macOS.
|
||||||
|
# This ensures that the main project and all dependencies (like gRPC) use the
|
||||||
|
# correct compiler and header search paths.
|
||||||
|
|
||||||
|
# 1. Set the target system (macOS)
|
||||||
|
set(CMAKE_SYSTEM_NAME Darwin)
|
||||||
|
|
||||||
|
# 2. Find the Homebrew LLVM installation path
|
||||||
|
# We use execute_process to make this portable across machine architectures.
|
||||||
|
execute_process(
|
||||||
|
COMMAND brew --prefix llvm@18
|
||||||
|
OUTPUT_VARIABLE HOMEBREW_LLVM_PREFIX
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT EXISTS "${HOMEBREW_LLVM_PREFIX}")
|
||||||
|
message(FATAL_ERROR "Homebrew LLVM not found. Please run 'brew install llvm'. Path: ${HOMEBREW_LLVM_PREFIX}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Using Homebrew LLVM from: ${HOMEBREW_LLVM_PREFIX}")
|
||||||
|
|
||||||
|
# 3. Set the C and C++ compilers
|
||||||
|
set(CMAKE_C_COMPILER "${HOMEBREW_LLVM_PREFIX}/bin/clang")
|
||||||
|
set(CMAKE_CXX_COMPILER "${HOMEBREW_LLVM_PREFIX}/bin/clang++")
|
||||||
|
|
||||||
|
# 4. Set the system root (sysroot) to the macOS SDK
|
||||||
|
# This correctly points to the system-level headers and libraries.
|
||||||
|
execute_process(
|
||||||
|
COMMAND xcrun --show-sdk-path
|
||||||
|
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
set(CMAKE_SYSROOT "${CMAKE_OSX_SYSROOT}")
|
||||||
|
message(STATUS "Using macOS SDK at: ${CMAKE_SYSROOT}")
|
||||||
|
|
||||||
|
# 5. **[THE CRITICAL FIX]** Explicitly define the C++ standard library include directory.
|
||||||
|
# This forces CMake to add Homebrew's libc++ headers to the search path *before*
|
||||||
|
# any other system paths, resolving the header conflict for the main project
|
||||||
|
# and all dependencies.
|
||||||
|
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "${HOMEBREW_LLVM_PREFIX}/include/c++/v1")
|
||||||
|
|
||||||
|
# 6. Set the default installation path for macOS frameworks
|
||||||
|
set(CMAKE_FIND_FRAMEWORK FIRST)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef YAZE_APP_GFX_PALETTE_MANAGER_H
|
#ifndef YAZE_APP_GFX_PALETTE_MANAGER_H
|
||||||
#define YAZE_APP_GFX_PALETTE_MANAGER_H
|
#define YAZE_APP_GFX_PALETTE_MANAGER_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
Reference in New Issue
Block a user