Skip to content

Commit eda5e56

Browse files
Fix build: add patches from heremaps/pptk#45,
add nix and envrc Signed-off-by: SamueleFacenda <[email protected]>
1 parent 76c6bf0 commit eda5e56

24 files changed

+211
-169
lines changed

.envrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
2+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
3+
fi
4+
use flake

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
__pycache__/
3+
result
4+
/.direnv

CMakeCache.linux.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

CMakeCache.mac.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

CMakeCache.win.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,12 @@
1-
cmake_minimum_required(VERSION 3.1)
1+
cmake_minimum_required(VERSION 3.14)
22
project(pptk)
33

44
set(CMAKE_BUILD_TYPE Release)
5-
set(CMAKE_MODULE_PATH
6-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_CURRENT_SOURCE_DIR})
7-
8-
find_package(PythonLibs 2.7 REQUIRED)
9-
find_package(OpenGL REQUIRED)
10-
find_package(Numpy REQUIRED)
11-
find_package(TBB REQUIRED)
12-
find_package(Eigen REQUIRED)
13-
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Network OpenGL Core)
14-
find_package(OpenMP)
15-
16-
# get root Qt5 folder (i.e. contains bin, lib, plugins, etc.)
17-
get_target_property(Qt5_DIR Qt5::qmake LOCATION)
18-
get_filename_component(Qt5_DIR ${Qt5_DIR} DIRECTORY)
19-
get_filename_component(Qt5_DIR ${Qt5_DIR} DIRECTORY)
20-
set(Qt5_PLUGINS_DIR ${Qt5_DIR}/plugins)
5+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
216

227
# localize all dependencies (.dll, .so, or .dylib) in the following folder
238
set(PPTK_LIBS_DIR ${PROJECT_BINARY_DIR}/pptk/libs)
249

25-
# use the following variable to store a list of .dll paths required by targets
26-
# built in pptk; this is useful only for building on Windows platform
27-
get_filename_component(TBB_RUNTIME_DIR ${TBB_tbb_RUNTIME} DIRECTORY)
28-
set(PPTK_DLL_DIRS
29-
${TBB_RUNTIME_DIR}
30-
${Qt5_DIR}/bin
31-
CACHE INTERNAL "Additional folder paths for finding .dll's")
32-
3310
# use patchelf to modify binary RPATH when building pptk on Linux
3411
if(UNIX AND NOT APPLE)
3512
find_program(PPTK_PATCHELF patchelf)

cmake/FindEigen.cmake

Lines changed: 0 additions & 5 deletions
This file was deleted.

cmake/FindNumpy.cmake

Lines changed: 0 additions & 5 deletions
This file was deleted.

cmake/FindTBB.cmake

Lines changed: 0 additions & 16 deletions
This file was deleted.

cmake/UsefulMacros.cmake

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ function(copy_target_dependencies x)
4848
${PROJECT_SOURCE_DIR}/cmake/CopyAppleDependencies.cmake
4949
${CMAKE_CURRENT_BINARY_DIR}/${_target_file_name} ${PPTK_LIBS_DIR})
5050
elseif(UNIX)
51+
find_file(helper_script CopyLinuxDependencies.cmake
52+
PATHS ${CMAKE_MODULE_PATH} REQUIRED)
5153
add_custom_command(TARGET ${x} POST_BUILD
52-
COMMAND ${CMAKE_COMMAND} -P
53-
${PROJECT_SOURCE_DIR}/cmake/CopyLinuxDependencies.cmake
54+
COMMAND ${CMAKE_COMMAND} -P ${helper_script}
5455
${_target_file}
5556
${CMAKE_CURRENT_BINARY_DIR}/${_target_file_name}
5657
${PPTK_LIBS_DIR} ${PPTK_PATCHELF})
58+
unset(helper_script CACHE) # find_file creates a cache variable, this is temporary
5759
endif()
5860
endfunction()
5961

