Skip to content

Commit

Permalink
Improved build system on Windows side; now automatically determines a…
Browse files Browse the repository at this point in the history
…nd copies (to a local libs folder) dependencies required by built targets.
  • Loading branch information
victoriousluser authored and Victor Lu committed Jul 13, 2018
1 parent a398d99 commit c23c39c
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 34 deletions.
10 changes: 10 additions & 0 deletions CMakeCache.win.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Numpy_INCLUDE_DIR:PATH=C:\Users\victlu.HERE\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.1.2730.win-x86_64\Lib\site-packages\numpy\core\include\numpy
PYTHON_INCLUDE_DIR:PATH=C:\Users\victlu.HERE\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.1.2730.win-x86_64\include
PYTHON_LIBRARY:FILEPATH=C:\Users\victlu.HERE\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.1.2730.win-x86_64\libs\python27.lib
Eigen_INCLUDE_DIR:PATH=F:/Sources/eigen-3.2.9
TBB_INCLUDE_DIR:PATH=F:/Sources/tbb43_20141204oss/include
TBB_tbb_LIBRARY:FILEPATH=F:/Sources/tbb43_20141204oss/lib/intel64/vc12/tbb.lib
TBB_tbb_RUNTIME:FILEPATH=F:/Sources/tbb43_20141204oss/bin/intel64/vc12/tbb.dll
TBB_tbbmalloc_LIBRARY:FILEPATH=F:/Sources/tbb43_20141204oss/lib/intel64/vc12/tbbmalloc.lib
TBB_tbbmalloc_RUNTIME:FILEPATH=F:/Sources/tbb43_20141204oss/bin/intel64/vc12/tbbmalloc.dll
Qt5_DIR:PATH=C:/Qt/5.4/msvc2013_64_opengl/lib/cmake/Qt5
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(pypcl)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_CURRENT_SOURCE_DIR})

find_package(PythonLibs 2.7 REQUIRED)
find_package(OpenGL REQUIRED)
Expand All @@ -16,8 +17,17 @@ get_target_property(Qt5_DIR Qt5::qmake LOCATION)
get_filename_component(Qt5_DIR ${Qt5_DIR} DIRECTORY)
get_filename_component(Qt5_DIR ${Qt5_DIR} DIRECTORY)

# localize all dependencies (.dll, .so, or .dylib) in the following folder
set(PYPCL_LIBS_DIR ${PROJECT_BINARY_DIR}/pypcl/libs)

# use the following variable to store a list .dll paths required by targets
# built in pypcl; this is useful only for building on Windows platform
get_filename_component(TBB_RUNTIME_DIR ${TBB_tbb_RUNTIME} DIRECTORY)
set(PYPCL_DLL_DIRS
${TBB_RUNTIME_DIR}
${Qt5_DIR}/bin
CACHE INTERNAL "Additional folder paths for finding .dll's")

include(UsefulMacros)

# following lines specifies the CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS variable
Expand Down
19 changes: 19 additions & 0 deletions cmake/CopyWindowsDependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# usage: cmake -P CopyWindowsDependencies.cmake
# <target file path> <copy folder path> <.dll folder paths>
# assumes full existing paths
# .dll folder paths are semicolon-separated

include(GetPrerequisites)

set(_target_file ${CMAKE_ARGV3})
set(_copy_folder ${CMAKE_ARGV4})
set(_dll_paths ${CMAKE_ARGV5})
get_prerequisites(${_target_file} _prereqs 1 1 "" "${_dll_paths}")
foreach(p ${_prereqs})
if(NOT (p STREQUAL "python27.dll"))
gp_resolve_item("" ${p} "" "${_dll_paths}" src)
set(dst ${_copy_folder})
execute_process(COMMAND
${CMAKE_COMMAND} -E copy_if_different ${src} ${dst})
endif()
endforeach()
1 change: 0 additions & 1 deletion cmake/UsefulMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ function(copy_file x)
string(CONCAT name "${temp}" "." "${name}")
endif()
if (ARGC EQUAL 2)
message("${ARGV0}")
set(${ARGV1} ${name} PARENT_SCOPE)
endif()
if (NOT IS_ABSOLUTE ${x})
Expand Down
8 changes: 6 additions & 2 deletions pypcl/kdtree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ copy_target(kdtree)
copy_file(__init__.py)

