Commit f3522cb8 authored by Alexis Girault's avatar Alexis Girault

COMP: Allow CTest to cover innerbuild tests

With the superbuild architecture, the inner project
is not added as a subdirectory in the superbuild project,
but configured through ExternalProject_Add(). For this
reason, the CTestTestfile.cmake at the top level (superbuild
project) does not add the Innerbuild directory in which
there is another CTestTestfile.cmake referencing the tests
of the inner project.

This commit includes the file `imstkCTestAddInnerbuild.cmake.in`
which calls `subdirs()` on the Innerbuild directory. That file
is configured in the top-level build directory, and added as
the TEST_INCLUDE_FILE property to that directory. This will
include that file to the top-level CTestTestfile.cmake, which
will therefore be able to reach the CTestTestfile.cmake in the
Innerbuild directory when running ctest.

Use this commit to also only solve external dependencies
in the superbuild tree, no need to to it in the innerbuild tree.
parent 34f78b7e
# This file needs to be configured then included in the top level
# CTestTestfile.cmake of your project in order to expand ctest
# to cover the Innerbuild.
#
# To do so, set the TEST_INCLUDE_FILE property of your top level
# build directory to the configured version of this file with the
# function `set_directory_properties()`.
set(innerbuild_dir "@CMAKE_CURRENT_BINARY_DIR@/Innerbuild")
if(EXISTS "${innerbuild_dir}/CTestTestfile.cmake")
subdirs(${innerbuild_dir})
else()
message(WARNING "No CTestTestfile.cmake found in ${innerbuild_dir}. Can not add innerbuild tests.")
endif()
......@@ -62,50 +62,68 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
#-----------------------------------------------------------------------------
# Define External dependencies
#-----------------------------------------------------------------------------
macro(imstk_define_dependency extProj)
list(APPEND ${PROJECT_NAME}_DEPENDENCIES ${extProj})
option(USE_SYSTEM_${extProj} "Exclude ${extProj} from superbuild and use an existing build." OFF)
mark_as_advanced(USE_SYSTEM_${extProj})
endmacro()
option(${PROJECT_NAME}_USE_Uncrustify "Use Uncrustify as a code style beautifier." OFF)
if(${PROJECT_NAME}_USE_Uncrustify)
imstk_define_dependency(Uncrustify)
endif()
if(WIN32)
imstk_define_dependency(PThreads)
imstk_define_dependency(Libusb) #for VRPN
imstk_define_dependency(FTD2XX) #for LibNiFalcon
endif()
imstk_define_dependency(g3log)
imstk_define_dependency(Eigen)
imstk_define_dependency(SCCD)
imstk_define_dependency(VegaFEM)
imstk_define_dependency(VTK)
imstk_define_dependency(VRPN)
imstk_define_dependency(LibNiFalcon)
if(BUILD_TESTING)
imstk_define_dependency(GoogleTest)
endif()
#-----------------------------------------------------------------------------
# SUPERBUILD
#-----------------------------------------------------------------------------
option(${PROJECT_NAME}_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON)
if(${PROJECT_NAME}_SUPERBUILD)
#-----------------------------------------------------------------------------
# Define External dependencies
#-----------------------------------------------------------------------------
macro(imstk_define_dependency extProj)
list(APPEND ${PROJECT_NAME}_DEPENDENCIES ${extProj})
option(USE_SYSTEM_${extProj} "Exclude ${extProj} from superbuild and use an existing build." OFF)
mark_as_advanced(USE_SYSTEM_${extProj})
endmacro()
option(${PROJECT_NAME}_USE_Uncrustify "Use Uncrustify as a code style beautifier." OFF)
if(${PROJECT_NAME}_USE_Uncrustify)
imstk_define_dependency(Uncrustify)
endif()
if(WIN32)
imstk_define_dependency(PThreads)
imstk_define_dependency(Libusb) #for VRPN
imstk_define_dependency(FTD2XX) #for LibNiFalcon
endif()
imstk_define_dependency(g3log)
imstk_define_dependency(Eigen)
imstk_define_dependency(SCCD)
imstk_define_dependency(VegaFEM)
imstk_define_dependency(VTK)
imstk_define_dependency(VRPN)
imstk_define_dependency(LibNiFalcon)
if(BUILD_TESTING)
imstk_define_dependency(GoogleTest)
#-----------------------------------------------------------------------------
# Allow CTest to cover Innerbuild
#-----------------------------------------------------------------------------
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/imstkCTestAddInnerbuild.cmake"
@ONLY
)
set_directory_properties(PROPERTIES TEST_INCLUDE_FILE
"${CMAKE_CURRENT_BINARY_DIR}/imstkCTestAddInnerbuild.cmake"
)
endif()
#-----------------------------------------------------------------------------
# Solve project dependencies
#-----------------------------------------------------------------------------
# Call CMakeLists.txt in CMake/External which will solve the dependencies
# and add the External projects, including this one: this top-level
# CMakeLists.txt will be called back with SUPERBUILD=OFF, to execute
# the rest of the code below (INNERBUILD), which explains the `return`
add_subdirectory(CMake/External)
return()
endif()
#-----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment