From f3522cb84fdf916abfb4ea4bc7abd8186ece22db Mon Sep 17 00:00:00 2001 From: Alexis Girault <alexis.girault@kitware.com> Date: Tue, 8 Nov 2016 10:37:33 -0500 Subject: [PATCH] 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. --- .../imstkCTestAddInnerbuild.cmake.in | 15 ++++ CMakeLists.txt | 82 +++++++++++-------- 2 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 CMake/Utilities/imstkCTestAddInnerbuild.cmake.in diff --git a/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in b/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in new file mode 100644 index 000000000..b1b69cf69 --- /dev/null +++ b/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in @@ -0,0 +1,15 @@ +# 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() diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c1469ba4..31dc54702 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() #----------------------------------------------------------------------------- -- GitLab