Skip to content

Commit 0c2327c

Browse files
committed
Changes necessary to compile on arch linux (py38)
To solve issue 39: Removed old Find*.cmake files to use the ones provided by the system libraries, and made necessary changes to multiple CMakeLists.txt to use those. Switched to imported targets. Changed imports of numpy in cpp files to be compatible with default folder structure. To solve issue37: Modified setup.py to be compatible with pip 20.
1 parent 697c09a commit 0c2327c

File tree

17 files changed

+88
-138
lines changed

17 files changed

+88
-138
lines changed

.gitignore

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

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()

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()

pptk/processing/estimate_normals/CMakeLists.txt

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# # Uncomment the following lines to run as standalone cmake script
2-
# cmake_minimum_required(VERSION 3.0)
3-
# project(estimate_normals)
1+
cmake_minimum_required(VERSION 3.14)
2+
project(estimate_normals)
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-
# find_package(Eigen REQUIRED)
10-
# include(UsefulMacros)
11-
# include(FindOpenMP)
4+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
5+
6+
find_package(Python3 COMPONENTS Interpreter Development NumPy)
7+
find_package(Eigen3 REQUIRED)
8+
find_package(TBB COMPONENTS tbb tbbmalloc REQUIRED)
9+
find_package(OpenMP REQUIRED)
10+
include(UsefulMacros)
1211

1312
add_library(estimate_normals SHARED estimate_normals.cpp)
1413
set(_link_flags ${OpenMP_CXX_FLAGS})
@@ -24,16 +23,13 @@ set_target_properties(estimate_normals PROPERTIES
2423
LINK_FLAGS ${_link_flags})
2524
set_target_python_module_name(estimate_normals)
2625
target_compile_definitions(estimate_normals PRIVATE -DUSE_TBB)
27-
target_link_libraries(estimate_normals
28-
${TBB_tbb_LIBRARY}
29-
${TBB_tbbmalloc_LIBRARY})
26+
target_link_libraries(estimate_normals Python3::NumPy Eigen3::Eigen
27+
TBB::tbb TBB::tbbmalloc
28+
)
3029
target_include_directories(estimate_normals PRIVATE
3130
../../include # for python_util.h
3231
../../kdtree/src # for kdtree.h
33-
${Eigen_INCLUDE_DIR}
34-
${PYTHON_INCLUDE_DIR}
35-
${TBB_INCLUDE_DIR}
36-
${Numpy_INCLUDE_DIR})
32+
)
3733
copy_target(estimate_normals)
3834
copy_target_dependencies(estimate_normals)
3935
copy_file(__init__.py)

pptk/processing/estimate_normals/estimate_normals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <limits>
66
#include <vector>
77
#include "Python.h"
8-
#include "arrayobject.h"
8+
#include "numpy/arrayobject.h"
99
#include "kdtree.h"
1010
#include "progress_bar.h"
1111
#include "python_util.h"

pptk/vfuncs/CMakeLists.txt

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

5-
# set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake" ${CMAKE_MODULE_PATH})
6-
# find_package(PythonLibs 2.7 REQUIRED)
7-
# find_package(Numpy REQUIRED)
8-
# find_package(Eigen 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(Eigen3 REQUIRED)
8+
include(UsefulMacros)
109

1110
add_library(vfuncs SHARED vfuncs.cpp)
11+
target_link_libraries(vfuncs Eigen3::Eigen Python3::Python Python3::NumPy)
1212
set_target_python_module_name(vfuncs)
1313
if(WIN32)
1414
target_link_libraries(vfuncs ${PYTHON_LIBRARY})
@@ -21,9 +21,7 @@ elseif(UNIX)
2121
endif()
2222
target_include_directories(vfuncs PRIVATE
2323
../include # for python_util.h
24-
${PYTHON_INCLUDE_DIR}
25-
${Eigen_INCLUDE_DIR}
26-
${Numpy_INCLUDE_DIR})
24+
)
2725
copy_target(vfuncs)
2826
copy_target_dependencies(vfuncs)
2927
copy_file(__init__.py)

pptk/vfuncs/vfuncs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Python.h"
2-
#include "arrayobject.h"
2+
#include "numpy/arrayobject.h"
33
#define EIGEN_NO_DEBUG // comment this for runtime assertions
44
#include <algorithm>
55
#include <functional>

pptk/viewer/CMakeLists.txt

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

5-
# set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake" ${CMAKE_MODULE_PATH})
6-
# find_package(Eigen REQUIRED)
7-
# find_package(OpenGL REQUIRED)
8-
# find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Network OpenGL Core)
9-
# include(UsefulMacros)
4+
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
5+
6+
find_package(Eigen3 REQUIRED)
7+
find_package(OpenGL REQUIRED)
8+
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Network OpenGL Core)
9+
include(UsefulMacros)
1010

1111
add_executable(viewer
1212
main.cpp
@@ -28,8 +28,9 @@ add_executable(viewer
2828
point_attributes.h)
2929

3030
set_target_properties(viewer PROPERTIES AUTOMOC TRUE)
31-
target_link_libraries(viewer Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_gl_LIBRARY})
32-
target_include_directories(viewer PRIVATE ${Eigen_INCLUDE_DIR} )
31+
target_link_libraries(viewer OpenGL Qt5::Widgets Qt5::Network Qt5::OpenGL
32+
Eigen3::Eigen)
33+
target_include_directories(viewer PRIVATE )
3334
copy_target(viewer)
3435
copy_target_dependencies(viewer)
3536
copy_file(viewer.py)

setup.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import shutil
77
import platform
88

9-
from pip._internal import wheel
9+
import packaging.tags
1010

11-
wheel_tags = wheel.pep425tags.get_supported()[0]
12-
13-
system_type = platform.system()
11+
sys_tag = packaging.tags.sys_tags().__next__()
12+
system_type = sys_tag.platform
1413

1514
license_text = b''
1615
with open('LICENSE', 'rb') as fd:
@@ -23,7 +22,7 @@
2322
def make_mod(x):
2423
if system_type == 'Windows':
2524
return x + '.pyd'
26-
elif system_type == 'Linux':
25+
elif "linux" in system_type.lower():
2726
return x + '.so'
2827
elif system_type == 'Darwin':
2928
return x + '.so'
@@ -34,7 +33,7 @@ def make_mod(x):
3433
def make_lib(x, version_suffix=''):
3534
if system_type == 'Windows':
3635
return x + '.dll'
37-
elif system_type == 'Linux':
36+
elif "linux" in system_type.lower():
3837
return 'lib' + x + '.so' + version_suffix
3938
elif system_type == 'Darwin':
4039
return 'lib' + x + '.dylib'
@@ -85,5 +84,5 @@ def list_libs():
8584
'pptk.vfuncs': [make_mod('vfuncs')],
8685
'pptk.viewer': [make_exe('viewer'), 'qt.conf']},
8786
options={'bdist_wheel': {
88-
'python_tag': wheel_tags[0],
89-
'plat_name': wheel_tags[2]}})
87+
'python_tag': sys_tag.interpreter,
88+
'plat_name': sys_tag.platform}})

0 commit comments

Comments
 (0)