@@ -65,22 +67,24 @@ endmacro()
6567
function(copy_file x)
6668
# x should be a file path, and should not be a variable
6769
# i.e. copy_file(${var}), not copy_file(var)
68-
get_filename_component(name ${x} NAME)
69-
file(RELATIVE_PATH temp ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
70-
if (NOT (temp STREQUAL ""))
71-
string(REGEX REPLACE "(/|\\\\)" "." temp "${temp}")
72-
string(CONCAT name "${temp}" "." "${name}")
70+
get_filename_component(filename ${x} NAME)
71+
file(RELATIVE_PATH rel_path ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
72+
if (NOT (rel_path STREQUAL ""))
73+
string(REGEX REPLACE "(/|\\\\)" "." rel_path "${rel_path}")
74+
string(CONCAT target_name "${rel_path}" "." "${filename}")
75+
else()
76+
string(CONCAT target_name "${PROJECT_NAME}" "." "${filename}")
7377
endif()
7478
if (ARGC EQUAL 2)
75-
set(${ARGV1} ${name} PARENT_SCOPE)
79+
set(${ARGV1} ${target_name} PARENT_SCOPE)
7680
endif()
7781
if (NOT IS_ABSOLUTE ${x})
7882
set(src ${CMAKE_CURRENT_SOURCE_DIR}/${x})
7983
else()
8084
set(src ${x})
8185
endif()
8286
set(dst ${CMAKE_CURRENT_BINARY_DIR})
83-
add_custom_target(${name} ALL
87+
add_custom_target(${target_name} ALL
8488
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
8589
COMMENT "Copying ${src} to ${dst}")
8690
endfunction()

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# nix comment
2+
{
3+
description = "3dont, ontology pointcloud visualizer";
4+
5+
inputs.nixpkgs.url = "nixpkgs/nixos-24.11";
6+
7+
inputs.flake-utils.url = "github:numtide/flake-utils";
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
let
11+
version = "0.0.1";
12+
overlay = final: prev: { };
13+
in
14+
15+
flake-utils.lib.eachDefaultSystem (system:
16+
let pkgs = (nixpkgs.legacyPackages.${system}.extend overlay); in
17+
{
18+
19+
packages = rec {
20+
default = visualizer;
21+
visualizer = pkgs.python3.pkgs.buildPythonPackage {
22+
pname = "3dont";
23+
src = ./.;
24+
inherit version;
25+
26+
nativeBuildInputs = with pkgs; [
27+
libsForQt5.qt5.wrapQtAppsHook
28+
];
29+
30+
buildInputs = with pkgs; [
31+
eigen
32+
python3
33+
tbb
34+
libsForQt5.qt5.qtbase
35+
libGL
36+
];
37+
38+
dependencies = with pkgs.python3Packages; [
39+
numpy
40+
];
41+
};
42+
};
43+
44+
apps = {
45+
default = {
46+
type = "app";
47+
program = "${self.defaultPackage.${system}}/bin/a.out";
48+
};
49+
};
50+
51+
devShells = {
52+
default = pkgs.mkShell {
53+
inputsFrom = [ self.packages.${system}.visualizer ];
54+
};
55+
};
56+
});
57+
}

licenses/LICENSE.append.txt

Whitespace-only changes.

pptk/include/python_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <cstdint>
55
#include <vector>
66
#include "Python.h"
7-
#include "arrayobject.h"
7+
#include "numpy/arrayobject.h"
88

99
struct Array2D {
1010
const unsigned char* data;

pptk/kdtree/CMakeLists.txt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# # Uncomment the following lines to run as standalone cmake script
2-
# cmake_minimum_required(VERSION 3.0)
3-
# project(kdtree)
1+
cmake_minimum_required(VERSION 3.14)
2+
project(kdtree)
43

5-
# set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake" ${CMAKE_CURRENT_SOURCE_DIR})
6-
# find_package(PythonLibs 2.7 REQUIRED)
7-
# find_package(Numpy REQUIRED)
8-
# find_package(TBB REQUIRED)
9-
# include(UsefulMacros)
4+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
5+
6+
find_package(Python3 COMPONENTS Interpreter Development NumPy)
7+
find_package(TBB COMPONENTS tbb tbbmalloc REQUIRED)
8+
include(UsefulMacros)
109

1110
add_library(kdtree SHARED kdtree_wrapper.cpp)
1211
set_target_python_module_name(kdtree)
@@ -24,12 +23,8 @@ target_compile_definitions(kdtree PRIVATE -DUSE_TBB)
2423
target_include_directories(kdtree PRIVATE
2524
../include # for python_util.h
2625
src # for k-d tree source code
27-
${TBB_INCLUDE_DIR}
28-
${PYTHON_INCLUDE_DIR}
29-
${Numpy_INCLUDE_DIR} )
30-
target_link_libraries(kdtree
31-
${TBB_tbb_LIBRARY}
32-
${TBB_tbbmalloc_LIBRARY})
26+
)
27+
target_link_libraries(kdtree Python3::NumPy TBB::tbb TBB::tbbmalloc)
3328
copy_target(kdtree)
3429
copy_target_dependencies(kdtree)
3530
copy_file(__init__.py)

pptk/libs/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ function(copy_system_file x)
44
if(ARGC EQUAL 2)
55
set(y ${ARGV1})
66
endif()
7-
find_file(temp ${x} ${y})
8-
copy_file(${temp} _target)
7+
find_file(file_loc ${x} PATHS ${y} REQUIRED)
8+
copy_file(${file_loc} _target)
99
if(UNIX AND NOT APPLE)
1010
add_custom_command(TARGET ${_target} POST_BUILD COMMAND
1111
${PPTK_PATCHELF} --set-rpath \\\$\$ORIGIN
1212
${CMAKE_CURRENT_BINARY_DIR}/${x})
1313
endif()
14-
unset(temp CACHE)
14+
unset(file_loc CACHE) # find_file creates a cache variable, this is temporary
1515
endfunction()
1616

1717
function(copy_import_target x)
@@ -35,13 +35,14 @@ elseif (APPLE)
3535
elseif (UNIX)
3636
# create local copies of system libraries that are required by pptk targets
3737
# but not provided by a bare bone manylinux1 platform, as specified in PEP 513
38-
if (CMAKE_LIBRARY_ARCHITECTURE)
39-
set(_paths
40-
/lib/${CMAKE_LIBRARY_ARCHITECTURE}
41-
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})
42-
endif()
43-
copy_system_file(libgomp.so.1 "${_paths}")
44-
copy_system_file(libz.so.1 "${_paths}")
38+
find_package(OpenMP REQUIRED)
39+
get_filename_component(gomp_file ${OpenMP_gomp_LIBRARY} NAME)
40+
get_filename_component(gomp_path ${OpenMP_gomp_LIBRARY} DIRECTORY)
41+
copy_system_file(${gomp_file} ${gomp_path})
42+
find_package(ZLIB REQUIRED)
43+
get_filename_component(zlib_file ${ZLIB_LIBRARY} NAME)
44+
get_filename_component(zlib_path ${ZLIB_LIBRARY} DIRECTORY)
45+
copy_system_file(${zlib_file} ${zlib_path})
4546
endif()
4647

4748
add_subdirectory(qt_plugins)

pptk/libs/qt_plugins/platforms/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ if(WIN32)
33
elseif (APPLE)
44
copy_file_with_dependencies(${Qt5_PLUGINS_DIR}/platforms/libqcocoa.dylib)
55
elseif (UNIX)
6-
copy_file_with_dependencies(${Qt5_PLUGINS_DIR}/platforms/libqxcb.so)
6+
find_package(Qt5 COMPONENTS Gui REQUIRED)
7+
get_target_property(xcb_loc Qt5::QXcbIntegrationPlugin LOCATION)
8+
copy_file_with_dependencies(${xcb_loc})
79
endif()
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
if(UNIX AND NOT APPLE)
2-
copy_file_with_dependencies(
3-
${Qt5_PLUGINS_DIR}/xcbglintegrations/libqxcb-egl-integration.so)
4-
copy_file_with_dependencies(
5-
${Qt5_PLUGINS_DIR}/xcbglintegrations/libqxcb-glx-integration.so)
2+
find_package(Qt5 COMPONENTS Gui REQUIRED)
3+
get_target_property(xcb_egl_loc Qt5::QXcbEglIntegrationPlugin LOCATION)
4+
copy_file_with_dependencies(${xcb_egl_loc})
5+
get_target_property(xcb_glx_loc Qt5::QXcbGlxIntegrationPlugin LOCATION)
6+
copy_file_with_dependencies(${xcb_glx_loc})
67
endif()

0 commit comments

Comments
 (0)