Refactor CMake files
1. Change set_property(...) to target_* commands 2. Remove explcit adding of CMAKE_CXX_FLAGS_WARN_EXTRA as compile option 3. Add /bigobj option to VTKm_COMPILE_OPTIONS under MSVC
This commit is contained in:
parent
1379502179
commit
011605d489
@ -34,6 +34,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
set(CMAKE_COMPILER_IS_ICCXX 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
set(CMAKE_COMPILER_IS_MSVCXX 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
@ -87,5 +91,7 @@ elseif(CMAKE_COMPILER_IS_ICCXX)
|
||||
# to loops, the #pragma warning(disable seems to not work so we add a
|
||||
# a compile define.
|
||||
add_definitions("-wd13379")
|
||||
elseif (CMAKE_COMPILER_IS_MSVCXX)
|
||||
#enable large object support so we can have 2^32 addressable sections
|
||||
list(APPEND VTKm_COMPILE_OPTIONS "/bigobj")
|
||||
endif()
|
||||
|
||||
|
@ -73,17 +73,9 @@ endfunction(vtkm_setup_nvcc_flags)
|
||||
function(vtkm_setup_msvc_properties target )
|
||||
#disable MSVC CRT and SCL warnings as they recommend using non standard
|
||||
#c++ extensions
|
||||
set_property(TARGET ${target}
|
||||
APPEND PROPERTY COMPILE_DEFINITIONS
|
||||
"_SCL_SECURE_NO_WARNINGS"
|
||||
"_CRT_SECURE_NO_WARNINGS"
|
||||
)
|
||||
target_compile_definitions(${target} PRIVATE "_SCL_SECURE_NO_WARNINGS"
|
||||
"_CRT_SECURE_NO_WARNINGS")
|
||||
|
||||
#enable large object support so we can have 2^32 addressable sections
|
||||
set_property(TARGET ${target}
|
||||
APPEND PROPERTY COMPILE_FLAGS
|
||||
"/bigobj"
|
||||
)
|
||||
endfunction(vtkm_setup_msvc_properties)
|
||||
|
||||
# Builds a source file and an executable that does nothing other than
|
||||
@ -123,12 +115,6 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda)
|
||||
cuda_add_library(TestBuild_${name} ${cxxfiles} ${hfiles})
|
||||
elseif (${cxxfiles_len} GREATER 0)
|
||||
add_library(TestBuild_${name} ${cxxfiles} ${hfiles})
|
||||
if(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
set_property(TARGET ${test_prog}
|
||||
APPEND PROPERTY COMPILE_FLAGS
|
||||
${CMAKE_CXX_FLAGS_WARN_EXTRA}
|
||||
)
|
||||
endif(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
target_include_directories(TestBuild_${name} PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
endif ()
|
||||
target_link_libraries(TestBuild_${name} ${VTKm_LIBRARIES})
|
||||
@ -287,8 +273,7 @@ function(vtkm_unit_tests)
|
||||
|
||||
#do it as a property value so we don't pollute the include_directories
|
||||
#for any other targets
|
||||
set_property(TARGET ${test_prog} APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${VTKm_INCLUDE_DIRS} )
|
||||
target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(${test_prog} ${VTKm_LIBRARIES})
|
||||
|
||||
@ -298,13 +283,6 @@ function(vtkm_unit_tests)
|
||||
vtkm_setup_msvc_properties(${test_prog})
|
||||
endif()
|
||||
|
||||
if(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
set_property(TARGET ${test_prog}
|
||||
APPEND PROPERTY COMPILE_FLAGS
|
||||
${CMAKE_CXX_FLAGS_WARN_EXTRA}
|
||||
)
|
||||
endif(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
|
||||
foreach (test ${VTKm_UT_SOURCES})
|
||||
get_filename_component(tname ${test} NAME_WE)
|
||||
add_test(NAME ${tname}
|
||||
@ -423,9 +401,7 @@ function(vtkm_worklet_unit_tests device_adapter)
|
||||
else()
|
||||
add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs})
|
||||
endif()
|
||||
set_property(TARGET ${test_prog} APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${VTKm_INCLUDE_DIRS}
|
||||
)
|
||||
target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(${test_prog} ${VTKm_LIBRARIES})
|
||||
|
||||
#add the specific compile options for this executable
|
||||
@ -447,18 +423,8 @@ function(vtkm_worklet_unit_tests device_adapter)
|
||||
vtkm_setup_msvc_properties(${test_prog})
|
||||
endif()
|
||||
|
||||
#increase warning level if needed, we are going to skip cuda here
|
||||
#to remove all the false positive unused function warnings that cuda
|
||||
#generates
|
||||
if(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
set_property(TARGET ${test_prog}
|
||||
APPEND PROPERTY COMPILE_FLAGS ${CMAKE_CXX_FLAGS_WARN_EXTRA} )
|
||||
endif()
|
||||
|
||||
#set the device adapter on the executable
|
||||
set_property(TARGET ${test_prog}
|
||||
APPEND
|
||||
PROPERTY COMPILE_DEFINITIONS "VTKM_DEVICE_ADAPTER=${device_adapter}" )
|
||||
target_compile_definitions(${test_prog} PRIVATE "VTKM_DEVICE_ADAPTER=${device_adapter}")
|
||||
endif()
|
||||
endfunction(vtkm_worklet_unit_tests)
|
||||
|
||||
@ -563,8 +529,7 @@ function(vtkm_benchmarks device_adapter)
|
||||
set_source_files_properties(${benchmark_headers}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
set_property(TARGET ${benchmark_prog} APPEND PROPERTY
|
||||
INCLUDE_DIRECTORIES ${VTKm_INCLUDE_DIRS} )
|
||||
target_include_directories(${benchmark_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(${benchmark_prog} ${VTKm_LIBRARIES})
|
||||
|
||||
if(MSVC)
|
||||
@ -574,19 +539,8 @@ function(vtkm_benchmarks device_adapter)
|
||||
#add the specific compile options for this executable
|
||||
target_compile_options(${benchmark_prog} PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
|
||||
#increase warning level if needed, we are going to skip cuda here
|
||||
#to remove all the false positive unused function warnings that cuda
|
||||
#generates
|
||||
if(VTKm_EXTRA_COMPILER_WARNINGS)
|
||||
set_property(TARGET ${benchmark_prog}
|
||||
APPEND PROPERTY COMPILE_FLAGS ${CMAKE_CXX_FLAGS_WARN_EXTRA} )
|
||||
endif()
|
||||
|
||||
#set the device adapter on the executable
|
||||
set_property(TARGET ${benchmark_prog}
|
||||
APPEND
|
||||
PROPERTY COMPILE_DEFINITIONS "VTKM_DEVICE_ADAPTER=${device_adapter}" )
|
||||
|
||||
target_compile_definitions(${benchmark_prog} PRIVATE "VTKM_DEVICE_ADAPTER=${device_adapter}")
|
||||
|
||||
endforeach()
|
||||
|
||||
|
@ -29,11 +29,8 @@ add_executable(Clipping_SERIAL Clipping.cxx)
|
||||
target_include_directories(Clipping_SERIAL PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(Clipping_SERIAL ${VTKm_LIBRARIES})
|
||||
target_compile_options(Clipping_SERIAL PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
|
||||
set_property(
|
||||
TARGET Clipping_SERIAL
|
||||
APPEND
|
||||
PROPERTY COMPILE_DEFINITIONS "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL")
|
||||
target_compile_definitions(Clipping_SERIAL PRIVATE
|
||||
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_SERIAL")
|
||||
|
||||
if(VTKm_CUDA_FOUND)
|
||||
set (cudaSource "${CMAKE_CURRENT_BINARY_DIR}/Clipping.cu")
|
||||
@ -62,8 +59,6 @@ if(VTKm_TBB_FOUND)
|
||||
target_include_directories(Clipping_TBB PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(Clipping_TBB ${VTKm_LIBRARIES})
|
||||
target_compile_options(Clipping_TBB PRIVATE PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
set_property(
|
||||
TARGET Clipping_TBB
|
||||
APPEND
|
||||
PROPERTY COMPILE_DEFINITIONS "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
|
||||
target_compile_definitions(Clipping_TBB PRIVATE
|
||||
"VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_TBB")
|
||||
endif()
|
||||
|
@ -24,3 +24,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(DynamicDispatcherExample main.cxx)
|
||||
target_include_directories(DynamicDispatcherExample PRIVATE ${VTKm_INCLUDE_DIRS})
|
||||
target_link_libraries(DynamicDispatcherExample ${VTKm_LIBRARIES})
|
||||
target_compile_options(DynamicDispatcherExample PRIVATE ${VTKm_COMPILE_OPTIONS})
|
||||
|
Loading…
Reference in New Issue
Block a user