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

File tree

24 files changed

+211
-169
lines changed

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

0 commit comments

Comments
 (0)