diff --git a/CMake/VTKmCheckSourceInBuild.cmake b/CMake/VTKmCheckSourceInBuild.cmake new file mode 100644 index 000000000..797a8714a --- /dev/null +++ b/CMake/VTKmCheckSourceInBuild.cmake @@ -0,0 +1,95 @@ +##============================================================================ +## 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 Sandia Corporation. +## Copyright 2016 UT-Battelle, LLC. +## Copyright 2016 Los Alamos National Security. +## +## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +## 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 is explicitly +## listed in the CMakeLists.txt files. This helps ensure that all files that we +## are using are appropriately listed in IDEs and installed as necessary. It +## also helps identify dead files that should no longer be in the repository. +## To run this script, execute CMake as follows: +## +## cmake -DVTKm_SOURCE_DIR= -P /CMake/VTKMCheckSourceInBuild.cmake +## + +cmake_minimum_required(VERSION 2.8) + +set(FILES_TO_CHECK + *.h + *.h.in + *.cxx + *.cu + ) + +set(EXCEPTIONS + ) + +if (NOT VTKm_SOURCE_DIR) + message(SEND_ERROR "VTKm_SOURCE_DIR not defined.") +endif (NOT VTKm_SOURCE_DIR) + +function(check_directory directory) + message("Checking directory ${directory}...") + + if(EXISTS "${directory}/CMakeLists.txt") + file(READ "${directory}/CMakeLists.txt" CMakeListsContents) + endif() + + foreach (glob_expression ${FILES_TO_CHECK}) + file(GLOB file_list + RELATIVE "${directory}" + "${directory}/${glob_expression}" + ) + + foreach (file ${file_list}) + set(skip) + foreach(exception ${EXCEPTIONS}) + if(file MATCHES "^${exception}(/.*)?$") + # This file is an exception + set(skip TRUE) + endif() + endforeach(exception) + + if(NOT skip) + message("Checking ${file}") + # Remove .in suffix. These are generally configured files that generate + # new files that are actually used in the build. + string(REGEX REPLACE ".in$" "" file_check "${file}") + string(FIND "${CMakeListsContents}" "${file_check}" position) + if(${position} LESS 0) + message(SEND_ERROR + "**************************************************************** +${file_check} is not found in ${directory}/CMakeLists.txt +This indicates that the file is not part of the build system. Thus it might be missing build targets. All such files should be explicitly handled by CMake.") + endif() + endif() + endforeach (file) + endforeach(glob_expression) + + file(GLOB file_list + LIST_DIRECTORIES true + "${directory}/*") + foreach(file ${file_list}) + if(IS_DIRECTORY "${file}") + check_directory("${file}") + endif() + endforeach(file) +endfunction(check_directory) + +check_directory("${VTKm_SOURCE_DIR}/vtkm") +check_directory("${VTKm_SOURCE_DIR}/examples") diff --git a/CMakeLists.txt b/CMakeLists.txt index e47577a3c..b682596bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,14 +149,19 @@ include_directories( ) #----------------------------------------------------------------------------- -# Add test to check for copyright statement on all source files. -# Also add test to output system information. +# 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 if (VTKm_ENABLE_TESTING) + 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" ) - 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 SourceInBuild + COMMAND ${CMAKE_COMMAND} "-DVTKm_SOURCE_DIR=${VTKm_SOURCE_DIR}" -P "${VTKm_SOURCE_DIR}/CMake/VTKmCheckSourceInBuild.cmake" ) endif (VTKm_ENABLE_TESTING) @@ -224,33 +229,6 @@ if(VTKm_BUILD_EXAMPLES) add_subdirectory(examples) endif(VTKm_BUILD_EXAMPLES) -#----------------------------------------------------------------------------- -# Build the configure file. -# need to set numerous VTKm cmake properties to the naming convention -# that we exepect for our C++ defines. - -set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION}) -set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) - -set(VTKM_ENABLE_CUDA ${VTKm_ENABLE_CUDA}) -set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB}) - -set(VTKM_ENABLE_OPENGL_INTEROP ${VTKm_ENABLE_OPENGL_INTEROP}) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkm/internal/Configure.h.in - ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h - @ONLY) -vtkm_install_headers( - vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h) - -unset(VTKM_ENABLE_OPENGL_INTEROP) - -unset(VTKM_ENABLE_TBB) -unset(VTKM_ENABLE_CUDA) - -unset(VTKM_USE_64BIT_IDS) -unset(VTKM_USE_DOUBLE_PRECISION) - #----------------------------------------------------------------------------- # Configuration for build directory. set(VTKm_INCLUDE_DIRS_CONFIG "${VTKm_SOURCE_DIR};${VTKm_BINARY_DIR}") diff --git a/vtkm/internal/CMakeLists.txt b/vtkm/internal/CMakeLists.txt index 566f2260a..f2e43d8dd 100644 --- a/vtkm/internal/CMakeLists.txt +++ b/vtkm/internal/CMakeLists.txt @@ -18,8 +18,37 @@ ## this software. ##============================================================================ +#----------------------------------------------------------------------------- +# Build the configure file. +# need to set numerous VTKm cmake properties to the naming convention +# that we exepect for our C++ defines. + +set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION}) +set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) + +set(VTKM_ENABLE_CUDA ${VTKm_ENABLE_CUDA}) +set(VTKM_ENABLE_TBB ${VTKm_ENABLE_TBB}) + +set(VTKM_ENABLE_OPENGL_INTEROP ${VTKm_ENABLE_OPENGL_INTEROP}) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Configure.h.in + ${CMAKE_CURRENT_BINARY_DIR}/Configure.h + @ONLY) +vtkm_install_headers( + vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/Configure.h) + +unset(VTKM_ENABLE_OPENGL_INTEROP) + +unset(VTKM_ENABLE_TBB) +unset(VTKM_ENABLE_CUDA) + +unset(VTKM_USE_64BIT_IDS) +unset(VTKM_USE_DOUBLE_PRECISION) + + set(headers ArrayPortalUniformPointCoordinates.h + Assume.h ConfigureFor32.h ConfigureFor64.h ConnectivityStructuredInternals.h