-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c380ed
commit 88f2872
Showing
9 changed files
with
275 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.gitattributes export-ignore | ||
.github/ export-ignore | ||
ci-docker.nix export-ignore | ||
|
||
CMakeLists.txt export-subst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# DEV_HASH: $Format:%H$ | ||
|
||
cmake_minimum_required(VERSION 3.12) | ||
cmake_policy(SET CMP0048 NEW) | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
|
||
project(opencv-swig VERSION 1.0.0 LANGUAGES NONE) | ||
|
||
if(WIN32 AND NOT CYGWIN) | ||
set(DEF_INSTALL_CMAKE_DIR CMake) | ||
else() | ||
set(DEF_INSTALL_CMAKE_DIR "lib/cmake/OpenCV-SWIG") | ||
set(DEF_INSTALL_SWIGLIB_DIR "share/swig/any") | ||
endif() | ||
|
||
set( | ||
OpenCV-SWIG_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH | ||
"Installation directory for CMake files" | ||
) | ||
|
||
set( | ||
OpenCV-SWIG_LIBDIR ${DEF_INSTALL_SWIGLIB_DIR} CACHE PATH | ||
"Installation directory for SWIG library files" | ||
) | ||
|
||
configure_package_config_file(OpenCV-SWIGConfig.cmake.in | ||
"${PROJECT_BINARY_DIR}/OpenCV-SWIGConfig.cmake" | ||
INSTALL_DESTINATION ${OpenCV-SWIG_CMAKE_DIR} | ||
PATH_VARS OpenCV-SWIG_LIBDIR | ||
) | ||
write_basic_package_version_file( | ||
"${PROJECT_BINARY_DIR}/OpenCV-SWIGConfigVersion.cmake" | ||
COMPATIBILITY SameMajorVersion | ||
ARCH_INDEPENDENT | ||
) | ||
|
||
install( | ||
FILES | ||
"${PROJECT_BINARY_DIR}/OpenCV-SWIGConfig.cmake" | ||
"${PROJECT_BINARY_DIR}/OpenCV-SWIGConfigVersion.cmake" | ||
DESTINATION ${OpenCV-SWIG_CMAKE_DIR} | ||
) | ||
|
||
install( | ||
DIRECTORY lib/ | ||
DESTINATION ${OpenCV-SWIG_LIBDIR} | ||
FILES_MATCHING PATTERN "*.i" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@PACKAGE_INIT@ | ||
|
||
set_and_check(OpenCV-SWIG_INCLUDE_DIRS "@PACKAGE_OpenCV-SWIG_LIBDIR@") | ||
|
||
check_required_components(OpenCV-SWIG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
stdenv | ||
, fetchgit | ||
, lib | ||
, cmake | ||
}: | ||
|
||
let | ||
headerSrc = builtins.readFile ./CMakeLists.txt; | ||
|
||
versionNumbersRegex = ".*project[[:space:]]*\\(.*[[:space:]]VERSION[[:space:]]+([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+).*\\).*"; | ||
|
||
versionNumbers = builtins.head (builtins.match versionNumbersRegex headerSrc); | ||
|
||
devHash_ = builtins.match ".*DEV_HASH: ([[:xdigit:]]+).*" headerSrc; | ||
devHash = if devHash_ != null then builtins.head devHash_ else null; | ||
|
||
repo = builtins.fetchGit { | ||
url = https://github.com/renatoGarcia/opencv-swig.git; | ||
ref = "cmake_nix"; | ||
rev = devHash; | ||
}; | ||
|
||
version = | ||
versionNumbers + | ||
( | ||
if devHash != null | ||
then "+dev." + toString repo.revCount | ||
else "+local_repo" | ||
); | ||
|
||
in stdenv.mkDerivation { | ||
pname = "opencv-swig"; | ||
inherit version; | ||
|
||
src = ./.; | ||
|
||
nativeBuildInputs = [ cmake ]; | ||
|
||
meta = with lib; { | ||
homepage = "https://github.com/renatoGarcia/opencv-swig"; | ||
description = "A SWIG library for OpenCV types"; | ||
license = licenses.bsd3; | ||
maintainers = with maintainers; [ renatoGarcia ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
cmake_policy(SET CMP0074 NEW) | ||
cmake_policy(SET CMP0078 NEW) | ||
cmake_policy(SET CMP0086 NEW) | ||
|
||
project(MyLib) | ||
|
||
find_package(OpenCV-SWIG REQUIRED) | ||
find_package(SWIG REQUIRED COMPONENTS python) | ||
find_package(Boost REQUIRED) | ||
find_package(OpenCV REQUIRED core) | ||
find_package(Python REQUIRED COMPONENTS Interpreter Development) | ||
|
||
include(UseSWIG) | ||
|
||
set_property(SOURCE my_lib.i PROPERTY CPLUSPLUS ON) | ||
swig_add_library(my_lib LANGUAGE python SOURCES my_lib.i my_lib.hpp) | ||
set_property( | ||
TARGET my_lib | ||
PROPERTY SWIG_INCLUDE_DIRECTORIES | ||
${OpenCV-SWIG_INCLUDE_DIRS} | ||
${OpenCV_INCLUDE_DIRS} | ||
) | ||
|
||
target_include_directories(my_lib | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${Python_INCLUDE_DIRS} | ||
${OpenCV_INCLUDE_DIRS} | ||
${Boost_INCLUDE_DIRS} | ||
) | ||
|
||
target_link_libraries(my_lib | ||
${OpenCV_LIBRARIES} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef MY_LIB_HPP_INCLUDED | ||
#define MY_LIB_HPP_INCLUDED | ||
|
||
#include <opencv2/core.hpp> | ||
#include <iostream> | ||
|
||
inline auto moveTo(cv::Point const& p) -> void | ||
{ | ||
std::cout << "cv::Point moved" << std::endl; | ||
} | ||
|
||
inline auto getImage() -> cv::Mat3b | ||
{ | ||
return cv::Mat3b(3, 5); | ||
} | ||
|
||
#endif /* MY_LIB_HPP_INCLUDED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
%module my_lib | ||
|
||
%include <opencv.i> | ||
%cv_instantiate_all_defaults | ||
|
||
%{ | ||
#include "my_lib.hpp" | ||
%} | ||
|
||
%include "my_lib.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
let | ||
pkgs = import <nixpkgs> {}; | ||
opencv-swig = pkgs.callPackage ( | ||
fetchTarball https://github.com/renatoGarcia/opencv-swig/archive/v1.0.0.tar.gz | ||
) {}; | ||
|
||
in pkgs.mkShell { | ||
buildInputs = [ | ||
opencv-swig | ||
pkgs.boost | ||
pkgs.swig | ||
pkgs.cmake | ||
pkgs.pythonPackages.opencv | ||
]; | ||
} |