Commit 0162d462 authored by Matt Clarkson's avatar Matt Clarkson

Merge branch '1-add-continuous-integration'

parents 415eb692 4324b782
Pipeline #4101 passed with stages
in 21 minutes and 31 seconds
#/*============================================================================
#
# 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.
#
#============================================================================*/
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- test
- cleanup
##########################################
# Linux build jobs
##########################################
linux build:
stage: build
tags:
- shared-linux, cuda
script:
- export git_hash=${CI_COMMIT_SHORT_SHA}
- export src_dir=${CI_PROJECT_DIR}
- export sb_dir="${src_dir}-sb"
- export pb_dir="${sb_dir}/SKSURGERYGPUCPP-build"
- echo "Commit - ${git_hash}"
- echo "Sources - ${src_dir}"
- echo "Superbuild - ${sb_dir}"
- echo "Project build - ${pb_dir}"
- hostname
- whoami
- pwd
- cmake --version
- pwd
- if [ -e ${sb_dir} ]; then rm -rf ${sb_dir}; fi
- mkdir -p ${sb_dir}
- cd ${sb_dir}
- pwd
- python3 -m venv continuousenv
- source continuousenv/bin/activate
- pip install numpy wheel six opencv-contrib-python pytest
- cmake -DCMAKE_BUILD_TYPE:STRING=Release
-DSKSURGERYGPUCPP_USE_CUDA:BOOL=ON
-DSKSURGERYGPUCPP_CUDA_ARCH_BIN:STRING=61
${src_dir}
- make -j 1
linux test:
stage: test
tags:
- shared-linux, cuda
script:
- export src_dir=${CI_PROJECT_DIR}
- export sb_dir="${src_dir}-sb"
- export pb_dir="${sb_dir}/SKSURGERYGPUCPP-build"
- pwd
- cd ${sb_dir}
- pwd
- source continuousenv/bin/activate
- cd ${pb_dir}
- ctest -S CTestContinuous.cmake -V
- cd ${src_dir}
- python setup.py bdist_wheel
- pip install dist/*
- python -c "import sksurgerygpupython as sk; sk.print_cuda_device_info()"
- python -c "import sksurgerygpupython as sk; import numpy as np; a = 2 * np.ones((4,4)); b = 3 * np.ones( (4,4)); c = sk.multiply_two_arrays(a,b); print(c)"
- python -m pytest -v -s ./Testing/
- deactivate
linux cleanup:
stage: cleanup
when: always
tags:
- shared-linux, cuda
script:
- export src_dir=${CI_PROJECT_DIR}
- export sb_dir="${src_dir}-sb"
- pwd
- rm -rf ${sb_dir}
##########################################################
# Windows build jobs
##########################################################
windows build:
stage: build
tags:
- shared-win-cuda
script:
- ${Env:git_hash} = ${CI_COMMIT_SHORT_SHA}
- ${Env:src_dir} = ${CI_PROJECT_DIR}
- ${Env:sb_dir} = "C:\gitlab-runner\scikit-surgerygpucpp-sb"
- ${Env:pb_dir} = "${Env:sb_dir}\SKSURGERYGPUCPP-build"
- echo "Sources - ${Env:src_dir}"
- echo "Commit - ${Env:git_hash}"
- echo "Superbuild - ${Env:sb_dir}"
- echo "Project build - ${Env:pb_dir}"
- ${Env:PATH} = "C:\Program Files\CMake\bin;C:\Python36;C:\Python36\Scripts;${Env:PATH}"
- ${Env:GIT_SSL_NO_VERIFY} = 1
- pwd
- hostname
- whoami
- cmake -version
- cd ${Env:sb_dir}
- python.exe -m venv continuousenv
- continuousenv/Scripts/activate
- pip install numpy wheel six opencv-contrib-python pytest
- cmake -G "Visual Studio 15 2017 Win64"
-DCMAKE_BUILD_TYPE:STRING=Release
-DSKSURGERYGPUCPP_USE_CUDA:BOOL=OFF
-DSKSURGERYGPUCPP_CUDA_ARCH_BIN:STRING=61
--config "Release" ${Env:src_dir}
- if ($LastExitCode -ne 0) {throw $LastExitCode}
- cmake --build . --config Release
- if ($LastExitCode -ne 0) {throw $LastExitCode}
windows test:
stage: test
tags:
- shared-win-cuda
script:
- ${Env:src_dir} = ${CI_PROJECT_DIR}
- ${Env:sb_dir} = "C:\gitlab-runner\scikit-surgerygpucpp-sb"
- ${Env:pb_dir} = "${Env:sb_dir}\SKSURGERYGPUCPP-build"
- echo "Sources - ${Env:src_dir}"
- echo "Superbuild - ${Env:sb_dir}"
- echo "Project build - ${Env:pb_dir}"
- ${Env:PATH} = "C:\Program Files\CMake\bin;C:\Python36;C:\Python36\Scripts;${Env:PATH}"
- pwd
- cd ${Env:sb_dir}
- pwd
- continuousenv/Scripts/activate
- cd ${Env:pb_dir}
- ctest -S CTestContinuous.cmake -V
- if ($LastExitCode -ne 0) {throw $LastExitCode}
- cd ${Env:src_dir}
- if ($LastExitCode -ne 0) {throw $LastExitCode}
- python setup.py bdist_wheel
- if ($LastExitCode -ne 0) {throw $LastExitCode}
- dir dist
- $wheel_files = @(Get-ChildItem dist\* -include *.whl)
- $wheel = $wheel_files[0]
- echo "Wheel file is $wheel"
- pip install --upgrade --no-index --find-links dist $wheel
- if ($LastExitCode -ne 0) {throw $LastExitCode}
- python -c "import sksurgerygpupython as sk; sk.print_cuda_device_info()"
- python -c "import sksurgerygpupython as sk; import numpy as np; a = 2 * np.ones((4,4)); b = 3 * np.ones( (4,4)); c = sk.multiply_two_arrays(a,b); print(c)"
- python -m pytest -v -s ./Testing/
- deactivate
windows cleanup:
stage: cleanup
when: always
tags:
- shared-win-cuda
script:
- ${Env:sb_dir} = "C:\gitlab-runner\scikit-surgerygpucpp-sb"
- echo "Should remove ${Env:sb_dir}"
......@@ -143,7 +143,6 @@ 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()
......
......@@ -46,7 +46,7 @@ if(NOT DEFINED ArrayFire_DIR)
${EP_COMMON_ARGS}
-DCMAKE_PREFIX_PATH:PATH=${SKSURGERYGPUCPP_PREFIX_PATH}
-DAF_BUILD_CPU:BOOL=ON
-DAF_BUILD_CUDA:BOOL=OFF
-DAF_BUILD_CUDA:BOOL=ON
-DAF_BUILD_OPENCL:BOOL=OFF
CMAKE_CACHE_ARGS
${EP_COMMON_CACHE_ARGS}
......
......@@ -82,6 +82,9 @@ if(NOT DEFINED BOOST_ROOT AND NOT SKSURGERYGPUCPP_USE_SYSTEM_Boost)
elseif(MSVC_VERSION EQUAL 1900)
set(_boost_with_toolset "vc14")
set(_boost_toolset "msvc-14.0")
elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1920)
set(_boost_with_toolset "vc141")
set(_boost_toolset "msvc-14.1")
endif()
endif()
set(_install_lib_dir "--libdir=<INSTALL_DIR>/bin")
......@@ -174,6 +177,7 @@ if(NOT DEFINED BOOST_ROOT AND NOT SKSURGERYGPUCPP_USE_SYSTEM_Boost)
threading=multi
runtime-link=${_boost_link}
--ignore-site-config
--abbreviate-paths
-q
)
......
......@@ -24,10 +24,10 @@ if(DEFINED OpenCV_DIR AND NOT EXISTS ${OpenCV_DIR})
message(FATAL_ERROR "OpenCV_DIR variable is defined but corresponds to non-existing directory")
endif()
set(version "3.4.5")
set(version "${OPENCV_VERSION}")
set(location "https://github.com/opencv/opencv.git")
mpMacroDefineExternalProjectVariables(OpenCV ${version} ${location})
set(proj_DEPENDENCIES )
set(proj_DEPENDENCIES OpenCVContrib)
if (BUILD_VTK)
list(APPEND proj_DEPENDENCIES VTK)
endif()
......@@ -42,6 +42,7 @@ if(NOT DEFINED OpenCV_DIR)
# as possible, and just provide a few re-usable algorithms.
##############################################################################
set(_additional_options
-DBUILD_TESTS:BOOL=OFF # in addition to BUILD_TESTING defined in SuperBuild.cmake
-DWITH_QT:BOOL=OFF
-DWITH_GTK:BOOL=OFF
-DWITH_EIGEN:BOOL=OFF
......@@ -55,38 +56,105 @@ if(NOT DEFINED OpenCV_DIR)
-DENABLE_PRECOMPILED_HEADERS:BOOL=OFF
-DOPENCV_PYTHON_SKIP_DETECTION:BOOL=ON
)
if (NOT APPLE)
if(WIN32)
list(APPEND _additional_options
-DWITH_LAPACK:BOOL=ON
)
else()
elseif(APPLE)
list(APPEND _additional_options
-DWITH_LAPACK:BOOL=OFF
-DWITH_IPP:BOOL=OFF
)
else()
list(APPEND _additional_options
-DWITH_LAPACK:BOOL=ON
-DWITH_IPP:BOOL=OFF
-DWITH_V4L:BOOL=OFF
-DWITH_GSTREAMER:BOOL=OFF
)
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U__STRICT_ANSI__")
endif()
endif()
set(_contrib_options
-DOPENCV_EXTRA_MODULES_PATH=${OpenCVContrib_DIR}/modules
-DBUILD_opencv_aruco:BOOL=OFF
-DBUILD_opencv_bgsegm:BOOL=OFF
-DBUILD_opencv_bioinspired:BOOL=OFF
-DBUILD_opencv_ccalib:BOOL=OFF
-DBUILD_opencv_cnn_3dobj:BOOL=OFF
-DBUILD_opencv_cudaarithm:BOOL=ON
-DBUILD_opencv_cudabgsegm:BOOL=OFF
-DBUILD_opencv_cudacodec:BOOL=OFF
-DBUILD_opencv_cudafeatures2d:BOOL=OFF
-DBUILD_opencv_cudafilters:BOOL=OFF
-DBUILD_opencv_cudaimgproc:BOOL=ON
-DBUILD_opencv_cudalegacy:BOOL=ON
-DBUILD_opencv_cudaobjdetect:BOOL=OFF
-DBUILD_opencv_cudaoptflow:BOOL=ON
-DBUILD_opencv_cudastereo:BOOL=ON
-DBUILD_opencv_cudawarping:BOOL=OFF
-DBUILD_opencv_cudev:BOOL=ON
-DBUILD_opencv_cvv:BOOL=OFF
-DBUILD_opencv_datasets:BOOL=OFF
-DBUILD_opencv_dnn_objdetect:BOOL=OFF
-DBUILD_opencv_dnns_easily_fooled:BOOL=OFF
-DBUILD_opencv_dpm:BOOL=OFF
-DBUILD_opencv_face:BOOL=OFF
-DBUILD_opencv_freetype:BOOL=OFF
-DBUILD_opencv_fuzzy:BOOL=OFF
-DBUILD_opencv_hdf:BOOL=OFF
-DBUILD_opencv_hfs:BOOL=OFF
-DBUILD_opencv_img_hash:BOOL=OFF
-DBUILD_opencv_line_descriptor:BOOL=OFF
-DBUILD_opencv_matlab:BOOL=OFF
-DBUILD_opencv_optflow:BOOL=OFF
-DBUILD_opencv_ovis:BOOL=OFF
-DBUILD_opencv_phase_unwrapping:BOOL=OFF
-DBUILD_opencv_plot:BOOL=ON
-DBUILD_opencv_quality:BOOL=OFF
-DBUILD_opencv_reg:BOOL=OFF
-DBUILD_opencv_rgbd:BOOL=OFF
-DBUILD_opencv_saliency:BOOL=OFF
-DBUILD_opencv_sfm:BOOL=OFF
-DBUILD_opencv_shape:BOOL=OFF
-DBUILD_opencv_stereo:BOOL=ON
-DBUILD_opencv_structured_light:BOOL=OFF
-DBUILD_opencv_superres:BOOL=OFF
-DBUILD_opencv_surface_matching:BOOL=OFF
-DBUILD_opencv_text:BOOL=OFF
-DBUILD_opencv_tracking:BOOL=ON
-DBUILD_opencv_videostab:BOOL=OFF
-DBUILD_opencv_viz:BOOL=OFF
-DBUILD_opencv_xfeatures2d:BOOL=OFF
-DBUILD_opencv_ximgproc:BOOL=OFF
-DBUILD_opencv_xobjdetect:BOOL=OFF
-DBUILD_opencv_xphoto:BOOL=OFF
)
if(BUILD_Python_Boost OR BUILD_Python_PyBind)
message("Building minimum OpenCV modules, as you want a Python build.")
list(APPEND _additional_options
-DBUILD_opencv_apps:BOOL=OFF
-DBUILD_opencv_calib3d:BOOL=ON
-DBUILD_opencv_core:BOOL=ON
-DBUILD_opencv_imgproc:BOOL=ON
-DBUILD_opencv_apps:BOOL=OFF
-DBUILD_opencv_dnn:BOOL=OFF
-DBUILD_opencv_features2d:BOOL=ON
-DBUILD_opencv_flann:BOOL=ON
-DBUILD_opencv_gapi:BOOL=OFF
-DBUILD_opencv_highgui:BOOL=ON
-DBUILD_opencv_imgcodecs:BOOL=ON
-DBUILD_opencv_imgproc:BOOL=ON
-DBUILD_opencv_java:BOOL=OFF
-DBUILD_opencv_java_bindings_generator:BOOL=OFF
-DBUILD_opencv_js:BOOL=OFF
-DBUILD_opencv_ml:BOOL=OFF
-DBUILD_opencv_objdetect:BOOL=OFF
-DBUILD_opencv_photo:BOOL=OFF
-DBUILD_opencv_python2:BOOL=OFF
-DBUILD_opencv_python:BOOL=OFF
-DBUILD_opencv_python_bindings_generator:BOOL=OFF
-DBUILD_opencv_stitching:BOOL=OFF
-DBUILD_opencv_ts:BOOL=OFF
......@@ -149,6 +217,7 @@ if(NOT DEFINED OpenCV_DIR)
-DBUILD_DOXYGEN_DOCS:BOOL=OFF
-DBUILD_PERF_TESTS:BOOL=OFF
${_additional_options}
${_contrib_options}
${_cuda_options}
"-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} ${SKSURGERYGPUCPP_CXX11_FLAG} -DVTK_MAJOR_VERSION=6" # Doesn't matter what version, as long as > 5.
${additional_cmake_args}
......
#/*============================================================================
#
# 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.
#
#============================================================================*/
#-----------------------------------------------------------------------------
# OpenCV contrib gets built whenever OpenCV is selected.
# This cmake file just downloads it, so it wont take too long.
#-----------------------------------------------------------------------------
if(NOT BUILD_OpenCV)
return()
endif()
# Sanity checks
if(DEFINED OpenCVContrib_DIR AND NOT EXISTS ${OpenCVContrib_DIR})
message(FATAL_ERROR "OpenCVContrib_DIR variable is defined but corresponds to non-existing directory")
endif()
set(version "b4b7f69136")
set(location "https://github.com/dimitrisPs/opencv_contrib.git")
mpMacroDefineExternalProjectVariables(OpenCVContrib ${version} ${location})
set(proj_DEPENDENCIES )
if(NOT DEFINED OpenCVContrib_DIR)
ExternalProject_Add(${proj}
LIST_SEPARATOR ^^
PREFIX ${proj_CONFIG}
SOURCE_DIR ${proj_SOURCE}
BINARY_DIR ${proj_BUILD}
INSTALL_DIR ${proj_INSTALL}
GIT_REPOSITORY ${proj_LOCATION}
GIT_TAG ${proj_VERSION}
UPDATE_COMMAND ${GIT_EXECUTABLE} checkout ${proj_VERSION}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
${EP_COMMON_ARGS}
CMAKE_CACHE_ARGS
${EP_COMMON_CACHE_ARGS}
CMAKE_CACHE_DEFAULT_ARGS
${EP_COMMON_CACHE_DEFAULT_ARGS}
DEPENDS ${proj_DEPENDENCIES}
)
set(OpenCVContrib_DIR ${proj_SOURCE})
mitkFunctionInstallExternalCMakeProject(${proj})
message("SuperBuild loading OpenCVContrib from ${OpenCVContrib_DIR}")
else()
mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}")
endif()
# Copyright (c) 2003-2012 German Cancer Research Center,
# Division of Medical and Biological Informatics
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# * Neither the name of the German Cancer Research Center,
# nor the names of its contributors may be used to endorse
# or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# FindGit
#
set(git_candidates git eg)
if(WIN32)
list(APPEND git_candidates eg.cmd)
if(NOT MSYS)
# We don't append git.cmd, since it does not correctly return
# exit codes, see http://code.google.com/p/msysgit/issues/detail?id=428
list(APPEND git_candidates git.cmd)
endif()
endif()
find_program(GIT_EXECUTABLE ${git_candidates}
PATHS
"C:/Program Files/Git/bin"
"C:/Program Files (x86)/Git/bin"
DOC "git command line client")
mark_as_advanced(GIT_EXECUTABLE)
if(GIT_EXECUTABLE)
macro(GIT_IS_REPO dir result_var)
# check if ${dir} is a proper Git repository
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 HEAD
WORKING_DIRECTORY ${dir}
RESULT_VARIABLE GIT_error
OUTPUT_QUIET
ERROR_QUIET)
if(GIT_error EQUAL 0)
set(${result_var} 1)
else()
set(${result_var} 0)
endif()
endmacro()
macro(GIT_WC_INFO dir prefix)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list -n 1 HEAD
WORKING_DIRECTORY ${dir}
ERROR_VARIABLE GIT_error
OUTPUT_VARIABLE ${prefix}_WC_REVISION_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_error} EQUAL 0)
message(SEND_ERROR "Command \"${GIT_EXECUTBALE} rev-list -n 1 HEAD\" in directory ${dir} failed with output:\n${GIT_error}")
else()
execute_process(COMMAND ${GIT_EXECUTABLE} name-rev ${${prefix}_WC_REVISION_HASH}
WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE ${prefix}_WC_REVISION_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(${prefix}_WC_GITSVN 0)
# In case, git-svn is used, attempt to extract svn info
execute_process(COMMAND ${GIT_EXECUTABLE} svn info
WORKING_DIRECTORY ${dir}
ERROR_VARIABLE git_svn_info_error
OUTPUT_VARIABLE ${prefix}_WC_INFO
RESULT_VARIABLE git_svn_info_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${git_svn_info_result} EQUAL 0)
set(${prefix}_WC_GITSVN 1)
string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
"\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*"
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
endif()
endmacro()
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Git DEFAULT_MSG GIT_EXECUTABLE)
......@@ -165,7 +165,7 @@ include(sksExternalProjectHelperMacros)
######################################################################
# External projects
######################################################################
foreach(p gflags glog Eigen Boost VTK OpenCV FLANN PCL ArrayFire)
foreach(p gflags glog Eigen Boost VTK OpenCVContrib OpenCV FLANN PCL ArrayFire)
include("CMake/ExternalProjects/${p}.cmake")
endforeach()
......
# Copyright (c) 2003-2012 German Cancer Research Center,
# Division of Medical and Biological Informatics
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the
# following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the
# following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# * Neither the name of the German Cancer Research Center,
# nor the names of its contributors may be used to endorse
# or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#! \brief Extract version information from a local working copy
#!
#! If the source_dir variable points to a git repository, this function
#! extracts the current revision hash and branch/tag name.
#!
#! If the source_dir variable points to a subversion repository, this
#! function extracts the current svn revision.
#
#! The information is provided in
#! <ul>
#! <li> ${prefix}_REVISION_ID The git hash or svn revision value
#! <li> ${prefix}_REVISION_NAME The git branch/tag name or empty
#! <li> ${prefix}_WC_TYPE The working copy type, one of "local", "git", or "svn"
#! </ul>
#!
#! \param source_dir The directory containing a working copy
#! \param prefix A prefix to prepend to the variables containing
#! the extracted information.
#!
function(mitkFunctionGetVersion source_dir prefix)
if(NOT prefix)
message(FATAL_ERROR "prefix argument not specified")
endif()
# initialize variables
set(_wc_type "local")
set(_wc_id "")
set(_wc_name "")
find_package(Git)
if(GIT_FOUND)
GIT_IS_REPO(${source_dir} _is_git_repo)
if(_is_git_repo)
set(_wc_type "git")
GIT_WC_INFO(${source_dir} ${prefix})
set(_wc_id ${${prefix}_WC_REVISION_HASH})
string(REPLACE " " ";" hash_name ${${prefix}_WC_REVISION_NAME})
list(GET hash_name 1 name)
if(name)
set(_wc_name ${name})
endif()
endif()
endif()
# test for svn working copy
if(_wc_type STREQUAL "local")
find_package(Subversion)
if(Subversion_FOUND)
execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} info
WORKING_DIRECTORY ${source_dir}
RESULT_VARIABLE _subversion_result
OUTPUT_QUIET
ERROR_QUIET)
if(NOT _subversion_result)
set(_wc_type svn)
Subversion_WC_INFO(${source_dir} ${prefix})
set(_wc_id ${${prefix}_WC_REVISION})
endif()
endif()
endif()
set(${prefix}_WC_TYPE ${_wc_type} PARENT_SCOPE)
set(${prefix}_REVISION_ID ${_wc_id} PARENT_SCOPE)
set(_shortid ${_wc_id})
if(_wc_type STREQUAL "git")
string(SUBSTRING ${_shortid} 0 7 _shortid)
endif()
set(${prefix}_REVISION_SHORTID ${_shortid} PARENT_SCOPE)
set(${prefix}_REVISION_NAME ${_wc_name} PARENT_SCOPE)
# For backwards compatibility
set(${prefix}_WC_REVISION_HASH ${_wc_id} PARENT_SCOPE)
set(${prefix}_WC_REVISION_NAME ${_wc_name} PARENT_SCOPE)
endfunction()
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
# NifTK: A software platform for medical image computing.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
......@@ -12,17 +12,13 @@
#
#============================================================================*/
option(BUILD_UNITY_WRAPPER "Build Unity Wrapper." OFF)
mark_as_advanced(BUILD_UNITY_WRAPPER)
if(BUILD_UNITY_WRAPPER AND BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries" FORCE)
message("Forcing BUILD_SHARED_LIBS to OFF as you want a Unity module.")
endif()
if(BUILD_UNITY_WRAPPER)
set(SKSURGERYGPUCPP_UNITY_PLUGIN_DIR "" CACHE PATH "Path to Unity project Assets dir")
if( "${SKSURGERYGPUCPP_UNITY_PLUGIN_DIR}" STREQUAL "")
message(FATAL_ERROR "If you turn BUILD_UNITY_WRAPPER, you must specify SKSURGERYGPUCPP_UNITY_PLUGIN_DIR.")
macro(niftkMacroGetGitBranch dir prefix)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${dir}
ERROR_VARIABLE GIT_error
OUTPUT_VARIABLE ${prefix}_BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_error} EQUAL 0)
message(SEND_ERROR "Command \"${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD in directory ${dir} failed with output:\n${GIT_error}")
endif()
endif()
endmacro()
#/*============================================================================
#
# SKSURGERYGPUCPP: Image-guided surgery functions, in C++, using GPU.
# NifTK: A software platform for medical image computing.
#
# Copyright (c) University College London (UCL). All rights reserved.
#
......@@ -12,29 +12,13 @@
#
#============================================================================*/
if(NOT BUILDING_GUIS)
set(SKSURGERYGPUCPP_UNITY_NAME ${SKSURGERYGPUCPP_LIBRARY_NAME}Unity)
set(SKSURGERYGPUCPP_UNITY_SRCS
sksUnityWrapper.cpp
)
set(SKSURGERYGPUCPP_UNITY_HDRS
sksUnityWrapper.h
)