CMakeLists.txt 5.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
##=============================================================================
##
##  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 2012 Sandia Corporation.
##  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
##  the U.S. Government retains certain rights in this software.
##
##=============================================================================

17 18
list(INSERT 0 CMAKE_MODULE_PATH
  "${VTK_SOURCE_DIR}/ThirdParty/vtkm/vtkvtkm/vtk-m/CMake")
19

20 21
set(sources)
set(headers)
22 23 24 25 26
set(private_headers
  vtkmlib/DataSetConverters.h
  vtkmlib/Portals.hxx
  vtkmlib/PortalTraits.h
  vtkmlib/Storage.hxx)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

set(impl_classes
  vtkmAverageToCells
  vtkmAverageToPoints
  vtkmCellSetExplicit
  vtkmCellSetSingleType
  vtkmCleanGrid
  vtkmClip
  vtkmConnectivityExec
  vtkmContour
  vtkmCoordinateSystemTransform
  vtkmExternalFaces
  vtkmExtractVOI
  vtkmGradient
  vtkmHistogram
  vtkmLevelOfDetail
  vtkmNDHistogram
  vtkmPointElevation
  vtkmPointTransform
  vtkmPolyDataNormals
  vtkmProbe
  vtkmThreshold
  vtkmTriangleMeshPointNormals
  vtkmWarpScalar
51 52
  vtkmWarpVector
  )
53 54

set(private_impl_classes
55 56 57 58 59 60
  vtkmlib/ArrayConverters
  vtkmlib/CellSetConverters
  vtkmlib/ImageDataConverter
  vtkmlib/PolyDataConverter
  vtkmlib/Storage
  vtkmlib/UnstructuredGridConverter
61
  vtkmlib/DataSetConverters
62
  vtkmlib/ImplicitFunctionConverter
63 64
  vtkmlib/Portals)

65 66 67 68 69
foreach (class IN LISTS impl_classes)
  list(APPEND sources "${class}.cxx")
  list(APPEND headers "${class}.h")
endforeach ()

70
foreach (class IN LISTS private_impl_classes)
71 72
  list(APPEND sources "${class}.cxx")
  list(APPEND private_headers "${class}.h")
73 74
endforeach ()

75 76 77 78 79 80
if (TARGET vtkm::cuda)
  set_source_files_properties(${sources} PROPERTIES LANGUAGE "CUDA")
  #The vtkmlib/CellSetConverters need to be built always as CXX
  #as the worklets used by them require access to vtk classes
  set_source_files_properties(vtkmlib/CellSetConverters.cxx PROPERTIES LANGUAGE "CXX")
endif ()
81

82 83 84 85 86 87
set(VTKM_FILTER_INCLUDE_AOS ${VTK_DISPATCH_AOS_ARRAYS})
set(VTKM_FILTER_INCLUDE_SOA ${VTK_DISPATCH_SOA_ARRAYS})
configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/vtkmConfig.h.in"
  "${CMAKE_CURRENT_BINARY_DIR}/vtkmConfig.h"
  @ONLY)
88

89 90
list(APPEND headers
  "${CMAKE_CURRENT_BINARY_DIR}/vtkmConfig.h")
91 92 93 94 95 96 97 98 99 100

# The VTK-m project uses large amounts of memory to compile as it does lots
# of template expansion. To reduce the amount of tension on the machine when
# using generators such as ninja we restrict the number of VTK-m enabled
# compilation units to be built at the same time.
# The logic we use is that no more than half the system memory should be used
# on VTK-m compilation units, where we expect each compilation unit to use
# 2GB of memory.
cmake_host_system_information(RESULT vtkm_mem_ QUERY TOTAL_PHYSICAL_MEMORY)
math(EXPR vtkm_pool_size "(${vtkm_mem_}/2)/2048")
101
if (vtkm_pool_size EQUAL 0)
102
  set(vtkm_pool_size 1)
103 104 105 106
endif ()
set_property(GLOBAL APPEND
  PROPERTY
    JOB_POOLS vtkm_pool=${vtkm_pool_size})
107

108
if (TARGET vtkm::cuda)
109
  enable_language(CUDA)
110

111 112
  # XXX(cmake#7519): Workaround for CMake which causes the c++11 flag set for
  # VTK-m using target_compile_features to not work.
113 114 115
  if (CMAKE_VERSION VERSION_LESS 3.11)
    set(CMAKE_CUDA_STANDARD 11)
    set(CMAKE_CUDA_STANDARD_REQUIRED True)
116 117
  endif()

118 119 120 121
  get_property(arch_flags
    TARGET    vtkm::cuda
    PROPERTY  VTKm_CUDA_Architecture_Flags)
  string(APPEND CMAKE_CUDA_FLAGS " ${arch_flags}")
122

123 124
  # Temporarily suppress "has address taken but no possible call to it" warnings,
  # until we figure out its implications.
luz.paz's avatar
luz.paz committed
125
  # We are disabling all warnings as nvlink has no known way to suppress
126
  # individual warning types.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")
endif ()

vtk_module_add_module(VTK::AcceleratorsVTKm
  SOURCES ${sources}
  HEADERS ${headers}
  PRIVATE_HEADERS ${private_headers})
vtk_module_set_property(VTK::AcceleratorsVTKm
  PROPERTY  JOB_POOL_COMPILE
  VALUE     vtkm_pool)

if (TARGET vtkm::cuda)
  vtk_module_set_property(VTK::AcceleratorsVTKm
    PROPERTY  CUDA_SEPARABLE_COMPILATION
    VALUE     ON)
  vtk_module_compile_options(VTK::AcceleratorsVTKm
143
    PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcudafe --diag_suppress=extra_semicolon>)
144
endif ()
145

146
if (MSVC)
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
  set(msvc_warning_flags
    # Generates numerous false positives with template code about unreachable
    # code
    /wd4702
    # Generates numerous warning that implicit assignment operators can't be
    # constructed. This is understood and we don't care.
    /wd4512
    # Generates numerous warning that implicit constructors can't be
    # constructed. This is understood and we don't care.
    /wd4510)
  set(vtkm_msvc_flags)
  foreach (msvc_warning_flag IN LISTS msvc_warning_flags)
    if (TARGET vtkm::cuda)
      list(APPEND vtkm_msvc_flags
        $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=${msvc_warning_flag},${msvc_warning_flag}>)
    else ()
      list(APPEND vtkm_msvc_flags
        ${msvc_warning_flag})
    endif ()
  endforeach ()
167 168
  vtk_module_compile_options(VTK::AcceleratorsVTKm
    PRIVATE
169
      ${msvc_warning_flags})
170
endif ()