Skip to content

Commit

Permalink
(#10512) OpenFX: Add openfx/1.4.0
Browse files Browse the repository at this point in the history
* OpenFX: Add openfx/1.4.0

* OpenFX: System libs

* OpenFX: Lower CMake minimum version

* OpenFX: CXX Standard

* OpenFX: CMake install

* OpenFX: Host shared + LICENCE type

* OpenFX: KEEP_RPATHS

* OpenFX: Find packages
  • Loading branch information
Iswenzz authored Jun 19, 2022
1 parent 7a1d8c5 commit e5cf4e1
Show file tree
Hide file tree
Showing 11 changed files with 540 additions and 0 deletions.
74 changes: 74 additions & 0 deletions recipes/openfx/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.1)
project(openfx VERSION 1.4.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-D_HAS_AUTO_PTR_ETC)

# Flags
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINDOWS -DNOMINMAX")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations")
endif()

# Conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(KEEP_RPATHS)
find_package(EXPAT REQUIRED)

# Macros
set(SOURCE_SUBFOLDER ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder)

# Sources
set(OFX_HEADER_DIR "${SOURCE_SUBFOLDER}/include")
set(OFX_SUPPORT_HEADER_DIR "${SOURCE_SUBFOLDER}/Support/include")
set(OFX_SUPPORT_LIBRARY_DIR "${SOURCE_SUBFOLDER}/Support/Library")
set(OFX_PLUGINS_HEADER_DIR "${SOURCE_SUBFOLDER}/Support/Plugins/include")
set(OFX_HOSTSUPPORT_HEADER_DIR "${SOURCE_SUBFOLDER}/HostSupport/include")
set(OFX_HOSTSUPPORT_LIBRARY_DIR "${SOURCE_SUBFOLDER}/HostSupport/src")

file(GLOB_RECURSE OFX_HEADER_FILES "${OFX_HEADER_DIR}/*.h")
file(GLOB_RECURSE OFX_SUPPORT_HEADER_FILES "${OFX_SUPPORT_HEADER_DIR}/*.h")
file(GLOB_RECURSE OFX_SUPPORT_LIBRARY_FILES "${OFX_SUPPORT_LIBRARY_DIR}/*.cpp")
file(GLOB_RECURSE OFX_PLUGINS_HEADER_FILES "${OFX_PLUGINS_HEADER_DIR}/*.H")
file(GLOB_RECURSE OFX_HOSTSUPPORT_HEADER_FILES "${OFX_HOSTSUPPORT_HEADER_DIR}/*.h")
file(GLOB_RECURSE OFX_HOSTSUPPORT_LIBRARY_FILES "${OFX_HOSTSUPPORT_LIBRARY_DIR}/*.cpp")

# Support
add_library(OfxSupport STATIC
${OFX_HEADER_FILES}
${OFX_SUPPORT_HEADER_FILES}
${OFX_SUPPORT_LIBRARY_FILES})

target_include_directories(OfxSupport PUBLIC
${OFX_HEADER_DIR}
${OFX_SUPPORT_HEADER_DIR})

# HostSupport
add_library(OfxHost
${OFX_HEADER_FILES}
${OFX_HOSTSUPPORT_HEADER_FILES}
${OFX_HOSTSUPPORT_LIBRARY_FILES})

target_link_libraries(OfxHost PUBLIC EXPAT::EXPAT)

target_include_directories(OfxHost PUBLIC
${OFX_HEADER_DIR}
${OFX_HOSTSUPPORT_HEADER_DIR})

