Skip to content
Open
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
35 changes: 35 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -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'
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
Expand All @@ -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:
Expand Down
24 changes: 24 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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 ..`
<br><br>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:

Expand Down
7 changes: 4 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}