From 4a0961500086cfff8e48f2ef0dd489474c72cc7e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 4 Jan 2018 13:15:34 -0500 Subject: [PATCH] Correct issues when building on windows --- CMake/VTKmCompilerFlags.cmake | 16 +++++++++------- CMake/VTKmDeviceAdapters.cmake | 8 +++++--- CMake/VTKmWrappers.cmake | 5 +++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/CMake/VTKmCompilerFlags.cmake b/CMake/VTKmCompilerFlags.cmake index 9090a14b6..4135cf3d2 100644 --- a/CMake/VTKmCompilerFlags.cmake +++ b/CMake/VTKmCompilerFlags.cmake @@ -39,7 +39,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(VTKM_COMPILER_IS_MSV 1) + set(VTKM_COMPILER_IS_MSVC 1) endif() @@ -91,14 +91,16 @@ target_link_libraries(vtkm_developer_flags INTERFACE vtkm_compiler_flags) if(VTKM_COMPILER_IS_MSVC) target_compile_definitions(vtkm_developer_flags INTERFACE "_SCL_SECURE_NO_WARNINGS" - "_CRT_SECURE_NO_WARNINGS") + "_CRT_SECURE_NO_WARNINGS") - target_compile_options(vtkm_developer_flags INTERFACE -wd4702 -wd4505 -wd4512 -wd4510) + #CMake COMPILE_LANGUAGE doesn't work with MSVC, ans since we want these flags + #only for C++ compilation we have to resort to setting CMAKE_CXX_FLAGS :( + # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4702 -wd4505") - # In VS2013 the C4127 warning has a bug in the implementation and - # generates false positive warnings for lots of template code if(MSVC_VERSION LESS 1900) - target_compile_options(vtkm_developer_flags INTERFACE -wd4127 ) + # In VS2013 the C4127 warning has a bug in the implementation and + # generates false positive warnings for lots of template code + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd4127") endif() elseif(VTKM_COMPILER_IS_ICC) @@ -108,7 +110,7 @@ elseif(VTKM_COMPILER_IS_ICC) # Likewise to suppress failures about being unable to apply vectorization # to loops, the #pragma warning(disable seems to not work so we add a # a compile define. - target_compile_definitions(vtkm_developer_flags INTERFACE -wd1478 -wd13379) + target_compile_definitions(vtkm_developer_flags INTERFACE $<$:-wd1478 -wd13379>) elseif(VTKM_COMPILER_IS_GNU OR VTKM_COMPILER_IS_CLANG) set(flags -Wall -Wno-long-long -Wcast-align -Wconversion -Wchar-subscripts -Wextra -Wpointer-arith -Wformat -Wformat-security -Wshadow -Wunused-parameter -fno-common) diff --git a/CMake/VTKmDeviceAdapters.cmake b/CMake/VTKmDeviceAdapters.cmake index 2891fba87..e9059d078 100644 --- a/CMake/VTKmDeviceAdapters.cmake +++ b/CMake/VTKmDeviceAdapters.cmake @@ -54,9 +54,11 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda) add_library(vtkm::cuda UNKNOWN IMPORTED) - set_target_properties(vtkm::cuda PROPERTIES - INTERFACE_COMPILE_OPTIONS $<$:--expt-relaxed-constexpr> - ) + if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") + set_target_properties(vtkm::cuda PROPERTIES + INTERFACE_COMPILE_OPTIONS $<$:--expt-relaxed-constexpr> + ) + endif() # We can't have this location/lib empty, so we provide a location that is # valid and will have no effect on compilation diff --git a/CMake/VTKmWrappers.cmake b/CMake/VTKmWrappers.cmake index 9b6907d53..fdab1dfb0 100644 --- a/CMake/VTKmWrappers.cmake +++ b/CMake/VTKmWrappers.cmake @@ -86,6 +86,11 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda) if(NOT TARGET TestBuild_${name}) add_library(TestBuild_${name} STATIC ${srcs} ${hfiles}) target_link_libraries(TestBuild_${name} PRIVATE vtkm_compiler_flags) + + if(TARGET vtkm::tbb) + #make sure that we have the tbb include paths when tbb is enabled. + target_link_libraries(TestBuild_${name} PRIVATE vtkm::tbb) + endif() else() target_sources(TestBuild_${name} PRIVATE ${srcs}) endif()