# Link
set_target_properties(OfxSupport PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(OfxHost PROPERTIES LINKER_LANGUAGE CXX)

# Install
install(FILES
${OFX_HEADER_FILES}
${OFX_SUPPORT_HEADER_FILES}
${OFX_PLUGINS_HEADER_FILES}
${OFX_HOSTSUPPORT_HEADER_FILES}
DESTINATION "include")

install(TARGETS OfxSupport OfxHost
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
22 changes: 22 additions & 0 deletions recipes/openfx/all/cmake/OpenFX.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Add a new OFX plugin target
# Arguments: TARGET
function(add_ofx_plugin TARGET)
add_library(${TARGET} SHARED)
set_target_properties(${TARGET} PROPERTIES SUFFIX ".ofx" PREFIX "")

if(NOT DEFINED OFX_SUPPORT_SYMBOLS_DIR)
if (NOT DEFINED CONAN_LIB_DIRS_OPENFX)
message(FATAL_ERROR "Define OFX_SUPPORT_SYMBOLS_DIR to use add_ofx_plugin().")
endif()
set(OFX_SUPPORT_SYMBOLS_DIR ${CONAN_LIB_DIRS_OPENFX}/symbols)
endif()

# Add extra flags to the link step of the plugin
if(APPLE)
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "-bundle -fvisibility=hidden -exported_symbols_list,${OFX_SUPPORT_SYMBOLS_DIR}/osx.symbols")
elseif(WIN32)
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/def:${OFX_SUPPORT_SYMBOLS_DIR}/windows.symbols")
else()
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "-Wl,-fvisibility=hidden,--version-script=${OFX_SUPPORT_SYMBOLS_DIR}/linux.symbols")
endif()
endfunction()
4 changes: 4 additions & 0 deletions recipes/openfx/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.4.0":
url: "https://github.com/ofxa/openfx/archive/refs/tags/OFX_Release_1_4_TAG.tar.gz"
sha256: "1f2d057b2cff025979f631f092f138020315524d4c0c0dcc2dccdadc2313a62f"
88 changes: 88 additions & 0 deletions recipes/openfx/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from conans import ConanFile, CMake, tools
import os


class openfx(ConanFile):
name = "openfx"
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://openeffects.org"
description = "OpenFX image processing plug-in standard."
topics = ("image-processing", "standard")

settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"shared": [True, False],
}
default_options = {
"fPIC": True,
"shared": False,
}
requires = ("opengl/system", "expat/2.4.8")
exports_sources = "CMakeLists.txt", "cmake/*", "symbols/*"

generators = "cmake", "cmake_find_package"
_cmake = None

def source(self):
tools.get(
**self.conan_data["sources"][self.version],
destination="source_subfolder",
strip_root=True
)

def configure(self):
if self.options.shared:
del self.options.fPIC

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

@property
def _build_modules(self):
return [os.path.join("lib", "cmake", "OpenFX.cmake")]

def package(self):
cmake = self._configure_cmake()

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))

cmake.install()

self.copy("*.symbols", src="symbols", dst="lib/symbols")
self.copy("*.cmake", src="cmake", dst="lib/cmake")
self.copy("LICENSE", src="source_subfolder/Support", dst="licenses")
self.copy("readme.md")

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "openfx"
self.cpp_info.names["cmake_find_package_multi"] = "openfx"

self.cpp_info.set_property("cmake_build_modules", self._build_modules)
self.cpp_info.builddirs.append(os.path.join("lib", "cmake"))
self.cpp_info.build_modules["cmake_find_package"] = self._build_modules
self.cpp_info.build_modules["cmake_find_package_multi"] = self._build_modules

if self.options.shared:
self.cpp_info.libs = ["OfxSupport"]
else:
self.cpp_info.libs = ["OfxHost", "OfxSupport"]

if self.settings.os in ("Linux", "FreeBSD"):
self.cpp_info.system_libs.extend(["GL"])
if self.settings.os == "Macos":
self.cpp_info.frameworks = ["CoreFoundation", "OpenGL"]
7 changes: 7 additions & 0 deletions recipes/openfx/all/symbols/linux.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
OFX_1.0 {
global:
OfxGetNumberOfPlugins;
OfxGetPlugin;
local:
*;
};
2 changes: 2 additions & 0 deletions recipes/openfx/all/symbols/osx.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_OfxGetPlugin
_OfxGetNumberOfPlugins
3 changes: 3 additions & 0 deletions recipes/openfx/all/symbols/windows.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
EXPORTS
OfxGetPlugin
OfxGetNumberOfPlugins
21 changes: 21 additions & 0 deletions recipes/openfx/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-D_HAS_AUTO_PTR_ETC)

# Conan
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(openfx REQUIRED CONFIG)

# Flags
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWINDOWS -DNOMINMAX")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations")
endif()

# Build
add_executable(test_package invert.cpp)
target_link_libraries(test_package openfx::openfx)
17 changes: 17 additions & 0 deletions recipes/openfx/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run("%s --help" % bin_path, run_environment=True)
Loading

0 comments on commit e5cf4e1

Please sign in to comment.