mirror of
https://github.com/ashaduri/gsmartcontrol.git
synced 2026-09-25 21:35:33 +00:00
Create and use cmake toolchains for msys2.
This commit is contained in:
@@ -43,9 +43,7 @@ jobs:
|
||||
run: >
|
||||
cmake $GITHUB_WORKSPACE
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DAPP_BUILD_EXAMPLES=ON
|
||||
-DAPP_BUILD_TESTS=ON
|
||||
-DAPP_COMPILER_ENABLE_WARNINGS=ON
|
||||
-DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/linux-dev.cmake"
|
||||
|
||||
- name: Build
|
||||
shell: bash
|
||||
@@ -74,8 +72,8 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include: [
|
||||
{ msystem: MINGW64, arch: x86_64 },
|
||||
{ msystem: MINGW32, arch: i686 }
|
||||
{ msystem: MINGW64, arch: x86_64, platform: win64 },
|
||||
{ msystem: MINGW32, arch: i686, platform: win32 }
|
||||
]
|
||||
|
||||
steps:
|
||||
@@ -105,11 +103,10 @@ jobs:
|
||||
- name: Configure CMake
|
||||
shell: msys2 {0}
|
||||
run: >
|
||||
cmake -B build -S "$GITHUB_WORKSPACE" -G "MSYS Makefiles"
|
||||
cmake -B build -S "$GITHUB_WORKSPACE"
|
||||
-G "MSYS Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DAPP_BUILD_EXAMPLES=ON
|
||||
-DAPP_BUILD_TESTS=ON
|
||||
-DAPP_COMPILER_ENABLE_WARNINGS=ON
|
||||
-DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/toolchains/${{ matrix.platform }}-mingw-msys2.cmake"
|
||||
|
||||
- name: Build
|
||||
shell: msys2 {0}
|
||||
|
||||
@@ -128,16 +128,19 @@ if (WIN32)
|
||||
|
||||
option(APP_WINDOWS_SYSROOT "Location of system root for Windows binaries, for packing" "")
|
||||
if (NOT APP_WINDOWS_SYSROOT)
|
||||
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(APP_WINDOWS_SYSROOT "c:\\msys64\\mingw64")
|
||||
else()
|
||||
set(APP_WINDOWS_SYSROOT "c:\\msys64\\mingw32")
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "${APP_WINDOWS_SYSROOT}" APP_WINDOWS_SYSROOT)
|
||||
else() # Cross-compiling
|
||||
# if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
|
||||
# if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
# set(APP_WINDOWS_SYSROOT "/mingw64")
|
||||
# else()
|
||||
# set(APP_WINDOWS_SYSROOT "/mingw32")
|
||||
# endif()
|
||||
# file(TO_CMAKE_PATH "${APP_WINDOWS_SYSROOT}" APP_WINDOWS_SYSROOT)
|
||||
# else() # Cross-compiling
|
||||
set(APP_WINDOWS_SYSROOT "${CMAKE_FIND_ROOT_PATH}")
|
||||
endif()
|
||||
# endif()
|
||||
endif()
|
||||
if (NOT APP_WINDOWS_SYSROOT)
|
||||
message(FATAL_ERROR "APP_WINDOWS_SYSROOT or CMAKE_FIND_ROOT_PATH must be set to environment root directory when compiling for Windows.")
|
||||
endif()
|
||||
message(STATUS "APP_WINDOWS_SYSROOT: ${APP_WINDOWS_SYSROOT}")
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2024 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
# Windows 32-bit production version with mingw/msys2.
|
||||
# Use with:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=...
|
||||
|
||||
# Target OS
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Specify the compiler
|
||||
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||
#set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
||||
|
||||
# The target environment. This is a path which is valid for msys2.
|
||||
set(CMAKE_FIND_ROOT_PATH /mingw32)
|
||||
|
||||
# Enable LTO for Release build
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# Increase optimizations of Release builds
|
||||
add_compile_options("$<$<CONFIG:RELEASE>:-g0 -O3 -s>")
|
||||
|
||||
# Enable common CPU optimizations
|
||||
add_compile_options(-march=i686 -mtune=generic)
|
||||
|
||||
|
||||
# Developer options
|
||||
set(APP_COMPILER_ENABLE_WARNINGS ON)
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
set(APP_BUILD_TESTS ON)
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
###############################################################################
|
||||
# License: BSD Zero Clause License file
|
||||
# Copyright:
|
||||
# (C) 2024 Alexander Shaduri <ashaduri@gmail.com>
|
||||
###############################################################################
|
||||
|
||||
# Windows 64-bit production version with mingw/msys2.
|
||||
# Use with:
|
||||
# cmake -DCMAKE_TOOLCHAIN_FILE=...
|
||||
|
||||
# Target OS
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# Specify the compiler
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
#set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
|
||||
# The target environment. This is a path which is valid for msys2.
|
||||
set(CMAKE_FIND_ROOT_PATH /mingw64)
|
||||
|
||||
# Enable LTO for Release build
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# Increase optimizations of Release builds
|
||||
add_compile_options("$<$<CONFIG:RELEASE>:-g0 -O3 -s>")
|
||||
|
||||
# Enable common CPU optimizations
|
||||
add_compile_options(-mtune=generic)
|
||||
|
||||
|
||||
# Developer options
|
||||
set(APP_COMPILER_ENABLE_WARNINGS ON)
|
||||
set(APP_BUILD_EXAMPLES ON)
|
||||
set(APP_BUILD_TESTS ON)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user