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

0 commit comments

Comments
 (0)