Commit 9580b192 authored by Robert Maynard's avatar Robert Maynard

Introduces SourceInInstall which verifies that VTK-m install its headers

Fixes #342
parent c501500e
##============================================================================
## Copyright (c) Kitware, Inc.
## All rights reserved.
## See LICENSE.txt for details.
## This software is distributed WITHOUT ANY WARRANTY; without even
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##
## Copyright 2016 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
## Copyright 2016 UT-Battelle, LLC.
## Copyright 2016 Los Alamos National Security.
##
## Under the terms of Contract DE-NA0003525 with NTESS,
## the U.S. Government retains certain rights in this software.
##
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
## Laboratory (LANL), the U.S. Government retains certain rights in
## this software.
##============================================================================
## This CMake script checks to make sure that each source file explicitly
## listed in the CMakeLists.txt is installed.
## To run this script, execute CMake as follows:
##
## cmake -DMODE=[INSTALL|VERIFY|CLEANUP]
# -DVTKm_SOURCE_DIR=<VTKm_SOURCE_DIR>
# -DVTKm_BINARY_DIR=<VTKm_BINARY_DIR>
# -DVTKm_INSTALL_INCLUDE_DIR=<VTKm_INSTALL_INCLUDE_DIR>
# -DVTKm_ENABLE_RENDERING=<VTKm_ENABLE_RENDERING>
# -DVTKm_ENABLE_LOGGING=<VTKm_ENABLE_LOGGING>
# -P <VTKm_SOURCE_DIR>/CMake/VTKMCheckSourceInBuild.cmake
##
if (NOT DEFINED MODE)
message(FATAL_ERROR "Need to pass the MODE variable (INSTALL|VERIFY|CLEANUP) so the script knows what to do")
endif ()
if (NOT VTKm_SOURCE_DIR)
message(FATAL_ERROR "VTKm_SOURCE_DIR not defined.")
endif ()
if (NOT VTKm_BINARY_DIR)
message(FATAL_ERROR "VTKm_BINARY_DIR not defined.")
endif ()
if (NOT VTKm_INSTALL_INCLUDE_DIR)
message(FATAL_ERROR "VTKm_INSTALL_INCLUDE_DIR not defined.")
endif ()
if (NOT DEFINED VTKm_ENABLE_RENDERING)
message(FATAL_ERROR "VTKm_ENABLE_RENDERING not defined.")
endif ()
if (NOT DEFINED VTKm_ENABLE_LOGGING)
message(FATAL_ERROR "VTKm_ENABLE_LOGGING not defined.")
endif ()
include(CMakeParseArguments)
# -----------------------------------------------------------------------------
function(verify_install_per_dir src_directory build_dir)
set(options )
set(oneValueArgs )
set(multiValueArgs EXTENSIONS FILE_EXCEPTIONS DIR_EXCEPTIONS)
cmake_parse_arguments(verify
"${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}
)
set(files_to_verify )
foreach(ext IN LISTS verify_EXTENSIONS)
file(GLOB_RECURSE listing
RELATIVE "${src_directory}"
"${src_directory}/${ext}"
)
list(APPEND files_to_verify ${listing})
endforeach()
#remove all files that are exempt
list(REMOVE_ITEM files_to_verify ${verify_FILE_EXCEPTIONS})
#remove all files inside directories that match
foreach(dir IN LISTS verify_DIR_EXCEPTIONS)
list(FILTER files_to_verify EXCLUDE REGEX "^${dir}")
endforeach()
set(to_fail FALSE) # error out after listing all missing headers
foreach(file IN LISTS files_to_verify)
if(NOT EXISTS ${build_dir}/${file})
message(STATUS "file: ${file} not installed \n\tWas expecting it to be at: ${build_dir}/${file}")
set(to_fail TRUE)
# else()
# message(STATUS "file: ${file} installed")
endif()
endforeach()
if(to_fail)
message(FATAL_ERROR "unable to find all headers in the install tree")
endif()
endfunction()
# -----------------------------------------------------------------------------
function(do_install root_dir prefix)
#Step 1. Setup up our new install prefix location
set(CMAKE_INSTALL_PREFIX ${root_dir}/${prefix})
#Step 2. Gather all the cmake_install.cmake files
file(GLOB_RECURSE install_files
LIST_DIRECTORIES False
RELATIVE "${root_dir}"
"${root_dir}/*/cmake_install.cmake")
#Step 3. Execute all the install files
if(EXISTS "${root_dir}/cmake_install.cmake")
include(${root_dir}/cmake_install.cmake)
endif()
foreach(file ${install_files})
include("${file}")
endforeach()
endfunction()
# -----------------------------------------------------------------------------
function(do_verify root_dir prefix)
#Step 1. Setup the extensions to check, and all file and directory
# extensions
set(files_extensions
*.hpp #needed for diy and taotuple
*.h
*.hxx
)
set(file_exceptions
cont/cuda/internal/testing/Testing.h
cont/ColorTablePrivate.hxx
)
# These exceptions should be based on the status of the associated
# cmake option
set(directory_exceptions )
if(NOT VTKm_ENABLE_RENDERING)
list(APPEND directory_exceptions rendering)
endif()
if(NOT VTKm_ENABLE_LOGGING)
list(APPEND directory_exceptions thirdparty/loguru)
endif()
#Step 2. Verify the installed files match what headers are listed in each
# source directory
verify_install_per_dir("${VTKm_SOURCE_DIR}/vtkm"
"${root_dir}/${prefix}/${VTKm_INSTALL_INCLUDE_DIR}/vtkm"
EXTENSIONS ${files_extensions}
FILE_EXCEPTIONS ${file_exceptions}
DIR_EXCEPTIONS ${directory_exceptions}
)
endfunction()
# -----------------------------------------------------------------------------
function(do_cleanup root_dir prefix)
#Step 1. Remove temp directory
file(REMOVE_RECURSE "${root_dir}/${prefix}")
endfunction()
set(root_dir "${VTKm_BINARY_DIR}")
set(prefix "/CMakeFiles/_tmp_install")
message(STATUS "MODE: ${MODE}")
if(MODE STREQUAL "INSTALL")
do_install(${root_dir} ${prefix})
elseif(MODE STREQUAL "VERIFY")
do_verify(${root_dir} ${prefix})
elseif(MODE STREQUAL "CLEANUP")
do_cleanup(${root_dir} ${prefix})
endif()
unset(prefix)
unset(root_dir)
......@@ -152,9 +152,6 @@ include(VTKmWrappers)
include(VTKmCompilerFlags)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
if (VTKm_ENABLE_TESTING)
enable_testing()
......@@ -171,24 +168,6 @@ if (VTKm_ENABLE_TESTING)
configure_file(${VTKm_SOURCE_DIR}/CTestCustom.cmake.in
${VTKm_BINARY_DIR}/CTestCustom.cmake @ONLY)
#-----------------------------------------------------------------------------
# Add "meta" tests that check the state of the repository
# SystemInformation prints out information about the current configuration
# CopyrightStatement checks that the copyright statement is in all source files
# SourceInBuild checks that all source files are listed in the build
add_test(NAME SystemInformation
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmSystemInformation.cmake"
)
add_test(NAME CopyrightStatement
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckCopyright.cmake"
)
# increase timeout since on some machines CopyrightStatement test takes a long time.
set_tests_properties(CopyrightStatement PROPERTIES TIMEOUT 300)
add_test(NAME SourceInBuild
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInBuild.cmake"
)
#-----------------------------------------------------------------------------
# Find the Python interpreter, which we will use during the build process
find_package(PythonInterp QUIET)
......@@ -325,3 +304,63 @@ endif()
if(VTKm_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif(VTKm_ENABLE_EXAMPLES)
#-----------------------------------------------------------------------------
if (VTKm_ENABLE_TESTING)
#-----------------------------------------------------------------------------
# Add "meta" tests that check the state of the repository
# SystemInformation prints out information about the current configuration
# CopyrightStatement checks that the copyright statement is in all source files
# SourceInBuild checks that all source files are listed in the build
# SourceInInstall checks that all source files are installed in the build
add_test(NAME SystemInformation
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" "-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmSystemInformation.cmake"
)
add_test(NAME CopyrightStatement
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckCopyright.cmake"
)
# increase timeout since on some machines CopyrightStatement test takes a long time.
set_tests_properties(CopyrightStatement PROPERTIES TIMEOUT 300)
add_test(NAME SourceInBuild
COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInBuild.cmake"
)
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
set(command_args
"-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}"
"-DVTKm_BINARY_DIR=${VTKm_BINARY_DIR}"
"-DVTKm_INSTALL_INCLUDE_DIR=${VTKm_INSTALL_INCLUDE_DIR}"
"-DVTKm_ENABLE_RENDERING=${VTKm_ENABLE_RENDERING}"
"-DVTKm_ENABLE_LOGGING=${VTKm_ENABLE_LOGGING}"
)
#By having this as separate tests using fixtures, it will allow us in
#the future to write tests that build against the installed version
add_test(NAME TestInstallSetup
COMMAND ${CMAKE_COMMAND}
"-DMODE=INSTALL"
${command_args}
-P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInInstall.cmake"
)
add_test(NAME SourceInInstall
COMMAND ${CMAKE_COMMAND}
"-DMODE=VERIFY"
${command_args}
-P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInInstall.cmake"
)
add_test(NAME TestInstallCleanup
COMMAND ${CMAKE_COMMAND}
"-DMODE=CLEANUP"
${command_args}
-P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInInstall.cmake"
)
set_tests_properties(TestInstallSetup PROPERTIES FIXTURES_SETUP vtkm_installed)
set_tests_properties(SourceInInstall PROPERTIES FIXTURES_REQUIRED vtkm_installed)
set_tests_properties(TestInstallCleanup PROPERTIES FIXTURES_CLEANUP vtkm_installed)
endif()
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