diff --git a/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in b/CMake/Utilities/imstkCTestAddInnerbuild.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..b1b69cf69d808fdd0618cb7cb94001d60861ab6e --- /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 4c1469ba4788825ceb337f11145e52d079c5b35e..31dc5470296e195df042205ab97acb22e09bf762 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() #-----------------------------------------------------------------------------