diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
new file mode 100644
index 0000000..d02b4d7
--- /dev/null
+++ b/.github/workflows/cmake.yml
@@ -0,0 +1,35 @@
+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: Install dependencies (macOS)
+ if: runner.os == 'macOS'
+ run: brew install libomp
+
+ - name: Setup vcpkg
+ uses: lukka/run-vcpkg@v11
+ with:
+ vcpkgGitCommitId: 25b458671af03578e6a34edd8f0d1ac85e084df4 # Matches builtin-baseline in vcpkg.json
+ vcpkgJsonGlob: 'vcpkg.json'
+
+ - name: Configure CMake
+ uses: lukka/run-cmake@v10
+ with:
+ configurePreset: 'vcpkg'
+ buildPreset: 'vcpkg'
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d4bf4de..6610825 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,19 @@ 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)
+ 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()
+
### Add defaults for cmake
# These defaults need to be included before the project() call.
include(DefineCMakeDefaults)
@@ -17,7 +31,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/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 beb9d72..fbedfed 100644
--- a/README.md
+++ b/README.md
@@ -41,6 +41,26 @@ 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. It automatically handles dependencies like OpenMP.
+
+1. Install [vcpkg](https://vcpkg.io/) and set the `VCPKG_ROOT` environment variable.
+2. Run the following commands from the project root:
+ ```bash
+ # Configure using the vcpkg preset
+ cmake --preset vcpkg
+
+ # Build the project
+ cmake --build --preset vcpkg
+ ```
+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 +73,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:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be49283..4a32f91 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,10 @@ 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)
+ if (MSVC)
+ target_compile_options(rtprocess PRIVATE /openmp:experimental)
+ endif()
endif()
if (VERBOSE)
diff --git a/vcpkg.json b/vcpkg.json
new file mode 100644
index 0000000..3438f83
--- /dev/null
+++ b/vcpkg.json
@@ -0,0 +1,18 @@
+{
+ "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
+ }
+ ],
+ "builtin-baseline": "25b458671af03578e6a34edd8f0d1ac85e084df4"
+}
\ No newline at end of file