From 291f49d22f7e8122a82a5896edaa2a09f3afae99 Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 13:48:49 -0500 Subject: [PATCH 1/6] Add vcpkg manifest and modernize OpenMP for macOS compatibility --- CMakeLists.txt | 10 ++++++++++ src/CMakeLists.txt | 4 +--- vcpkg.json | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index d4bf4de..2b64c1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # Required cmake version cmake_minimum_required(VERSION 3.5.0) cmake_policy(SET CMP0048 NEW) +cmake_policy(SET CMP0074 NEW) if (NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") @@ -9,6 +10,15 @@ endif() # and find_package() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") +if(APPLE) + # On macOS, OpenMP is often provided by Homebrew's libomp. + # We provide hints to find_package(OpenMP) to locate it. + if(NOT OpenMP_ROOT AND EXISTS "/opt/homebrew/opt/libomp") + set(OpenMP_ROOT "/opt/homebrew/opt/libomp") + endif() + message(STATUS "Using OpenMP_ROOT: ${OpenMP_ROOT}") +endif() + ### Add defaults for cmake # These defaults need to be included before the project() call. include(DefineCMakeDefaults) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be49283..0b1a6a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,9 +34,7 @@ endif() target_compile_options(rtprocess PRIVATE - ${OpenMP_CXX_FLAGS} ${DEFAULT_CXX_COMPILE_FLAGS} - ${OpenMP_CXX_FLAGS} ${PROC_FLAGS}) set_property(TARGET rtprocess @@ -56,7 +54,7 @@ set_property(TARGET SOVERSION ${LIBRARY_SOVERSION}) if (OpenMP_FOUND) - target_link_libraries(rtprocess PRIVATE ${OpenMP_CXX_LIBRARIES}) + target_link_libraries(rtprocess PRIVATE OpenMP::OpenMP_CXX) endif() if (VERBOSE) diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..c0842cd --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "librtprocess", + "version": "0.12.0", + "description": "RawTherapee's processing algorithms library", + "homepage": "https://github.com/CarVac/librtprocess", + "license": "GPL-3.0-or-later", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} From 5e74ecff797391fce5a5f3a90f617eb1ba05180f Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 13:50:20 -0500 Subject: [PATCH 2/6] Update README with vcpkg instructions and sync project version to 0.12.0 --- CMakeLists.txt | 2 +- README.md | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b64c1d..24b03e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ include(DefineCMakeDefaults) # and -DCMAKE_BUILD_TYPE=AddressSanitizer include(DefineCompilerFlags) -project(rtprocess VERSION 0.11.0 LANGUAGES CXX) +project(rtprocess VERSION 0.12.0 LANGUAGES CXX) # SOVERSION scheme: MAJOR.MINOR.PATCH # If there was an incompatible interface change: diff --git a/README.md b/README.md index beb9d72..06cd48e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,24 @@ This is version 0.12.0, which furnishes the following routines: ## Build instructions: +### Using vcpkg (Recommended) + +This is the easiest way to build the project as it handles dependencies like OpenMP automatically. + +1. Install [vcpkg](https://vcpkg.io/). +2. Run the following commands from the project root: + ```bash + # Set VCPKG_ROOT if not already set + cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake + cmake --build build + ``` +3. To install: + ```bash + cmake --install build + ``` + +### Standard CMake build + 1. Make a subdirectory named `build`, and `cd` to that directory. 2. Run `cmake -DCMAKE_BUILD_TYPE="Release" ..` 3. Run `make` @@ -53,13 +71,10 @@ Build instructions for Windows msys2 environment: 3. Run `make` 4. Run `make install`. -Build instructions for macOS: +### Legacy macOS build instructions -Prerequisites: XCode/XCode command line tools. An optional SDK (this example uses macOS 10.9). An implementation of OpenMP, for example `libiomp.5`. -1. Make a subdirectory named `build`, and `cd` to that directory. -2. On macOS 10.12 _Sierra_, run `sudo cmake -DCMAKE_BUILD_TYPE="release" -DPROC_TARGET_NUMBER="1" -DCMAKE_C_COMPILER="clang-mp-3.9" -DCMAKE_CXX_COMPILER="clang++-mp-3.9" -DCMAKE_CXX_FLAGS=-I/opt/local/include -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.9" -DOpenMP_C_FLAGS=-fopenmp="libiomp5" -DOpenMP_CXX_FLAGS=-fopenmp="libiomp5" -DOpenMP_C_LIB_NAMES="libiomp5" -DOpenMP_CXX_LIB_NAMES="libiomp5" -DOpenMP_libiomp5_LIBRARY="/opt/local" -DCMAKE_INSTALL_PREFIX=/opt/local ..` -

