Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake portable build #7232

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5fdd9f1
Basic CMake support
MarcoMartins86 Apr 1, 2019
a119239
-Integrated coders and filters source files into MagickCore
MarcoMartins86 Apr 2, 2019
85a3601
Added license headers and ImageMagick.rc file to projects build
MarcoMartins86 Apr 2, 2019
9d513ec
Parsed the PACKAGE_RELEASE_DATE from last ChangeLog file entry
MarcoMartins86 Apr 2, 2019
62c76ab
Changed binaries name to match version and quantum bitness, also link…
MarcoMartins86 Apr 5, 2019
3f26bf5
Add opencl build support
Jul 31, 2020
57603a8
Adapted @MarcoMartins86 CMake work to the latest version (7.1.0-21)
Cyriuz Jan 29, 2022
7e443b6
CMake: Add missing SIZEOF_VOID_P to the cmake config.h
Cyriuz Feb 4, 2022
fe02242
CMake: Install generated headers properly.
Cyriuz Feb 4, 2022
edf069b
CMake: Expose HDRI option and add it to the binary names.
Cyriuz Feb 4, 2022
bc32fe5
CMake: General cleanup and reordering.
Cyriuz Feb 6, 2022
184e804
CMake: Simplified and organized the compile time options.
Cyriuz Feb 7, 2022
7ddf2bc
CMake: Tweaks to make it build properly with found delegates.
Cyriuz Feb 8, 2022
42f2fae
CMake: Also install license files.
Cyriuz Feb 17, 2022
fea5fe7
CMake: Use find package for OpenCL too.
Cyriuz Feb 18, 2022
d5459fb
CMake: Fix some delegate include dirs missing.
Cyriuz Feb 19, 2022
ad4ac58
CMake: Allow specifying target names of delegates.
Cyriuz Feb 21, 2022
d7af83f
CMake: Fix util install on mac.
Cyriuz Feb 21, 2022
e5d04b5
CMake: Remove outdated copyright notice
Cyriuz Mar 11, 2022
837636b
CMake: Update to work with 7.1.0-28
Cyriuz Mar 25, 2022
82b65d0
CMake: Fix finding of print functions on Windows
Cyriuz Mar 25, 2022
634181f
CMake: Fix mac build after previous windows build fix...
Cyriuz Apr 10, 2022
f264107
CMake: Update to support latest (7.1.0-57)
Cyriuz Jan 3, 2023
1f2ac98
CMake: Expose option for zero configuration
Cyriuz Jan 3, 2023
f11ee3e
CMake: Make sure to link c++ when using the openexr delegate
Cyriuz Jan 4, 2023
4c8484a
CMake: Make sure SETJMP_IS_THREAD_SAFE is set for png to support thre…
Cyriuz Jan 9, 2023
86dd168
CMake: Fix find jxl library name
Cyriuz Jan 11, 2023
04630f4
CMake: Add missing file after updating to 7.1.1-4
Cyriuz Mar 20, 2023
50f38ee
CMake: Fix building without hdri support
Cyriuz Oct 25, 2023
64a6df9
CMake: Fix threaded load of pngs since the define was renamed
Cyriuz Nov 22, 2023
809d90f
CMake: Correct install directory for libs
Cyriuz Dec 9, 2023
19822c6
CMake portable build
mmomtchev Apr 8, 2024
70562c8
add HAVE_LIBHEIF_LIBHEIF_H to configure
mmomtchev Apr 8, 2024
0063b19
explain what everyone is missing
mmomtchev Apr 9, 2024
8df1caa
add the missing HAVE_LIBHEIF_LIBHEIF_H define
mmomtchev Apr 9, 2024
cbd6c35
support files installation (#1)
mmomtchev Apr 27, 2024
a607642
enable 64 bit file access for WASM (#2)
mmomtchev Apr 28, 2024
3ca674f
this does not have to run everyday
mmomtchev Apr 28, 2024
9a527ad
completely disable release
mmomtchev Apr 28, 2024
df2db57
implement a proper libheif/heif.h detection in configure (#3)
mmomtchev Apr 28, 2024
472d0be
always run 'daily' on PR
mmomtchev Apr 29, 2024
9f7754f
allow manual setting of INSTALLED_SUPPORT (#4)
mmomtchev Apr 29, 2024
c0cbb20
`meson` compatibility for `emf.c` (#5)
mmomtchev Apr 30, 2024
3067411
always run daily on PR
mmomtchev May 3, 2024
5b82da0
if building a static lib, prefer static pkgconfig settings (#6)
mmomtchev May 3, 2024
8061934
update the README
mmomtchev May 6, 2024
f9d620e
ability to disable select delegates (#7)
mmomtchev May 6, 2024
26776cb
switch `jemalloc` to opt-in and test enabling/disabling of delegates …
mmomtchev May 6, 2024
5b26af1
use POSIX file structure on Windows (#9)
mmomtchev May 7, 2024
4b5c05e
check if this is needed (#10)
mmomtchev May 20, 2024
4d5c7b9
switch to the official CMake switch name before it is too late (#11)
mmomtchev May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CMake portable build for ImageMagick-7

## Why?

As everyone who distributes open source software based on ImageMagick is aware, ImageMagick has a build system as old as the project itself.

A build system conceived during an era when a PC was considered an inferior computer designed for the home market and portability was defined by having a C compiler for your particular CPU architecture.

Fast-forward 30 years, and in 2024 this build system is a serious obstacle for one of the oldest open source projects that are still actively developed.

On [Conan](https://conan.io), this package does not have Windows support - because it cannot be built without MFC - which is required only for its UI components.

## By Whom?

This project builds upon the ground-breaking work by [`@MarcoMartins86`](https://github.com/MarcoMartins86) and [`@Cyriuz`](https://github.com/Cyriuz).

The `conan` support, `pkg-config` support, installation targets, polishing, documenting and testing work is by [`@mmomtchev`](https://github.com/mmomtchev) aka the *problem-extortion-size-judiciary-corruption* guy.

## By What Means?

I am an engineer who has spent the last 4 years living in total isolation after my ex-employers reached a deal with my lawyer to cover up an explosive accusation of a sexual nature which involves several very large companies, the French police and Judiciary and EU justice system.

I regularly receive various kinds of simultaneous notifications by Google, Facebook, Twitter, reddit, Amazon, Microsoft, StackOverflow, Dropbox, upwork, Steam, Discord and many others in order to intimidate me to shut up.

During those 4 years I have contributed to many large open-source projects who are trying hard to make it seem as they did not notice me - when it finally becomes impossible then I usually get various simultaneous notifications from them and from other criminal parties involved - including the French police.

I create open-source software to make the time pass and to raise awareness for my situation.

## What?

The build instructions can be found in [`README.CMake.md`](https://github.com/mmomtchev/ImageMagick/blob/cmake-portable-build/README.CMake.md) in the project root.

*WARNING* The `cmake-portable-build` branch, the default branch in this repository, is often rebased onto the latest ImageMagick release tag. Do not forget that you have to use:

```
git fetch origin
git reset --hard origin/cmake-portable-build
```

in order to update your local checkout.
293 changes: 293 additions & 0 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
name: CMake portable build

on:
push:
branches:
- cmake-portable-build
- cmake-testing
schedule:
# schedule a regular Sunday Mass to check that
# everything still works
- cron: '30 12 * * 0'

concurrency:
group: cmake-${{ github.ref }}
cancel-in-progress: true


jobs:

conan:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
libtype: [shared, static]
buildtype: [Release, Debug]
exclude:
- buildtype: Debug
libtype: shared
- buildtype: Debug
os: windows-latest

steps:
- uses: actions/checkout@v4
with:
sparse-checkout: conanfile.py
sparse-checkout-cone-mode: false

- name: Get conan
id : conan
uses: turtlebrowser/get-conan@main

- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ~/.conan2
key: ${{ runner.os }}-${{ matrix.libtype }}-${{ matrix.buildtype }}

- name: Restart from scratch every Sunday
run: rm -rf ~/.conan2
shell: bash
if: github.event_name == 'schedule'

- name: Install all delegates
run: |
conan profile detect || echo ok
conan install . -of build --build=missing -o libtype=${{ matrix.libtype }} --settings=build_type=${{ matrix.buildtype }}
echo 'CONAN_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/build/conan_toolchain.cmake"' >> $GITHUB_ENV
shell: bash


native:

runs-on: ${{ matrix.os }}
# This build job is self-contained but it will run faster if
# the conan job has completed (ie all the artifacts are prebuilt)
needs: conan
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
libtype: [shared, static]
provider: [conan, system, pkgconf]
buildtype: [Release, Debug]
zeroconf: [zeroconf, support]
delegates: [default-delegates]
include:
- os: ubuntu-latest
libtype: static
provider: conan
buildtype: Release
zeroconf: support
delegates: custom-delegates
exclude:
- buildtype: Debug
libtype: shared
- buildtype: Debug
os: windows-latest
provider: conan
- os: windows-latest
provider: pkgconf

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Conan (conan/pkgconf)
id : conan
uses: turtlebrowser/get-conan@main
if: matrix.provider == 'conan' || matrix.provider == 'pkgconf'

- name: Setup Visual Studio (system/pkgconf) (Windows)
uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows' && matrix.provider != 'conan'

- name: Restore conan artifacts from shared cache (conan/pkgconf)
id: conan-artifacts
uses: actions/cache/restore@v3
with:
path: ~/.conan2
key: ${{ runner.os }}-${{ matrix.libtype }}-${{ matrix.buildtype }}
if: matrix.provider == 'conan' || matrix.provider == 'pkgconf'

- name: Install all delegates (conan)
run: |
conan profile detect || echo ok
conan install . -of build --build=missing -o libtype=${{ matrix.libtype }} --settings=build_type=${{ matrix.buildtype }}
echo 'CONAN_TOOLCHAIN=-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/build/conan_toolchain.cmake"' >> $GITHUB_ENV
shell: bash
if: matrix.provider == 'conan'

# pkgconf also uses conan to build and install all the libraries, but is not integrated with
# the CMake bulid - it uses the pkg-config file of each library
- name: Install all delegates (pkgconf)
run: |
conan profile detect || echo ok
conan install . -of build --build=missing -o libtype=${{ matrix.libtype }} --settings=build_type=${{ matrix.buildtype }}
echo "PKG_CONFIG_PATH=${{ github.workspace }}/build" >> $GITHUB_ENV
shell: bash
env:
CONAN_GENERATOR: PkgConfigDeps
if: matrix.provider == 'pkgconf'

- name: Generate CMake options
shell: bash
if: matrix.libtype == 'static'
run: echo "LIBTYPE=-DBUILD_SHARED_LIBS=OFF" >> $GITHUB_ENV

- name: Set zero configuration
shell: bash
run: echo "ZERO_CONF=-DZERO_CONFIGURATION_SUPPORT=ON" >> $GITHUB_ENV
if: matrix.zeroconf == 'zeroconf'

- name: Set install prefix
shell: bash
run: echo "INSTALL_PREFIX=${{ github.workspace }}/install" >> $GITHUB_ENV

- name: Set expected delegates (conan/pkgconfig)
shell: bash
run: echo "EXPECTED_DELEGATES=bzlib cairo fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lzma openexr png raw tiff webp xml zlib zstd" >> $GITHUB_ENV
if: matrix.provider == 'conan' || matrix.provider == 'pkgconf'

- name: Set custom delegates
shell: bash
run: |
echo "CUSTOM_DELEGATES=-DHASJEMALLOC=ON -DPNG_DELEGATE=OFF" >> $GITHUB_ENV
echo "EXPECTED_DELEGATES=jemalloc -png" >> $GITHUB_ENV
if: matrix.delegates == 'custom-delegates'

- name: Generate CMake build
shell: bash
run: |
mkdir -p build
cd build
cmake .. ${{ env.CONAN_TOOLCHAIN }} -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }} ${{ env.LIBTYPE }} \
-DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_PREFIX }}" ${{ env.ZERO_CONF }} ${{ env.CUSTOM_DELEGATES }}

- name: Build
run: cmake --build build --config ${{ matrix.buildtype }}

- name: Install
run: cmake --install build --config ${{ matrix.buildtype }}

- name: Build a simple program
shell: bash
run: |
mkdir -p build-test
cd build-test
cmake ../tests ${{ env.CONAN_TOOLCHAIN }} -DCMAKE_BUILD_TYPE=${{ matrix.buildtype }}
cmake --build . --config ${{ matrix.buildtype }} -j 4
env:
ImageMagick_ROOT: ${{ env.INSTALL_PREFIX }}/lib/cmake

- name: Run the test program (POSIX)
run: cd build-test && ./delegates ${{ env.EXPECTED_DELEGATES }}
if: runner.os != 'Windows'

- name: Run the test program (Windows)
run: cd build-test/${{ matrix.buildtype }} && ./delegates.exe ${{ env.EXPECTED_DELEGATES }}
shell: bash
if: runner.os == 'Windows'
env:
PATH: ${{ env.PATH }};${{ env.INSTALL_PREFIX }}/bin

- name: Check required shared libraries (Linux)
run: ldd build/utilities/Magick
if: runner.os == 'Linux'

- name: Check required shared libraries (macOS)
run: otool -L build/utilities/Magick
if: runner.os == 'macOS'

wasm32:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Conan
id : conan
uses: turtlebrowser/get-conan@main

- name: Cache conan artifacts
id: conan-artifacts
uses: actions/cache@v4
with:
path: ~/.conan2
key: wasm-emscripten

- name: Install all delegates
shell: bash
run: |
conan profile detect || echo ok
conan install . -of build -pr:b=default -pr:h=./emscripten.profile --build=missing

- name: Generate CMake build (conan)
run: |
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF

- name: Build
run: cmake --build build --config Release -j 2


configurations:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
quant: [8, 16, 32, 64]
hdri: [true, false]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate CMake options
shell: bash
run: |
echo "HDRI=-DMMAGICK_HDRI_ENABLE=${{ matrix.hdri && 'ON' || 'OFF' }}" >> $GITHUB_ENV
echo "QUANT=-DMAGICKCORE_QUANTUM_DEPTH=${{ matrix.quant }}" >> $GITHUB_ENV

- name: Generate CMake build
shell: bash
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release ${{ env.HDRI }} ${{ env.QUANT }}

- name: Build
run: cmake --build build --config Release -j 4


containers:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache Docker images.
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-builds

- name: Run all available containers
shell: bash
run: |
for CONTAINER in docker/Docker*; do
echo "======================="
echo "======================="
echo "=== ${CONTAINER} ==="
echo "======================="
echo "======================="
docker/run_container_build.sh `echo $CONTAINER | cut -f 2 -d "."`
done
14 changes: 6 additions & 8 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
on:
workflow_dispatch:
schedule:
- cron: 0 6 * * *
#schedule:
#- cron: 0 6 * * *
push:
branches:
- main
paths:
- '.github/workflows/daily.yml'
- cmake-portable-build
- cmake-testing
pull_request:
branches:
- main
paths:
- '.github/workflows/daily.yml'
- cmake-portable-build
- cmake-testing

name: daily
jobs:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
on:
workflow_dispatch:
schedule:
- cron: 0 6 * * *
push:
tags:
- '*'
pull_request:
branches:
- main
paths:
- '.github/workflows/release.yml'
#schedule:
#- cron: 0 6 * * *
#push:
# tags:
# - '*'
#pull_request:
# branches:
# - main
# paths:
# - '.github/workflows/release.yml'

permissions:
contents: write
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@
.dirstamp
.libs
Makefile
Makefile.PL
Makefile.PL

/build*
/CMakeUserPresets.json