Commit 098f7fd3 authored by Matt Clarkson's avatar Matt Clarkson
parents
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.h text
*.hpp text
*.cpp text
*.cxx text
*.txx text
*.qrc text
*.ui text
*.txt text
*.cmake text
*.cmake.in text
*.bat text
*.bat.in text
*.pyc
*~
# Mercurial:
.hg*
# IntelliJ config files:
/.idea
# Eclipse config files:
/.cproject
/.project
# QtCreator config files:
/*.config
/*.creator
/*.creator.user
/*.files
/*.includes
/*.autosave
/CMakeLists.txt.user*
# Mac Finder:
.DS_Store
# CLion/IntelliJ
*cmake-build-debug
.idea/*
# From building python wheels, (normally using CI servers).
build/
dist/
*.egg-info
[submodule "Code/Lib/PythonPyBind/pybind11"]
path = Code/PythonPyBind/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "Code/Lib/PythonBoost/pyboostcvconverter"]
path = Code/PythonBoost/pyboostcvconverter
url = https://github.com/Algomorph/pyboostcvconverter.git
[submodule "multibuild"]
path = multibuild
url = https://github.com/matthew-brett/multibuild.git
#!/usr/bin/env bash
# Script to quickly restore project folder for quick testing.
git add rename.sh
git add restore.sh
git clean -fd
git checkout .
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
# Inspired by: https://github.com/skvark/opencv-python
# and : https://github.com/matthew-brett/multibuild
# and : https://github.com/thompson318/ndicapi-wheels
language: python
# The Travis Python version is unrelated to the version we build and test
# with. This is set with the MB_PYTHON_VERSION variable.
python: 3.6
sudo: required
dist: trusty
services: docker
# To Do: Where to put these?
# Most of these were deduced while testing various combinations of
# VTK, PCL, OpenCV etc. Your project may be able to get away with a
# much smaller list, depending on your actual testing requirements.
#
#sudo apt-get update
#sudo apt-get -yqq install build-essential
#sudo apt-get -yqq install binutils-gold
#sudo apt-get -yqq install freeglut3
#sudo apt-get -yqq install freeglut3-dev
#sudo apt-get -yqq install libglew-dev
#sudo apt-get -yqq install libglew1.5-dev
#sudo apt-get -yqq install libglm-dev
#sudo apt-get -yqq install mesa-common-dev
#sudo apt-get -yqq install mesa-utils-extra
#sudo apt-get -yqq install libgl1-mesa-dev
#sudo apt-get -yqq install libglapi-mesa
env:
global:
- DO_PYTHON_BUILD="true"
- "PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'"
- REPO_DIR=.
- BUILD_COMMIT=HEAD
- BUILD_DEPENDS="numpy six wheel"
- TEST_DEPENDS="numpy six pytest"
- BDIST_PARAMS=""
- PLAT=x86_64
- UNICODE_WIDTH=32
matrix:
fast_finish: true
exclude:
# Exclude the default Python 3.6 build
- python: 3.6
include:
# Builds for MacOS
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=2.7
- BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.6
- BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
- os: osx
language: generic
env:
- MB_PYTHON_VERSION=3.7
- BDIST_PARAMS="-- -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7"
# Builds for Linux
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=2.7
- PLAT=i686
- UNICODE_WIDTH=16
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- os: linux
env:
- MB_PYTHON_VERSION=3.5
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.6
- os: linux
env:
- MB_PYTHON_VERSION=3.6
- PLAT=i686
- os: linux
env:
- MB_PYTHON_VERSION=3.7
- os: linux
env:
- MB_PYTHON_VERSION=3.7
- PLAT=i686
before_install:
- source multibuild/common_utils.sh
- source multibuild/travis_steps.sh
- before_install
install: |
echo "Starting main library build section."
if [ "${DO_PYTHON_BUILD}" = "true" ]; then
echo "DO_PYTHON_BUILD=true, so will do C++ and then build a wheel."
if [ -n "$IS_OSX" ]; then
# On Mac, it builds it inside the Travis Mac VM.
# So, you could add various homebrew commands to pre-install stuff,
# or if you are reading the travis documentation, you could use
# travis type directives like 'addons', which are normally configured above.
build_wheel $REPO_DIR $PLAT
else
# On Linux, this builds the C++ and then wheel
# inside a manylinux docker container (Centos 5).
DOCKER_IMAGE=quay.io/skvark/manylinux1_$PLAT
build_multilinux $PLAT "build_wheel $REPO_DIR"
fi
else
echo "DO_PYTHON_BUILD is not set to true, so will just do C++."
# This builds the C++ inside the Travis VM. On Linux this will
# be the OS listed above, e.g. Ubuntu trusty. So, if your project
# is only doing C++ and not Python, you will need debian based
# 'sudo apt-get' type commands, either here, or if you are reading
# travis documentation, then using various travis type directives
# like 'addons', which are normally configured at the top of this file.
source ci_cmake_build.sh
cmake_build
fi
echo "Finished main library build section."
script: |
echo "Starting to check if we are running tests on installed python wheel."
if [ "${DO_PYTHON_BUILD}" = "true" ]; then
echo "DO_PYTHON_BUILD is set to true, which means config.sh::run_tests() is called."
install_run $PLAT
else
echo "Nothing to do as DO_PYTHON_BUILD is not set to true."
fi
echo "Finished running tests on installed python wheel."
after_success: |
echo "Starting to check if we are deploying to PyPi"
if [ -n "$TRAVIS_TAG" ]; then
if [ "${DO_PYTHON_BUILD}" = "true" ]; then
pip install twine
if [[ "$TRAVIS_OS_NAME" = "osx" ]]; then
pip install --upgrade pyOpenSSL
fi
twine upload --repository pypi -u ${PYPI_USER} -p ${PYPI_PASS} --skip-existing wheelhouse/*
else
echo "Deployment skipped as DO_PYTHON_BUILD is not set to true."
fi
else
echo "Deployment skipped as git tag not set."
fi
echo "Finished any necessary deployment."
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
# This file is configured at cmake time, and loaded at cpack time.
# To pass variables to cpack from cmake, they must be configured
# in this file. At the moment we aren't configuring much,
# but for example, NSIS on Windows may require lots of variables.
# NOTE: Also, I noticed if you choose >1 option for Mac, i.e. PackageManager and DragNDrop, variables start going wrong.
if("${CPACK_GENERATOR}" STREQUAL "DragNDrop")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON)
set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
elseif("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
set(CPACK_PACKAGING_INSTALL_PREFIX "/Applications/@SKSURGERYGPUCPP_DEPLOY_NAME@")
elseif("${CPACK_GENERATOR}" STREQUAL "TGZ")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON)
elseif("${CPACK_GENERATOR}" STREQUAL "TBZ2")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON)
elseif("${CPACK_GENERATOR}" STREQUAL "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "@SKSURGERYGPUCPP__CONTACT@")
set(CPACK_PACKAGE_DEFAULT_LOCATION "/opt/@SKSURGERYGPUCPP_DEPLOY_NAME@")
elseif("${CPACK_GENERATOR}" STREQUAL "NSIS")
set(CPACK_NSIS_DISPLAY_NAME "@CPACK_PACKAGE_NAME@-@CPACK_PACKAGE_VERSION@")
set(CPACK_NSIS_PACKAGE_NAME "@CPACK_PACKAGE_FILE_NAME@")
set(CPACK_NSIS_HELP_LINK "http://cmic.cs.ucl.ac.uk")
set(CPACK_NSIS_URL_INFO_ABOUT "http://cmic.cs.ucl.ac.uk")
set(CPACK_NSIS_CREATE_ICONS_EXTRA "${CREATE_ICON_LIST} @ICONS_SETUP_STRING@")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "${UNINSTALL_LIST} @ICONS_REMOVE_STRING@")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "@DESKTOP_ICONS_SETUP_STRING@")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "@DESKTOP_ICONS_REMOVE_STRING@")
# set(CPACK_NSIS_MUI_FINISHPAGE_RUN "QtVTKDemo.exe")
set(CPACK_NSIS_MODIFY_PATH ON)
endif()
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
############################################################################
# First, set the generator variable
############################################################################
if(NOT CPACK_GENERATOR)
if(WIN32)
find_program(NSIS_MAKENSIS NAMES makensis
PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
DOC "Where is makensis.exe located"
)
if(NOT NSIS_MAKENSIS)
set(CPACK_GENERATOR ZIP)
else()
set(CPACK_GENERATOR "NSIS")
endif(NOT NSIS_MAKENSIS)
set(CPACK_SOURCE_GENERATOR ZIP)
else()
if(APPLE)
set(CPACK_GENERATOR "DragNDrop")
else()
set(CPACK_GENERATOR TBZ2)
endif()
set(CPACK_SOURCE_GENERATOR TBZ2)
endif()
endif(NOT CPACK_GENERATOR)
############################################################################
# This bit came from MITK (http://www.mitk.org). Don't know if we need it. Yes we do.
############################################################################
# Should apply only to windows. Note however, that the debug crt is
# non-redistributable! a debug-package cannot be made available to the public.
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_INSTALL_DEBUG_LIBRARIES ON)
endif()
include(InstallRequiredSystemLibraries)
############################################################################
# This bit came from various CMIC packages - START
############################################################################
if (CMAKE_SYSTEM_PROCESSOR MATCHES "unknown")
set (CMAKE_SYSTEM_PROCESSOR "x86")
endif ()
if(NOT DEFINED CPACK_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
endif()
if(${CPACK_SYSTEM_NAME} MATCHES Windows)
if(CMAKE_CL_64)
set(CPACK_SYSTEM_NAME Win64-${CMAKE_SYSTEM_PROCESSOR})
else()
set(CPACK_SYSTEM_NAME Win32-${CMAKE_SYSTEM_PROCESSOR})
endif()
endif()
if(${CPACK_SYSTEM_NAME} MATCHES Darwin AND CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES _length)
if(_length GREATER 1)
set(CPACK_SYSTEM_NAME Darwin-Universal)
else()
set(CPACK_SYSTEM_NAME Darwin-${CMAKE_OSX_ARCHITECTURES})
endif()
endif()
############################################################################
# This bit came from various CMIC packages - END
############################################################################
############################################################################
# The main setting of CPack settings that are independent of generator.
# See also CPackOptions.cmake.in, which gets modified at CMake time,
# and then used at CPack time.
############################################################################
set(CPACK_PACKAGE_NAME "${SKSURGERYGPUCPP_PACKAGE_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_NAME} - for doing something interesting.")
set(CPACK_PACKAGE_VENDOR "University College London.")
set(CPACK_PACKAGE_VERSION "${SKSURGERYGPUCPP_VERSION_MAJOR}.${SKSURGERYGPUCPP_VERSION_MINOR}.${SKSURGERYGPUCPP_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${SKSURGERYGPUCPP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${SKSURGERYGPUCPP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${SKSURGERYGPUCPP_VERSION_PATCH}")
#set(CPACK_CREATE_DESKTOP_LINKS "QtVTKDemo")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_BINARY_DIR}/README.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_BINARY_DIR}/INSTALLATION.txt")
set(CPACK_PACKAGE_FILE_NAME "${SKSURGERYGPUCPP_DEPLOY_NAME}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${SKSURGERYGPUCPP_DEPLOY_NAME}")
set(CPACK_MONOLITHIC_INSTALL ON)
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
set(CTEST_SOURCE_DIRECTORY "@CMAKE_SOURCE_DIR@")
set(CTEST_BINARY_DIRECTORY "@CMAKE_BINARY_DIR@")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_BUILD_NAME "@CTEST_BUILD_NAME@")
set(CTEST_GIT_COMMAND "@GIT_EXECUTABLE@")
set(SKSURGERYGPUCPP_BRANCH_NAME "@SKSURGERYGPUCPP_BRANCH_NAME@")
find_program(HOSTNAME_CMD NAMES hostname)
exec_program("${HOSTNAME_CMD}" ARGS OUTPUT_VARIABLE HOSTNAME)
set(CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}")
#
# This macro is to find the branch whose tip is the commit to test.
#
macro(GetBranchName branch_name_var)
execute_process(COMMAND "${CTEST_GIT_COMMAND}" branch -r --contains HEAD --merged HEAD
WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY}
ERROR_VARIABLE GIT_error
OUTPUT_VARIABLE remote_ref_names)
if(NOT ${GIT_error} EQUAL 0)
message(SEND_ERROR "Command '${CTEST_GIT_COMMAND} branch -r --contains HEAD --merged' failed with output:\n${GIT_error}")
endif()
# message("remote refs: ${remote_ref_names}")
if("${remote_ref_names}" MATCHES "origin/([^ \n]*)\n")
set(branch_name ${CMAKE_MATCH_1})
else()
message("Branch has not been pushed to origin. Test report will be submitted to the Continuous group.")
endif()
set(${branch_name_var} ${branch_name})
endmacro()
#
# This macro gets the first few digits of the current commit hash.
#
macro(GetCommitHash commit_hash_var)
execute_process(COMMAND "${CTEST_GIT_COMMAND}" log -n 1 --pretty=format:%h HEAD
WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY}
ERROR_VARIABLE GIT_error
OUTPUT_VARIABLE ${commit_hash_var}
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_error} EQUAL 0)
message(SEND_ERROR "Command \"${CTEST_GIT_COMMAND} log -n 1 --pretty=format:\"%h\" HEAD in directory ${CTEST_SOURCE_DIRECTORY} failed with output:\n${GIT_error}")
endif()
endmacro()
#
# This macro gets the first few digits of the current commit hash.
#
macro(GetNumberOfCpuCores cpu_cores_var)
if(DEFINED PARALLEL_LEVEL)
set(cpu_cores ${PARALLEL_LEVEL})
else()
set(cpu_cores 1)
set(cpuinfo_file "/proc/cpuinfo")
if(EXISTS "${cpuinfo_file}")
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
list(LENGTH procs cpu_cores)
endif()
if(APPLE)
find_program(cmd_sysctl "sysctl")
if(cmd_sysctl)
execute_process(COMMAND "${cmd_sysctl}" -n hw.ncpu OUTPUT_VARIABLE cpu_cores OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
if(WIN32)
set(cpu_cores "$ENV{NUMBER_OF_PROCESSORS}")
endif()
endif()
set(${cpu_cores_var} ${cpu_cores})
endmacro()
#
# This macro gets the build name that is the compiler version plus the commit hash.
#
macro(GetBuildName build_name_var)
if (CTEST_BUILD_NAME MATCHES "(.*)-${SKSURGERYGPUCPP_BRANCH_NAME}-${commit_hash}-(Rel|Dbg)")
set(compiler_name ${CMAKE_MATCH_1})
set(build_type ${CMAKE_MATCH_2})
set(build_name "${compiler_name}-${commit_hash}-${build_type}")
else()
set(build_name "${commit_hash}")
endif()
set(${build_name_var} ${build_name})
endmacro()
GetBranchName(branch_name)
GetCommitHash(commit_hash)
GetBuildName(build_name)
GetNumberOfCpuCores(cpu_cores)
if (NOT ${branch_name} STREQUAL "")
set(group_name ${branch_name})
else()
set(group_name "Continuous")
endif()
message("Remote branch: ${branch_name}")
message("Group: ${group_name}")
message("Build name: ${build_name}")
message("Threads: ${cpu_cores}")
set(CTEST_BUILD_NAME ${build_name})
if ("${CTEST_CMAKE_GENERATOR}" STREQUAL "Unix Makefiles")
set(CTEST_BUILD_FLAGS "-j ${cpu_cores}")
endif()
set(PARALLEL_LEVEL ${cpu_cores})
ctest_start(Continuous TRACK ${group_name})
ctest_build()
ctest_test(EXCLUDE "${tests_to_exclude}" RETURN_VALUE exitCode)
ctest_submit()
if (exitCode)
message(SEND_ERROR "Some unit tests failed. CTest exit code: ${exitCode}")
endif()
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
set (CTEST_EXTRA_COVERAGE_GLOB ${CTEST_EXTRA_COVERAGE_GLOB})
foreach (E IN ITEMS .c .cpp .h .txx)
list (APPEND CTEST_EXTRA_COVERAGE_GLOB
"Code/*/*${E}"
)
endforeach ()
set(CTEST_CUSTOM_COVERAGE_EXCLUDE
${CTEST_CUSTOM_COVERAGE_EXCLUDE}
# Exclude try_compile sources from coverage results:
".*/CMakeFiles/CMakeTmp/.*"
# Exclude files generated by the moc pre-compiler
".*/moc_.*"
# Exclude files generated by the uic pre-compiler
".*/ui_.*"
)
# The following tests should not be run under valgrind
set(CTEST_CUSTOM_MEMCHECK_IGNORE
)
set(CTEST_CUSTOM_ERROR_MATCH
${CTEST_CUSTOM_ERROR_MATCH}
"CMake Error[ :]"
)
set(CTEST_CUSTOM_WARNING_MATCH
${CTEST_CUSTOM_WARNING_MATCH}
"CMake Warning[ :]"
)
set(CTEST_CUSTOM_WARNING_EXCEPTION
${CTEST_CUSTOM_WARNING_EXCEPTION}
# kwstyle suppressions
"[Kk][Ww][Ss]tyle.*kws.*cxx"
"[Kk][Ww][Ss]tyle.*kws.*h"
"[Kk][Ww][Ss]tyle.*metaCommand.*cxx"
)
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
# This software is distributed WITHOUT ANY WARRANTY; without even
# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.
#
# See LICENSE.txt in the top level directory for details.
#
#============================================================================*/
#-----------------------------------------------------------------------------
# ArrayFire
#-----------------------------------------------------------------------------
if(NOT BUILD_ArrayFire)
return()
endif()
# Sanity checks
if(DEFINED ArrayFire_DIR AND NOT EXISTS ${ArrayFire_DIR})
message(FATAL_ERROR "ArrayFire_DIR variable is defined but corresponds to non-existing directory \"${ArrayFire_DIR}\".")
endif()
set(ArrayFire_VERSION "dc38ef1329")
set(location "https://github.com/arrayfire/arrayfire.git")
mpMacroDefineExternalProjectVariables(ArrayFire ${ArrayFire_VERSION} ${location})
set(proj_DEPENDENCIES )
if(NOT DEFINED ArrayFire_DIR)
ExternalProject_Add(${proj}
LIST_SEPARATOR ^^
PREFIX ${proj_CONFIG}
SOURCE_DIR ${proj_SOURCE}