From c5d630a77eacf2cc79e07b9a51c434a00fe8c50c Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 16 Jan 2018 14:54:31 -0500 Subject: [PATCH] cmake: add a vtkm_option macro Projects might want to force these without giving users the indication that their choices actually matter. --- CMake/VTKmCompilerExtras.cmake | 2 +- CMake/VTKmMacros.cmake | 9 +++++++++ CMakeLists.txt | 28 ++++++++++++++-------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CMake/VTKmCompilerExtras.cmake b/CMake/VTKmCompilerExtras.cmake index defc8fb82..b6c621c32 100644 --- a/CMake/VTKmCompilerExtras.cmake +++ b/CMake/VTKmCompilerExtras.cmake @@ -64,7 +64,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) endif() # Set up the debug CXX_FLAGS for extra warnings - option(VTKm_EXTRA_COMPILER_WARNINGS "Add compiler flags to do stricter checking when building debug." ON) + vtkm_option(VTKm_EXTRA_COMPILER_WARNINGS "Add compiler flags to do stricter checking when building debug." ON) # We used to add the compiler flags globally, but this caused problems with # the CUDA compiler (and its lack of support for GCC pragmas). Instead, # the vtkm_declare_headers and vtkm_unit_tests CMake functions add these flags diff --git a/CMake/VTKmMacros.cmake b/CMake/VTKmMacros.cmake index 66931930c..87b983452 100644 --- a/CMake/VTKmMacros.cmake +++ b/CMake/VTKmMacros.cmake @@ -896,3 +896,12 @@ function(_vtkm_parse_test_options varname options) endforeach() set(${varname} ${names} PARENT_SCOPE) endfunction() + +# ----------------------------------------------------------------------------- +# vtkm_option(variable doc [initial]) +# Provides an option if it is not already defined. +macro (vtkm_option variable) + if (NOT DEFINED "${variable}") + option("${variable}" ${ARGN}) + endif () +endmacro () diff --git a/CMakeLists.txt b/CMakeLists.txt index 43b2b7690..0eca90835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ set(CMAKE_CXX_EXTENSIONS False) # We prefer to only export symbols of a small set of user facing classes, # rather than exporting all symbols. In practice we will try to not export # symbols for any third party library. -option(VTKm_USE_DEFAULT_SYMBOL_VISIBILITY "Don't explicitly hide symbols from libraries." OFF) +vtkm_option(VTKm_USE_DEFAULT_SYMBOL_VISIBILITY "Don't explicitly hide symbols from libraries." OFF) mark_as_advanced(VTKm_USE_DEFAULT_SYMBOL_VISIBILITY) if(NOT VTKm_USE_DEFAULT_SYMBOL_VISIBILITY) set(CMAKE_CXX_VISIBILITY_PRESET hidden) @@ -113,27 +113,27 @@ include(CMake/VTKmCompilerExtras.cmake) #----------------------------------------------------------------------------- # Configurable Options -option(VTKm_ENABLE_CUDA "Enable Cuda support" OFF) -option(VTKm_ENABLE_TBB "Enable TBB support" OFF) -option(VTKm_ENABLE_RENDERING "Enable rendering library" ON) -option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON) -option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF) -option(VTKm_ENABLE_OSMESA "Enable creating the OSMesa canvas" OFF) -option(VTKm_ENABLE_MPI "Enable MPI support" OFF) +vtkm_option(VTKm_ENABLE_CUDA "Enable Cuda support" OFF) +vtkm_option(VTKm_ENABLE_TBB "Enable TBB support" OFF) +vtkm_option(VTKm_ENABLE_RENDERING "Enable rendering library" ON) +vtkm_option(VTKm_ENABLE_TESTING "Enable VTKm Testing" ON) +vtkm_option(VTKm_ENABLE_BENCHMARKS "Enable VTKm Benchmarking" OFF) +vtkm_option(VTKm_ENABLE_OSMESA "Enable creating the OSMesa canvas" OFF) +vtkm_option(VTKm_ENABLE_MPI "Enable MPI support" OFF) -option(VTKm_ENABLE_DOCUMENTATION "Build Doxygen documentation" OFF) -option(VTKm_ENABLE_EXAMPLES "Build examples" OFF) +vtkm_option(VTKm_ENABLE_DOCUMENTATION "Build Doxygen documentation" OFF) +vtkm_option(VTKm_ENABLE_EXAMPLES "Build examples" OFF) -option(VTKm_USE_DOUBLE_PRECISION +vtkm_option(VTKm_USE_DOUBLE_PRECISION "Use double precision for floating point calculations" OFF ) -option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON) +vtkm_option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON) -option(VTKm_NO_ASSERT "Disable assertions in debugging builds." OFF) +vtkm_option(VTKm_NO_ASSERT "Disable assertions in debugging builds." OFF) mark_as_advanced(VTKm_NO_ASSERT) -option(BUILD_SHARED_LIBS "Build VTK-m with shared libraries" ON) +vtkm_option(BUILD_SHARED_LIBS "Build VTK-m with shared libraries" ON) set(VTKm_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) if (VTKm_ENABLE_TESTING)