Commit 0d5459e2 authored by Nick Laurenson's avatar Nick Laurenson
Browse files

Remove application specific project

parent 790255be
cmake_minimum_required(VERSION 2.8.8)
project(LidarViewSuperBuild)
set (SuperBuild_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
set (SuperBuild_PROJECTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Projects")
set (SuperBuild_BINARY_DIR ${LidarViewSuperBuild_BINARY_DIR}) # required to do FindPackage(ParaView) inside LidarView's CMakeLists
set(qt_version 5)
macro (superbuild_setup_variables)
include(SuperbuildVersionMacros)
# if (paraview_SOURCE_SELECTION STREQUAL "git")
# # Assuming master; just use the latest version, but let the user set their
# # own version in case it is actually a branch from some other version.
# set(PARAVIEW_VERSION_DEFAULT "5.5.0"
# CACHE STRING "The default version of ParaView to use if it cannot be detected")
# mark_as_advanced(PARAVIEW_VERSION_DEFAULT)
# set(paraview_default_version "${PARAVIEW_VERSION_DEFAULT}")
# elseif (paraview_SOURCE_SELECTION STREQUAL "source")
# # If it is a git repo, we'll get it that way, otherwise we will look at the
# # `version.txt` in the checkout.
# set(paraview_default_version "")
# else ()
# # The selection is the version number; use it.
# set(paraview_default_version "${paraview_SOURCE_SELECTION}")
# endif()
# superbuild_set_version_variables(paraview "${paraview_default_version}" "paraview-version.cmake" "version.txt")
# set(paraview_version "${paraview_version_major}.${paraview_version_minor}")
set(paraview_version "5.4")
endmacro ()
#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# All the function and variable bellow are here because we rely on lidarview's
# superbuild.
# To see which function/variable cana/needs to be set, please take a look at
# the CMakeLists.txt inside "lidarview-common-superbuild"
#-----------------------------------------------------------------------------
# Collect information about the build platform.
include(CheckTypeSize)
check_type_size(void* VOID_PTR_SIZE BUILTIN_TYPES_ONLY)
if (VOID_PTR_SIZE EQUAL 8)
set(VV_BUILD_ARCHITECTURE "64")
else ()
set(VV_BUILD_ARCHITECTURE "32")
endif()
# Set suffix to be used for generating archives. This ensures that the package
# files have decent names that we can directly upload to the website.
set (package_suffix "${CMAKE_SYSTEM_NAME}-${VV_BUILD_ARCHITECTURE}bit")
#-----------------------------------------------------------------------------
# Setup CMAKE_MODULE_PATH so that platform specific configurations are processed
# before the generic ones.
set (CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/Projects"
"${SuperBuild_PROJECTS_DIR}"
"${SuperBuild_CMAKE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/../CMake"
${CMAKE_MODULE_PATH})
function (add_project_to_superbuild var)
# list cannot append to parent's scope so we do it in two steps
list(APPEND "${var}" lidarview)
set("${var}" "${${var}}" PARENT_SCOPE)
function (superbuild_find_projects var)
# Some of these allow using system libraries.
set(projects
boost
bzip2
cxx11
eigen
liblas
freetype
opencv
paraview
pcap
png
python
pythonqt
qt5
zlib
ceres
glog
pcl
qhull
flann
nanoflann
yaml
darknet
)
if (UNIX)
list(APPEND projects
libxml2
)
if (NOT APPLE)
list(APPEND projects
fontconfig
gperf
)
endif()
endif()
add_project_to_superbuild(projects)
set("${var}"
${projects}
PARENT_SCOPE)
endfunction ()
if (WIN32)
if ( (NOT "${CMAKE_GENERATOR}" MATCHES "^NMake.*$") OR
(NOT "${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*$"))
# not use VS environment. We need to be pointed to nmake and devenv paths
# since they are needed when building tools (qt, python, etc.)
find_program(DEVENV_PATH devenv)
find_program(NMAKE_PATH nmake)
mark_as_advanced(DEVENV_PATH NMAKE_PATH)
endif()
endif()
if(UNIX AND NOT DEFINED USE_SYSTEM_python)
# it is still possible to pass -DUSE_SYSTEM_python=False to cmake
message(STATUS "Defaulting USE_SYSTEM_python to True (was undefined and we are on UNIX)")
set(USE_SYSTEM_python True CACHE BOOL INTERNAL)
endif()
function (superbuild_add_packaging)
if (WIN32)
set(generators
ZIP
NSIS)
elseif (APPLE)
set(generators
DragNDrop)
else ()
set(generators
TGZ
TXZ)
endif ()
list(GET generators 0 default_generator)
if (USE_SYSTEM_qt5)
list(APPEND superbuild_export_variables
Qt5_DIR)
endif ()
# pass some variables that are required for packaging step:
list(APPEND superbuild_export_variables
PARAVIEW_VERSION
package_suffix
)
set(default_package lidarview)
foreach (generator IN LISTS generators)
superbuild_add_extra_package_test(lidarview "${generator}"
LABELS "LidarView" # does not have to be ${SOFTWARE_NAME} I think
TIMEOUT 6400)
endforeach ()
if (default_package)
superbuild_enable_install_target("${default_package}/${default_generator}")
endif ()
endfunction ()
function (superbuild_add_tests)
# TODO: add existing tests
# add_subdirectory("${CMAKE_SOURCE_DIR}/tests" "${CMAKE_BINARY_DIR}/tests")
endfunction ()
# skiped module as defined in paraview superbuild.
# One difference: pythonQt needs Multimedia so we don't skip it.
set(qt5_skip_modules
qtspeech
qtconnectivity
qtgamepad
qtlocation
qtsensors
qtserialport
qtwayland
qtwebchannel
qtwebengine
qtwebsockets)
list(APPEND qt5_process_environment
BUILD_IN_SOURCE 1)
set(boost_libraries
chrono
date_time
filesystem
iostreams
program_options
system
regex
thread)
set(boost_extra_options
"-sNO_BZIP2=1")
list(APPEND superbuild_version_files
"${CMAKE_CURRENT_LIST_DIR}/versions.cmake")
list(APPEND superbuild_project_roots
"${SuperBuild_PROJECTS_DIR}")
set(_superbuild_default_cxx11 ON)
option(ENABLE_all "Enable all optional dependancy like pcl, ceres, opencv, darknet, ..." OFF)
if (ENABLE_all)
set(ENABLE_opencv ON CACHE BOOL "enable OpenCV")
set(ENABLE_ceres ON CACHE BOOL "enable Ceres")
set(ENABLE_pcl ON CACHE BOOL "enable PCL")
set(ENABLE_nanoflann ON CACHE BOOL "enable nanoflann")
set(ENABLE_darknet ON CACHE BOOL "enable darknet")
endif(ENABLE_all)
add_subdirectory(lidarview-common-superbuild/)
add_subdirectory(common-superbuild)
on run argv
set image_name to item 1 of argv
tell application "Finder"
tell disk image_name
-- wait for the image to finish mounting
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5
-- open the image the first time and save a DS_Store with just
-- background and icon setup
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.tif"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 128
delay 5
close
-- next setup the position of the app and Applications symlink
-- plus hide all the window decoration
open
update without registering applications
tell container window
set sidebar width to 0
set statusbar visible to false
set toolbar visible to false
set the bounds to { 400, 100, 900, 465 }
set position of item "@lidarview_appname@" to { 133, 200 }
set position of item "Applications" to { 378, 200 }
end tell
update without registering applications
delay 5
close
-- one last open and close so you can see everything looks correct
open
delay 5
close
end tell
delay 1
end tell
end run
# Some advices when debugging:
# - get help by looking at:
# (mainly) https://gitlab.kitware.com/paraview/paraview-superbuild/blob/master/projects/apple/paraview.bundle.cmake
# (also) https://gitlab.kitware.com/cmb/cmb-superbuild/blob/master/projects/apple/cmb.bundle.apple.cmake
# - always clean the package-related directories of the build tree before retrying:
# rm -rf _CPack_Packages && rm -rf cpack && cmake .
# then try with: ctest -R cpack -V > package.log (very useful to grep the log)
# - to test if the application has correct paths and patched executable/libraries:
# inside build directory:
# `open _CPack_Packages/Darwin/DragNDrop/LidarView-3.6.0-196-g3490e1d-20190109-Darwin-64bit/lidarview.app`
# (much, much faster than having to mount the .dmg using the finder)
# - testing the .dmg on another computer (that does not have Qt) is important because that is our target
# - testing the .dmg on another computer + executing LidarView from terminal
# (with `/Volume/something.dmg/lidarview.app/Contents/MacOS/LidarView`) will sometime give you much
# very clear indications about absolute path that have not been fixed / missing files
# - to have a hint at "should this file really by inside the .dmg ?", look inside Paraview's .dmg
# or (better) recent working LidarView's .dmg
# - do not hesistate to hack inside ../common-superbuild/cmake/scripts/fixup_bundle.apple.py
# to print/modify/add paths, then get rid of your hack using only this file
# (we do not want to modify the common-superbuild)
include(lidarview.bundle.common)
include(${LidarViewSuperBuild_SOURCE_DIR}/../SoftwareInformation/branding.cmake)
# the variable lidarview_appname:
# - must be a valid dirname: will be a directory at the top of the .dmg
# - is visible in the macOS GUI when opening the .dmg
# - MUST end with .app (else its tree is not considered as an app by macOS)
set(lidarview_appname "${SOFTWARE_NAME}.app")
# LidarView is based on ParaView and can load ParaView plugins
set(paraview_plugin_path "bin/${lidarview_appname}/Contents/Plugins")
# this must be done before calling superbuild_apple_create_app,
# because superbuild_apple_create_app uses paraview_plugin_paths
# this was copied from ParaView's superbuild
# TODO: could/should be inside lidarview.bundle.common ?
set(paraview_plugins "PointCloudPlugin" "EyeDomeLightingView")
set(paraview_plugin_paths)
foreach (paraview_plugin IN LISTS paraview_plugins)
if (EXISTS "${superbuild_install_location}/Applications/paraview.app/Contents/Plugins/lib${paraview_plugin}.dylib")
list(APPEND paraview_plugin_paths
"${superbuild_install_location}/Applications/paraview.app/Contents/Plugins/lib${paraview_plugin}.dylib")
continue ()
endif ()
foreach (path IN ITEMS "" "paraview-${paraview_version}")
if (EXISTS "${superbuild_install_location}/lib/${path}/lib${paraview_plugin}.dylib")
list(APPEND paraview_plugin_paths
"${superbuild_install_location}/lib/${path}/lib${paraview_plugin}.dylib")
break ()
endif ()
endforeach ()
endforeach ()
superbuild_apple_create_app(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
"${superbuild_install_location}/bin/${lidarview_appname}/Contents/MacOS/${SOFTWARE_NAME}"
CLEAN
PLUGINS ${paraview_plugin_paths}
SEARCH_DIRECTORIES "${superbuild_install_location}/lib" "${superbuild_install_location}/bin/${lidarview_appname}/Contents/Libraries"
INCLUDE_REGEXES ${include_regexes})
function (paraview_add_plugin output)
set(contents "<?xml version=\"1.0\"?>\n<Plugins>\n</Plugins>\n")
foreach (name IN LISTS ARGN)
set(auto_load 0)
if (DEFINED paraview_plugin_${name}_auto_load)
set(auto_load 1)
endif ()
set(plugin_directive " <Plugin name=\"${name}\" auto_load=\"${auto_load}\" />\n")
string(REPLACE "</Plugins>" "${plugin_directive}</Plugins>" contents "${contents}")
endforeach ()
file(WRITE "${output}" "${contents}")
endfunction ()
set(plugins_file "${CMAKE_CURRENT_BINARY_DIR}/lidarview.plugins")
paraview_add_plugin("${plugins_file}" ${paraview_plugins})
install(
FILES "${plugins_file}"
DESTINATION "${lidarview_appname}/Contents/Plugins"
COMPONENT superbuild
RENAME ".plugins")
install(
FILES "${superbuild_install_location}/Applications/paraview.app/Contents/Resources/pvIcon.icns"
DESTINATION "${lidarview_appname}/Contents/Resources"
COMPONENT superbuild)
install(
FILES "${superbuild_install_location}/bin/${lidarview_appname}/Contents/Info.plist"
DESTINATION "${lidarview_appname}/Contents"
COMPONENT superbuild)
# Remove "LidarView" from the list since we just installed it above.
list(REMOVE_ITEM lidarview_executables
${SOFTWARE_NAME})
foreach (executable IN LISTS lidarview_executables)
superbuild_apple_install_utility(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
"${superbuild_install_location}/bin/${lidarview_appname}/Contents/bin/${executable}"
SEARCH_DIRECTORIES "${superbuild_install_location}/lib"
INCLUDE_REGEXES ${include_regexes})
endforeach ()
if (qt5_enabled)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = Plugins\n")
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
DESTINATION "${lidarview_appname}/Contents/Resources"
COMPONENT superbuild)
endif ()
if (python_enabled)
superbuild_apple_install_python(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
MODULES paraview
lidarview
vtk
vtkmodules
${python_modules}
MODULE_DIRECTORIES
"${superbuild_install_location}/bin/${lidarview_appname}/Contents/Python"
"${superbuild_install_location}/lib/python2.7/site-packages"
SEARCH_DIRECTORIES
"${superbuild_install_location}/bin/${lidarview_appname}/Contents/Libraries"
"${superbuild_install_location}/lib")
if (matplotlib_enabled)
install(
DIRECTORY "${superbuild_install_location}/lib/python2.7/site-packages/matplotlib/mpl-data/"
DESTINATION "${lidarview_appname}/Contents/Python/matplotlib/mpl-data"
COMPONENT superbuild)
endif ()
endif ()
# For some reason these .so files are not processed by the command
# superbuild_apple_install_python above, so we have to specify them manually
# it could be that I failed to find the correct name(s) to add in parameter
# "MODULE" but I do not think so because there are 86 such files, and because
# they seem to be part of vtk which is already specified like that in ParaView
file(GLOB missing_python_so "${superbuild_install_location}/bin/${lidarview_appname}/Contents/Libraries/vtk*Python.so")
foreach (python_so ${missing_python_so})
superbuild_apple_install_module(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
"${python_so}"
"Contents/Libraries") # destination path inside bundle
endforeach()
# My understanding is that these module are not processed automatically
# by superbuild_apple_create_app because there is no path leading to
# them in binary LidarView or in any of its .dylib dependencies
set(my_modules)
list(APPEND my_modules "LidarPluginPython.so")
list(APPEND my_modules "libLidarPluginPythonD.dylib")
foreach (module ${my_modules})
superbuild_apple_install_module(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
"${superbuild_install_location}/bin/${lidarview_appname}/Contents/Libraries/${module}"
"Contents/Libraries") # destination path inside bundle
endforeach()
# Configure CMakeDMGSetup.scpt to replace the app name in the script.
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/files/CMakeDMGSetup.scpt.in"
"${CMAKE_CURRENT_BINARY_DIR}/CMakeDMGSetup.scpt"
@ONLY)
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_LIST_DIR}/files/CMakeDMGBackground.tif")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/CMakeDMGSetup.scpt")
message(STATUS "qt5_plugin_paths is ${qt5_plugin_paths}")
foreach (qt5_plugin_path IN LISTS qt5_plugin_paths)
get_filename_component(qt5_plugin_group "${qt5_plugin_path}" DIRECTORY)
get_filename_component(qt5_plugin_group "${qt5_plugin_group}" NAME)
superbuild_apple_install_module(
"\${CMAKE_INSTALL_PREFIX}"
"${lidarview_appname}"
"${qt5_plugin_path}"
"Contents/Plugins/${qt5_plugin_group}"
SEARCH_DIRECTORIES "${library_paths}")
endforeach ()
install(DIRECTORY "${superbuild_install_location}/bin/${lidarview_appname}/Contents/Resources"
DESTINATION "${lidarview_appname}/Contents"
COMPONENT superbuild)
# Enable CPack packaging.
set(LidarViewSuperBuild_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../")
include(${LidarViewSuperBuild_SOURCE_DIR}/../SoftwareInformation/branding.cmake)
# Include CMake scripts for geting the version from Git
include(Git)
include(ParaViewDetermineVersion)
# Sets VV_VERSION_{MAJOR,MINOR,PATCH} for git
set(VV_VERSION_FILE ${LidarViewSuperBuild_SOURCE_DIR}/../version.txt)
file(STRINGS "${VV_VERSION_FILE}" version_txt)
extract_version_components("${version_txt}" "VV")
determine_version(${LidarViewSuperBuild_SOURCE_DIR} ${GIT_EXECUTABLE} "VV")
# Update the hard-coded version
extract_version_components("${version_txt}" "VV_file")
if((version_txt VERSION_LESS VV_VERSION_FULL)
OR (version_txt VERSION_EQUAL VV_VERSION_FULL
AND (VV_file_VERSION_PATCH_EXTRA STRLESS VV_VERSION_PATCH_EXTRA)))
message(STATUS "Outdated version file updated from ${version_txt} to ${VV_VERSION_FULL} in " ${VV_VERSION_FILE})
file(WRITE "${VV_VERSION_FILE}" "${VV_VERSION_FULL}")
endif()
if(NOT (version_txt STREQUAL VV_VERSION_FULL))
message(STATUS "Git version (${VV_VERSION_FULL}) differs from version in file (${version_txt}) at " ${VV_VERSION_FILE})
endif()
# Sets GD_YEAR, GD_MONTH, GD_DAY
include(${LidarViewSuperBuild_SOURCE_DIR}/Projects/getdate.cmake)
GET_DATE()
set(PACKAGE_TIMESTAMP "${GD_YEAR}${GD_MONTH}${GD_DAY}")
set(CPACK_COMPONENT_LIDARVIEW_DISPLAY_NAME ${SOFTWARE_NAME})
set(CPACK_PACKAGE_VERSION_MAJOR ${VV_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VV_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VV_VERSION_PATCH})
if (NOT VV_VERSION_IS_RELEASE)
set(CPACK_PACKAGE_VERSION_PATCH ${VV_VERSION_PATCH}-${VV_VERSION_PATCH_EXTRA})
else()
endif()
if (NOT VV_VERSION_IS_RELEASE)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${VV_VERSION_FULL}-${PACKAGE_TIMESTAMP}-${package_suffix}")
else()
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${VV_VERSION_FULL}-${package_suffix}")
endif()
message(STATUS "Bundled package name will be: ${CPACK_PACKAGE_FILE_NAME}" )
# Set the license file.
set(CPACK_RESOURCE_FILE_LICENSE "${LidarViewSuperBuild_SOURCE_DIR}/LICENSE")
list(APPEND lidarview_executables
"${SOFTWARE_NAME}"
"PacketFileSender"
"PCAPTester"
)
if (qt5_enabled)
include(qt5.functions)
set(qt5_plugin_prefix)
if (NOT WIN32)
set(qt5_plugin_prefix "lib")
endif ()
set(qt5_plugins
sqldrivers/${qt5_plugin_prefix}qsqlite)
if (WIN32)
list(APPEND qt5_plugins
platforms/qwindows)
elseif (APPLE)
list(APPEND qt5_plugins
platforms/libqcocoa
printsupport/libcocoaprintersupport)
elseif (UNIX)
list(APPEND qt5_plugins
platforms/libqxcb
platforminputcontexts/libcomposeplatforminputcontextplugin
xcbglintegrations/libqxcb-glx-integration)
endif ()
superbuild_install_qt5_plugin_paths(qt5_plugin_paths ${qt5_plugins})
else ()
set(qt5_plugin_paths)
endif ()
superbuild_add_project(lidarview
DEPENDS paraview qt5 pcap boost eigen liblas yaml
DEFAULT_ON
CMAKE_ARGS
-DBUILD_SHARED_LIBS:BOOL=ON
-DBUILD_TESTING:BOOL=OFF
-DParaView_DIR:PATH=${SuperBuild_BINARY_DIR}/common-superbuild/paraview/build
-DEIGEN_INCLUDE_DIR:PATH=<INSTALL_DIR>/include/eigen3
-DPYTHONQT_DIR:PATH=<INSTALL_DIR>
-DVTK_DIR:PATH=${SuperBuild_BINARY_DIR}/common-superbuild/paraview/build/VTK
-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
-DBOOST_ROOT:PATH=<INSTALL_DIR>
-DBOOST_LIBRARYDIR:PATH=<INSTALL_DIR>/lib
-Dqt_version:STRING=${qt_version}
-DPCL_DIR:PATH=<INSTALL_DIR>/share/pcl-1.8/
-DYAML_DIR:PATH=<INSTALL_DIR>/include/yaml-cpp/
-DENABLE_pcl=${ENABLE_pcl}
-DENABLE_ceres=${ENABLE_ceres}
-DENABLE_opencv=${ENABLE_opencv}
-DENABLE_nanoflann=${ENABLE_nanoflann}
)
if (WIN32 OR APPLE)
# These options are useful to use Boost as a dynamic library.
# Boost_USE_STATIC_LIBS is off by default, but sometimes that is not sufficient
# on windows (especially with MSVC ?)
superbuild_append_flags(cxx_flags "-DBOOST_ALL_NO_LIB" PROJECT_ONLY)
superbuild_append_flags(cxx_flags "-DBOOST_ALL_DYN" PROJECT_ONLY)
endif()