1
0
mirror of synced 2024-09-23 19:18:24 +02:00

build: Use llvm-ar and llvm-ranlib on Windows

This commit is contained in:
WerWolv 2023-07-14 21:51:18 +02:00
parent 04b56c3d4d
commit 6c4fdd146f
4 changed files with 49 additions and 10 deletions

View File

@ -74,10 +74,7 @@ jobs:
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DCMAKE_INSTALL_PREFIX="$PWD/install" \
-DCREATE_PACKAGE=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="-fuse-ld=lld" \
-DCMAKE_CXX_FLAGS="-fuse-ld=lld" \
-DIMHEX_USE_DEFAULT_BUILD_SETTINGS=ON \
-DIMHEX_PATTERNS_PULL_MASTER=ON \
-DIMHEX_COMMIT_HASH_SHORT="${GITHUB_SHA::7}" \
-DIMHEX_COMMIT_HASH_LONG="${GITHUB_SHA}" \

View File

@ -11,6 +11,7 @@ option(IMHEX_IGNORE_BAD_COMPILER "Allow compiling with an unsupported compiler"
option(IMHEX_USE_GTK_FILE_PICKER "Use GTK file picker instead of xdg-desktop-portals" OFF)
option(IMHEX_DISABLE_STACKTRACE "Disables support for printing stack traces" OFF)
option(IMHEX_ENABLE_LTO "Enables Link Time Optimizations if possible" OFF)
option(IMHEX_USE_DEFAULT_BUILD_SETTINGS "Use default build settings" OFF)
# Basic compiler and cmake configurations
set(CMAKE_CXX_STANDARD 23)
@ -20,9 +21,9 @@ set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules")
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")
# Setup project
configureCMake()
loadVersion(IMHEX_VERSION)
setVariableInParent(IMHEX_VERSION ${IMHEX_VERSION})
configureCMake()
project(imhex
LANGUAGES C CXX VERSION ${IMHEX_VERSION}
DESCRIPTION "The ImHex Hex Editor"

View File

@ -17,13 +17,11 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER_LAUNCHER": "ccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_C_FLAGS": "-fuse-ld=lld",
"CMAKE_CXX_FLAGS": "-fuse-ld=lld",
"IMHEX_PATTERNS_PULL_MASTER": "ON",
"CMAKE_INSTALL_PREFIX": "./install",
"USE_SYSTEM_CURL": "ON"
"USE_SYSTEM_CURL": "ON",
"USE_SYSTEM_CAPSTONE": "ON",
"IMHEX_USE_DEFAULT_BUILD_SETTINGS": "ON"
}
},
{

View File

@ -283,6 +283,48 @@ function(JOIN OUTPUT GLUE)
endfunction()
macro(configureCMake)
message(STATUS "Configuring ImHex v${IMHEX_VERSION}")
# Configure use of recommended build tools
if (IMHEX_USE_DEFAULT_BUILD_SETTINGS)
message(STATUS "Configuring CMake to use recommended build tools...")
find_program(CCACHE_PATH ccache)
find_program(NINJA_PATH ninja)
find_program(LD_LLD_PATH ld.lld)
find_program(AR_LLVMLIBS_PATH llvm-ar)
find_program(RANLIB_LLVMLIBS_PATH llvm-ranlib)
if (CCACHE_PATH)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PATH})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PATH})
else ()
message(WARNING "ccache not found!")
endif ()
if (AR_LLVMLIBS_PATH)
set(CMAKE_AR ${AR_LLVMLIBS_PATH})
else ()
message(WARNING "llvm-ar not found, using default ar!")
endif ()
if (RANLIB_LLVMLIBS_PATH)
set(CMAKE_RANLIB ${RANLIB_LLVMLIBS_PATH})
else ()
message(WARNING "llvm-ranlib not found, using default ranlib!")
endif ()
if (LD_LLD_PATH)
set(CMAKE_LINKER ${LD_LLD_PATH})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
else ()
message(WARNING "lld not found, using default linker!")
endif ()
set(CMAKE_GENERATOR Ninja)
endif()
# Enable LTO if desired and supported
if (IMHEX_ENABLE_LTO)
include(CheckIPOSupported)
@ -290,6 +332,7 @@ macro(configureCMake)
check_ipo_supported(RESULT result)
if (result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "LTO enabled!")
else ()
message(WARNING "LTO is not supported!")
endif ()