mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
cmake: Add makefile against install test
This commit is contained in:
parent
0eb9b68c1e
commit
5612d26892
@ -41,8 +41,10 @@ test:centos8_sanitizer:
|
|||||||
variables:
|
variables:
|
||||||
OMP_NUM_THREADS: 4
|
OMP_NUM_THREADS: 4
|
||||||
CTEST_MEMORYCHECK_TYPE: LeakSanitizer
|
CTEST_MEMORYCHECK_TYPE: LeakSanitizer
|
||||||
CTEST_EXCLUSIONS: smoke_test_built_against_test_install
|
CTEST_EXCLUSIONS: >-
|
||||||
|
smoke_test_cmake_built_against_test_install
|
||||||
|
smoke_test_make_built_against_test_install
|
||||||
|
smoke_test_pkgconfig_make_built_against_test_install
|
||||||
dependencies:
|
dependencies:
|
||||||
- build:centos8_sanitizer
|
- build:centos8_sanitizer
|
||||||
needs:
|
needs:
|
||||||
|
@ -90,6 +90,10 @@ test:macos_xcode14:
|
|||||||
- "ctest $CTEST_TIMEOUT -VV -S .gitlab/ci/ctest_test.cmake"
|
- "ctest $CTEST_TIMEOUT -VV -S .gitlab/ci/ctest_test.cmake"
|
||||||
extends:
|
extends:
|
||||||
- .cmake_test_artifacts
|
- .cmake_test_artifacts
|
||||||
|
variables:
|
||||||
|
CTEST_EXCLUSIONS: >-
|
||||||
|
smoke_test_make_built_against_test_install
|
||||||
|
smoke_test_pkgconfig_make_built_against_test_install
|
||||||
|
|
||||||
.macos_build_tags:
|
.macos_build_tags:
|
||||||
tags:
|
tags:
|
||||||
|
@ -122,3 +122,5 @@ test:ubuntu1604_clang5:
|
|||||||
- build:ubuntu1604_clang5
|
- build:ubuntu1604_clang5
|
||||||
needs:
|
needs:
|
||||||
- build:ubuntu1604_clang5
|
- build:ubuntu1604_clang5
|
||||||
|
variables:
|
||||||
|
CTEST_EXCLUSIONS: "make_built_against_test_install"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
##============================================================================
|
##============================================================================
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
function(vtkm_test_install )
|
function(vtkm_test_install)
|
||||||
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
|
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
|
||||||
# Find all modules that are not-compiled. Skip these directories.
|
# Find all modules that are not-compiled. Skip these directories.
|
||||||
set(dir_exceptions)
|
set(dir_exceptions)
|
||||||
@ -89,11 +89,11 @@ set(CMAKE_HIP_COMPILER \"${CMAKE_HIP_COMPILER}\" CACHE FILEPATH \"\")
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
function(vtkm_test_against_install dir)
|
function(vtkm_test_against_install_cmake dir)
|
||||||
set(name ${dir})
|
set(name ${dir})
|
||||||
set(install_prefix "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_install")
|
set(install_prefix "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_install")
|
||||||
set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/${name}/")
|
set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/${name}/")
|
||||||
set(build_dir "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_build/test_${name}/")
|
set(build_dir "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_build/test_${name}_cmake/")
|
||||||
|
|
||||||
set(args )
|
set(args )
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.13)
|
if(CMAKE_VERSION VERSION_LESS 3.13)
|
||||||
@ -134,7 +134,7 @@ function(vtkm_test_against_install dir)
|
|||||||
#this information to built the test name to make it clear to the user
|
#this information to built the test name to make it clear to the user
|
||||||
#what a 'passing' test means
|
#what a 'passing' test means
|
||||||
set(retcode 0)
|
set(retcode 0)
|
||||||
set(build_name "${name}_built_against_test_install")
|
set(build_name "${name}_cmake_built_against_test_install")
|
||||||
set(test_label "TEST_INSTALL")
|
set(test_label "TEST_INSTALL")
|
||||||
|
|
||||||
add_test(NAME ${build_name}
|
add_test(NAME ${build_name}
|
||||||
@ -162,3 +162,72 @@ function(vtkm_test_against_install dir)
|
|||||||
set_tests_properties(${build_name} PROPERTIES FIXTURES_REQUIRED vtkm_installed)
|
set_tests_properties(${build_name} PROPERTIES FIXTURES_REQUIRED vtkm_installed)
|
||||||
set_tests_properties(${build_name} PROPERTIES TIMEOUT 600)
|
set_tests_properties(${build_name} PROPERTIES TIMEOUT 600)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function(_test_install_make dir name)
|
||||||
|
set(build_name "${name}_make_built_against_test_install")
|
||||||
|
set(build_example_dir "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_build/test_${name}_make/")
|
||||||
|
set(source_example_dir "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/")
|
||||||
|
|
||||||
|
# Create build dir if it doesnt exists
|
||||||
|
add_test(NAME ${build_name}_setup
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${build_example_dir})
|
||||||
|
|
||||||
|
# Build and invoke its test
|
||||||
|
add_test(NAME ${build_name}
|
||||||
|
WORKING_DIRECTORY ${build_example_dir}
|
||||||
|
COMMAND make -f ${source_example_dir}/Makefile check V=1 VPATH=${source_example_dir})
|
||||||
|
|
||||||
|
set_tests_properties(${build_name}_setup PROPERTIES FIXTURES_SETUP "makefile_setup")
|
||||||
|
set_tests_properties(${build_name} PROPERTIES ENVIRONMENT "${ARGN}")
|
||||||
|
set_tests_properties(${build_name} PROPERTIES LABELS "TEST_INSTALL")
|
||||||
|
set_tests_properties(${build_name} PROPERTIES FIXTURES_REQUIRED "vtkm_installed;makefile_setup")
|
||||||
|
set_tests_properties(${build_name} PROPERTIES TIMEOUT 600)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
function(vtkm_test_against_install_make dir)
|
||||||
|
# Only add tests if and only if Make is found
|
||||||
|
if (NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
||||||
|
# Only these compilers accept the -std=c++XX parameter
|
||||||
|
if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang|Intel")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
find_program(make_found make)
|
||||||
|
if (NOT make_found)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(env_vars
|
||||||
|
"CXX=${CMAKE_CXX_COMPILER}"
|
||||||
|
"CXXFLAGS=$CACHE{CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(vtkm_install_dir "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_install")
|
||||||
|
if (WIN32)
|
||||||
|
string(REPLACE ";" "\\;" escaped_path "$ENV{PATH}")
|
||||||
|
list(APPEND env_vars "PATH=$<SHELL_PATH:${vtkm_install_dir}/bin>\\;${escaped_path}")
|
||||||
|
elseif(APPLE)
|
||||||
|
list(APPEND env_vars "DYLD_LIBRARY_PATH=${vtkm_install_dir}/lib:$ENV{DYLD_LIBRARY_PATH}")
|
||||||
|
else()
|
||||||
|
list(APPEND env_vars "LD_LIBRARY_PATH=${vtkm_install_dir}/lib:$ENV{LD_LIBRARY_PATH}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# The plain make test uses the given dir as its test name
|
||||||
|
_test_install_make(${dir} ${dir}
|
||||||
|
"VTKM_INSTALL_PREFIX=${vtkm_install_dir}"
|
||||||
|
"VTKM_CONFIG_MK_PATH=${vtkm_install_dir}/share/vtkm-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}/vtkm_config.mk"
|
||||||
|
${env_vars}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create pkg-config test if pkg-config is found
|
||||||
|
find_program(pkgconfig_found pkg-config)
|
||||||
|
if (pkgconfig_found)
|
||||||
|
_test_install_make(${dir} "${dir}_pkgconfig"
|
||||||
|
"PKG_CONFIG_PATH=${vtkm_install_dir}/share/vtkm-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}/"
|
||||||
|
"PKG_CONFIG_TEST_ARGS=--define-variable=prefix=${vtkm_install_dir}"
|
||||||
|
${env_vars}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
13
docs/changelog/Added_Makefile_contract_tests.md
Normal file
13
docs/changelog/Added_Makefile_contract_tests.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Added Makefile contract tests
|
||||||
|
|
||||||
|
Added Makefile contract tests to ensure that the VTK-m smoke test example
|
||||||
|
application can be built and run using a Makefile against a VTK-m install tree.
|
||||||
|
This will help users who use bare Make as their build system. Additionally,
|
||||||
|
fixed both the VTK-m pkg-config `vtkm.pc` and the `vtkm_config.mk` file to
|
||||||
|
ensure that both files are correctly generated and added CI coverage to ensure
|
||||||
|
that they are always up-to-date and correct. This improves support for users
|
||||||
|
who use bare Make as their build system, and increases confidence in the
|
||||||
|
correctness of both the VTK-m pkg-config file `vtkm.pc` and of the Makefile
|
||||||
|
`vtkm_config.mk`.
|
||||||
|
|
||||||
|
You can run these tests with: `ctest -R smoke_test`
|
@ -57,7 +57,8 @@ endif()
|
|||||||
if (VTKm_ENABLE_TESTING)
|
if (VTKm_ENABLE_TESTING)
|
||||||
# These need to be fast to build as they will
|
# These need to be fast to build as they will
|
||||||
# be built each time we run the test
|
# be built each time we run the test
|
||||||
vtkm_test_against_install(demo)
|
vtkm_test_against_install_cmake(demo)
|
||||||
vtkm_test_against_install(histogram)
|
vtkm_test_against_install_cmake(histogram)
|
||||||
vtkm_test_against_install(smoke_test)
|
vtkm_test_against_install_cmake(smoke_test)
|
||||||
|
vtkm_test_against_install_make(smoke_test)
|
||||||
endif()
|
endif()
|
||||||
|
24
examples/smoke_test/Makefile
Normal file
24
examples/smoke_test/Makefile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
ifdef PKG_CONFIG_TEST_ARGS
|
||||||
|
CPPFLAGS = $(shell pkg-config $${PKG_CONFIG_TEST_ARGS} --cflags vtkm)
|
||||||
|
LDLIBS = $(shell pkg-config $${PKG_CONFIG_TEST_ARGS} --libs vtkm)
|
||||||
|
|
||||||
|
else ifdef VTKM_CONFIG_MK_PATH
|
||||||
|
include $(VTKM_CONFIG_MK_PATH)
|
||||||
|
VTKm_DIR = $(VTKM_INSTALL_PREFIX)
|
||||||
|
CPPFLAGS = $(VTKm_INCLUDE_FLAGS)
|
||||||
|
LDLIBS = $(VTKm_LIB_FLAGS)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: smoke_test
|
||||||
|
|
||||||
|
check: smoke_test
|
||||||
|
./smoke_test
|
||||||
|
|
||||||
|
%.o : %.cxx
|
||||||
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
|
||||||
|
|
||||||
|
smoke_test.o: smoke_test.cxx
|
||||||
|
|
||||||
|
smoke_test: CC=$(CXX)
|
||||||
|
smoke_test: smoke_test.o
|
Loading…
Reference in New Issue
Block a user