Skip to content

Commit

Permalink
update build system, same setup for debian, macos, mingw, msvc
Browse files Browse the repository at this point in the history
Signed-off-by: Martin <Ho-Ro@users.noreply.github.com>
  • Loading branch information
Ho-Ro committed Dec 18, 2023
1 parent 49e0efe commit d00e32d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 36 deletions.
45 changes: 19 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,14 @@ env:
BUILD_TYPE: Release


# jobs:
# build_check:
# strategy:
# # do not stop on 1st fail
# fail-fast: false
# matrix:
# # GitHub runner macos build is broken: https://github.com/actions/runner-images/issues/577
# # Could not symlink bin/2to3-3.11 Target /usr/local/bin/2to3-3.11 already exists.
# # Could not symlink bin/2to3 Target /usr/local/bin/2to3 already exists.
# # hack fix: https://github.com/actions/setup-python/issues/577#issuecomment-1365231822
# os: [ubuntu-22.04, macos-12, windows-2022]
#
# runs-on: ${{ matrix.os }}
#
#
# steps:


jobs:

# --- Linux (Ubuntu) steps ---
# ----------------------------
# --- Linux (Ubuntu) steps ---
# ----------------------------
#
linux-x86_64:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:

# --- Clone the latest commit ---
Expand All @@ -74,7 +59,7 @@ jobs:
run: |
mkdir build
sudo apt update
#sudo apt -y upgrade
# sudo apt -y upgrade
sudo apt install g++ make cmake fakeroot rpm qttools5-dev libfftw3-dev binutils-dev \
libusb-1.0-0-dev libqt5opengl5-dev mesa-common-dev libgl1-mesa-dev libgles2-mesa-dev
Expand Down Expand Up @@ -106,9 +91,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# --- macOS steps ---
# -------------------
# --- macOS steps ---
# -------------------
#
macos-x86_64:
runs-on: macos-latest
runs-on: macos-12
steps:

# --- Clone the latest commit ---
Expand Down Expand Up @@ -189,7 +177,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# --- Windows steps ---
# ---------------------------
# --- Windows MINGW steps ---
# ---------------------------
#
windows-mingw_w64:
runs-on: windows-2022
steps:
Expand Down Expand Up @@ -256,7 +247,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# --- Windows MSVC steps ---
# --------------------------
# --- Windows MSVC steps ---
# --------------------------
#
windows-msvc_x64:
runs-on: windows-2022
steps:
Expand All @@ -282,7 +276,6 @@ jobs:

- name: Setup Windows MSVC Build
run:
copy CMakeListsMSVC.txt CMakeLists.txt &
md build &
call "%VCINSTALLDIR%/Auxiliary/Build/vcvars64.bat" &
cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH=%Qt5_DIR% -DCMAKE_BUILD_TYPE=Release -Bbuild
Expand Down
39 changes: 29 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,41 @@ if (GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
)
# get the git version
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
COMMAND ${GIT_EXECUTABLE} describe --tags --long --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# unstable release?
string(FIND ${VERSION} "unstable" REGULAR)
if( ${REGULAR} ) # not unstable
set( PACKAGE_VERSION ${VERSION} ) # x.y.z
else() # unstable
# add commit hash to version
# devdrop or release?
string(FIND ${VERSION} "devdrop-0-g" DEVDROP_POS)
string(FIND ${VERSION} "-0-g" ZERO_POS)
if( ${DEVDROP_POS} EQUAL 0 ) # "devdrop-x.y.z-p-gxxxxxxx(-dirty)"
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --long --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set( VERSION "devdrop-${VERSION}" )
elseif( ${ZERO_POS} GREATER 0 ) # x.y.z(-dirty)
# message(STATUS "TAG")
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else() # "x.y.z-p-gxxxxxxx(-dirty)"
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --long --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set( PACKAGE_VERSION "${VERSION}-unstable" ) # "x.y.z-p-gxxxxxxx-unstable"
endif()
set( PACKAGE_VERSION ${VERSION} )
endif()

message(STATUS "VERSION: ${VERSION}")
message(STATUS "PACKAGE_VERSION: ${PACKAGE_VERSION}")

set(OpenGL_GL_PREFERENCE GLVND)
Expand All @@ -49,7 +62,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/")

INCLUDE_DIRECTORIES(".")

add_compile_options(-Wall -Wextra -pedantic)
if(MSVC)
# NOMINMAX to avoid clash with std::min or std::max due to silly macros min and max
add_compile_options(/W4 /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX)
else()
add_compile_options(-Wall -Wextra -pedantic)
endif()


# Silence nasty warnings "parameter passing for argument of type ... changed in GCC 7.1"
if(CMAKE_COMPILER_IS_GNUCXX)
Expand Down

0 comments on commit d00e32d

Please sign in to comment.