On macOS 10.14 _Mojave_, run `cmake -DCMAKE_BUILD_TYPE="release" -DPROC_TARGET_NUMBER="1" -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_CXX_FLAGS=-I/opt/local/include -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.9" -DOpenMP_CXX_FLAGS=-fopenmp=lomp -DOpenMP_CXX_LIB_NAMES="libomp" -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp /opt/local/lib/libomp.dylib -I/opt/local/include" -DOpenMP_CXX_LIB_NAMES="libomp" -DOpenMP_libomp_LIBRARY=/opt/local/lib/libomp.dylib -DCMAKE_INSTALL_PREFIX=/opt/local -DCMAKE_SHARED_LINKER_FLAGS=-L/opt/local/lib ..` -3. Run `sudo make -j$(sysctl -n hw.ncpu) install` +Prerequisites: XCode/XCode command line tools. An implementation of OpenMP (e.g., from Homebrew/MacPorts). +Note: Using the `vcpkg` method above is highly recommended as it handles OpenMP flags correctly. Optional switches to be included in the `cmake` command: From 2ea99118c38a62ddbd0695b4af8f202492fa983e Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 13:56:42 -0500 Subject: [PATCH 3/6] Add CMakePresets.json and update README for easier vcpkg builds --- CMakePresets.json | 24 ++++++++++++++++++++++++ README.md | 12 +++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 CMakePresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..4bf33ae --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,24 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "vcpkg", + "displayName": "vcpkg Preset", + "description": "Build using vcpkg toolchain", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + }, + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { + "name": "vcpkg", + "configurePreset": "vcpkg" + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 06cd48e..fbedfed 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,16 @@ This is version 0.12.0, which furnishes the following routines: ### Using vcpkg (Recommended) -This is the easiest way to build the project as it handles dependencies like OpenMP automatically. +This is the easiest way to build the project. It automatically handles dependencies like OpenMP. -1. Install [vcpkg](https://vcpkg.io/). +1. Install [vcpkg](https://vcpkg.io/) and set the `VCPKG_ROOT` environment variable. 2. Run the following commands from the project root: ```bash - # Set VCPKG_ROOT if not already set - cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake - cmake --build build + # Configure using the vcpkg preset + cmake --preset vcpkg + + # Build the project + cmake --build --preset vcpkg ``` 3. To install: ```bash From 1af72797b96910b059e6f1d53057dd8dfb816fb3 Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 20:04:03 -0500 Subject: [PATCH 4/6] Add CI/CD --- .github/workflows/cmake.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..59dac35 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,30 @@ +name: CMake Build + +on: + push: + branches: [ "main", "master" ] + pull_request: + branches: [ "main", "master" ] + +jobs: + build: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgJsonGlob: 'vcpkg.json' + + - name: Configure CMake + uses: lukka/run-cmake@v10 + with: + configurePreset: 'vcpkg' + buildPreset: 'vcpkg' From 763bc2c92559d56ef72be586bbac57233d9b1458 Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 20:24:49 -0500 Subject: [PATCH 5/6] include vcpkg git commit --- .github/workflows/cmake.yml | 1 + vcpkg.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 59dac35..546a68c 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -21,6 +21,7 @@ jobs: - name: Setup vcpkg uses: lukka/run-vcpkg@v11 with: + vcpkgGitCommitId: 25b458671af03578e6a34edd8f0d1ac85e084df4 # Matches builtin-baseline in vcpkg.json vcpkgJsonGlob: 'vcpkg.json' - name: Configure CMake diff --git a/vcpkg.json b/vcpkg.json index c0842cd..3438f83 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -13,5 +13,6 @@ "name": "vcpkg-cmake-config", "host": true } - ] -} + ], + "builtin-baseline": "25b458671af03578e6a34edd8f0d1ac85e084df4" +} \ No newline at end of file From b31385436902eaaca5835d0ef10104d1a93be291 Mon Sep 17 00:00:00 2001 From: Omer Calakos-Mano Date: Sat, 10 Jan 2026 20:40:04 -0500 Subject: [PATCH 6/6] fixup openmp compile --- .github/workflows/cmake.yml | 4 ++++ CMakeLists.txt | 8 ++++++-- src/CMakeLists.txt | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 546a68c..d02b4d7 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -18,6 +18,10 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + run: brew install libomp + - name: Setup vcpkg uses: lukka/run-vcpkg@v11 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 24b03e7..6610825 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,12 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") if(APPLE) # On macOS, OpenMP is often provided by Homebrew's libomp. # We provide hints to find_package(OpenMP) to locate it. - if(NOT OpenMP_ROOT AND EXISTS "/opt/homebrew/opt/libomp") - set(OpenMP_ROOT "/opt/homebrew/opt/libomp") + if(NOT OpenMP_ROOT) + if(EXISTS "/opt/homebrew/opt/libomp") + set(OpenMP_ROOT "/opt/homebrew/opt/libomp") + elseif(EXISTS "/usr/local/opt/libomp") + set(OpenMP_ROOT "/usr/local/opt/libomp") + endif() endif() message(STATUS "Using OpenMP_ROOT: ${OpenMP_ROOT}") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b1a6a0..4a32f91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,9 @@ set_property(TARGET if (OpenMP_FOUND) target_link_libraries(rtprocess PRIVATE OpenMP::OpenMP_CXX) + if (MSVC) + target_compile_options(rtprocess PRIVATE /openmp:experimental) + endif() endif() if (VERBOSE)