Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 50 additions & 47 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,88 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "master"]
branches: [ "master" ]
pull_request:
branches: [ "master"]
branches: [ "master" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: true

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [windows-latest, ubuntu-latest]
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
c_compiler: [gcc, clang, cl, x86_64-w64-mingw32-gcc]

include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
exe_suffix: .exe
mingw: false

- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
exe_suffix: ""
mingw: false

- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exe_suffix: ""
mingw: false

- os: ubuntu-latest
c_compiler: x86_64-w64-mingw32-gcc
cpp_compiler: x86_64-w64-mingw32-g++
exe_suffix: .exe
mingw: true

exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: windows-latest
c_compiler: x86_64-w64-mingw32-gcc
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v3

- name: Git update submodules
run: |
git submodule update --init --recursive --depth 1
- uses: actions/checkout@v3

- name: Install MinGW (only if mingw is true)
if: matrix.mingw == true
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Update submodules
run: git submodule update --init --recursive --depth 1

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Set build directory
id: vars
run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Configure CMake
run: >
cmake -S . -B ${{ github.workspace }}/build
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
${{ matrix.mingw && '-DCMAKE_TOOLCHAIN_FILE=mingw-w64-x86_64.cmake' || '' }}

- name: Test windows
working-directory: ${{ steps.strings.outputs.build-output-dir }}/Example/Release
if: matrix.os == 'windows-latest'
run: |
./ImageLoaderExample.exe
- name: Build
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }}

- name: Test Ubuntu
working-directory: ${{ steps.strings.outputs.build-output-dir }}/Example
if: matrix.os == 'ubuntu-latest'
run: |
./ImageLoaderExample
- name: Run tests
if: matrix.mingw == false
working-directory: >-
${{ github.workspace }}/build/Example${{
matrix.os == 'windows-latest' && format('/{0}', matrix.build_type) || ''
}}
run: ./ImageLoaderExample${{ matrix.exe_suffix }}
13 changes: 11 additions & 2 deletions Codecs/CodecJPG/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ endif()

# ======== Platform-specific file extensions ========
if(WIN32)
set(JPG_RUNTIME_NAME "turbojpeg.dll")
set(JPG_IMPLIB_NAME "turbojpeg.lib")
if (MINGW)
set(JPG_RUNTIME_NAME "libturbojpeg.dll")
set(JPG_IMPLIB_NAME "libturbojpeg.dll.a")
else()
set(JPG_RUNTIME_NAME "turbojpeg.dll")
set(JPG_IMPLIB_NAME "turbojpeg.lib")
endif()
elseif(APPLE)
set(JPG_RUNTIME_NAME "libturbojpeg.dylib")
set(JPG_IMPLIB_NAME "") # No import libs on macOS
Expand Down Expand Up @@ -50,6 +55,10 @@ set(LibJpegTurboArgs
-DCMAKE_INSTALL_PREFIX=${TurboJpegBinBaseDir}/install
)

if (CMAKE_TOOLCHAIN_FILE)
get_filename_component(CMAKE_TOOLCHAIN_FILE_ABSOLUTE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
list(APPEND LibJpegTurboArgs -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE_ABSOLUTE})
endif()
# Enable NASM on Windows if needed
if(WIN32 AND NOT ${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
list(APPEND LibJpegTurboArgs -DCMAKE_ASM_NASM_COMPILER=${NASMPATH})
Expand Down
2 changes: 1 addition & 1 deletion External/libpng
Submodule libpng updated 1 files
+12 −0 README.md
43 changes: 43 additions & 0 deletions mingw-w64-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

#Usage: cmake -DCMAKE_TOOLCHAIN_FILE=mingw-w64-x86_64.cmake

set(CMAKE_SYSTEM_NAME Windows)


set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

# cross compilers to use for C, C++ and Fortran
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_SYSTEM_VERSION 10)


function (createSymLink target symlink)
cmake_path(GET symlink PARENT_PATH parentPath)
file(MAKE_DIRECTORY ${parentPath})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${target} ${symlink})
endfunction()

# MINGW defaults max SDK version to Windows server 2003 (0x0502)
# For supporting newer functionality, overriding is needed, otherwise code won't compile
# override with Windows 10 (0x0A00) SDK version
add_compile_definitions(_WIN32_WINNT=0x0A00)

set(CASE_SENSITIVE_FIX_FOR_MINGW_PATH ${CMAKE_CURRENT_BINARY_DIR}/mingw-w64)
createSymLink(/usr/x86_64-w64-mingw32/include/windows.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/Windows.h)
createSymLink(/usr/x86_64-w64-mingw32/include/shlobj.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/ShlObj.h)
createSymLink(/usr/x86_64-w64-mingw32/include/dbghelp.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/DbgHelp.h)
createSymLink(/usr/x86_64-w64-mingw32/include/commctrl.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/CommCtrl.h)
createSymLink(/usr/x86_64-w64-mingw32/include/shellscalingapi.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/ShellScalingApi.h)
createSymLink(/usr/x86_64-w64-mingw32/include/psapi.h ${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include/Psapi.h)

include_directories(${CASE_SENSITIVE_FIX_FOR_MINGW_PATH}/Include)