if (WIN32)
# TODO
add_custom_command(TARGET kdtree POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyWindowsDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:kdtree> ${PYPCL_LIBS_DIR}
"${PYPCL_DLL_DIRS}")
elseif (APPLE)
add_custom_command(TARGET kdtree POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyAppleDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:vfuncs> ${PYPCL_LIBS_DIR})
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:kdtree> ${PYPCL_LIBS_DIR})
elseif (UNIX)
# TODO
endif()
4 changes: 0 additions & 4 deletions pypcl/libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ elseif (UNIX)
copy_file(/usr/lib64/libgomp.so.1)
endif()

# copy TBB runtime libraries
copy_file(${TBB_tbb_RUNTIME})
copy_file(${TBB_tbbmalloc_RUNTIME})

# copy Qt runtime libraries
macro(copy_import_target x)
get_target_property(temp ${x} LOCATION)
Expand Down
14 changes: 12 additions & 2 deletions pypcl/libs/qt_plugins/platforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
if (WIN32)
copy_file(${Qt5_DIR}/plugins/platforms/qwindows.dll)
copy_file(${Qt5_DIR}/plugins/platforms/qwindows.dll _target_name)
add_custom_command(TARGET ${_target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyWindowsDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/qwindows.dll
${PYPCL_LIBS_DIR} "${PYPCL_DLL_DIRS}")
elseif (APPLE)
include(${CMAKE_CURRENT_SOURCE_DIR}/mac.cmake)
copy_file(${Qt5_DIR}/plugins/platforms/libqcocoa.dylib _target_name)
add_custom_command(TARGET ${_target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyAppleDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/libqcocoa.dylib
${PYPCL_LIBS_DIR})
elseif (UNIX)
copy_file(${Qt5_DIR}/plugins/platforms/libqxcb.so)
endif()
Expand Down
7 changes: 0 additions & 7 deletions pypcl/libs/qt_plugins/platforms/mac.cmake

This file was deleted.

6 changes: 5 additions & 1 deletion pypcl/processing/estimate_normals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ copy_target(estimate_normals)
copy_file(__init__.py)

if (WIN32)
# TODO
add_custom_command(TARGET estimate_normals POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyWindowsDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:estimate_normals>
${PYPCL_LIBS_DIR} "${PYPCL_DLL_DIRS}")
elseif (APPLE)
add_custom_command(TARGET estimate_normals POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
Expand Down
6 changes: 5 additions & 1 deletion pypcl/vfuncs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ copy_target(vfuncs)
copy_file(__init__.py)

if (WIN32)
# TODO
add_custom_command(TARGET vfuncs POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyWindowsDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:vfuncs> ${PYPCL_LIBS_DIR}
"${PYPCL_DLL_DIRS}")
elseif (APPLE)
add_custom_command(TARGET vfuncs POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
Expand Down
18 changes: 5 additions & 13 deletions pypcl/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@ copy_file(__init__.py)
copy_file(qt.conf)

# deploy runtime dll's to libs folder
get_target_property(_qmake_exe Qt5::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin ${_qmake_exe} DIRECTORY)
if (WIN32)
add_custom_command(TARGET viewer POST_BUILD
COMMAND ${_qt_bin}/windeployqt.exe $<TARGET_FILE:viewer>
--libdir ${CMAKE_CURRENT_BINARY_DIR}/../libs
--no-compiler-runtime
--no-translations
--no-quick-import
--no-webkit2
--no-angle
--no-system-d3d-compiler)
add_custom_command(TARGET viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
${PROJECT_SOURCE_DIR}/cmake/CopyWindowsDependencies.cmake
${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_FILE_NAME:viewer> ${PYPCL_LIBS_DIR}
"${PYPCL_DLL_DIRS}")
elseif (APPLE)
add_custom_command(TARGET viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -P
Expand All @@ -56,5 +50,3 @@ elseif (APPLE)
elseif (UNIX)
# TODO
endif()
unset(_qmake_exe)
unset(_qt_bin)
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ def make_exe(x):
author = 'Victor Lu',
packages = find_packages(),
package_data={
'pypcl': [os.path.join('libs', make_lib('*'))],
'pypcl': [
os.path.join('libs', make_lib('*')),
os.path.join('libs', 'qt_plugins', 'platforms', make_lib('*'))
],
'pypcl.kdtree': [make_mod('kdtree')],
'pypcl.processing.estimate_normals': [make_mod('estimate_normals')],
'pypcl.vfuncs': [make_mod('vfuncs')],
'pypcl.viewer': [make_exe('viewer')]},
'pypcl.viewer': [make_exe('viewer'), 'qt.conf']},
options = {'bdist_wheel':{
'python_tag': wheel_tags[0],
'plat_name': wheel_tags[2]}})

0 comments on commit c23c39c

Please sign in to comment.