From 1b0ea8af8f290338a9ea5c039ac34f6512fdef4a Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Wed, 6 Sep 2023 18:37:10 -0400 Subject: [PATCH 1/3] cmake: update vtkm.pc and vtkm_config.mk file (cherry picked from commit 0eb9b68c1e680ee0095341d97c16782b1d65cb08) --- config/vtkm.pc.in | 2 +- config/vtkm_config.mk.in | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/vtkm.pc.in b/config/vtkm.pc.in index 9bc8b41b0..adf9e2bff 100644 --- a/config/vtkm.pc.in +++ b/config/vtkm.pc.in @@ -17,5 +17,5 @@ libdir=${exec_prefix}/lib Name: VTKm Description: The VTKm library Version: @VTKm_VERSION@ -Cflags: -I${includedir}/vtkm-@CMAKE_INSTALL_PREFIX@ +Cflags: -I${includedir} -I${includedir}/vtkm/thirdparty/diy/vtkmdiy/include/ -I${includedir}/vtkm/thirdparty/lcl/vtkmlcl/ Libs: -L${libdir}@lib_args@ diff --git a/config/vtkm_config.mk.in b/config/vtkm_config.mk.in index d67bb3929..8627acf37 100644 --- a/config/vtkm_config.mk.in +++ b/config/vtkm_config.mk.in @@ -24,5 +24,7 @@ VTKm_ENABLE_OSMESA_CONTEXT = @VTKm_ENABLE_OSMESA_CONTEXT@ VTKm_ENABLE_EGL_CONTEXT = @VTKm_ENABLE_EGL_CONTEXT@ VTKm_ENABLE_MPI = @VTKm_ENABLE_MPI@ -VTKm_INCLUDE_FLAGS = -I $(VTKm_DIR)/include/vtkm-@VTKm_VERSION_MAJOR@.@VTKm_VERSION_MINOR@ +VTKm_INCLUDE_DIR = $(VTKm_DIR)/include/vtkm-@VTKm_VERSION_MAJOR@.@VTKm_VERSION_MINOR@ +VTKm_INCLUDE_FLAGS = -I$(VTKm_INCLUDE_DIR) -I$(VTKm_INCLUDE_DIR)/vtkm/thirdparty/diy/vtkmdiy/include/ -I$(VTKm_INCLUDE_DIR)/vtkm/thirdparty/lcl/vtkmlcl/ + VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib@lib_args@ From 2d47ba22b7eafa290c99d608264f9aa48f681529 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Wed, 6 Sep 2023 18:36:26 -0400 Subject: [PATCH 2/3] cmake: Add makefile against install test (cherry picked from commit 5612d26892f172d7e0285fb46f2bd4da2ae76dda) --- .gitlab/ci/centos8.yml | 6 +- .gitlab/ci/macos.yml | 4 + .gitlab/ci/ubuntu1604.yml | 2 + CMake/testing/VTKmTestInstall.cmake | 77 ++++++++++++++++++- .../Added_Makefile_contract_tests.md | 13 ++++ examples/CMakeLists.txt | 7 +- examples/smoke_test/Makefile | 24 ++++++ 7 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 docs/changelog/Added_Makefile_contract_tests.md create mode 100644 examples/smoke_test/Makefile diff --git a/.gitlab/ci/centos8.yml b/.gitlab/ci/centos8.yml index 535b028af..ff731ad05 100644 --- a/.gitlab/ci/centos8.yml +++ b/.gitlab/ci/centos8.yml @@ -41,8 +41,10 @@ test:centos8_sanitizer: variables: OMP_NUM_THREADS: 4 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: - build:centos8_sanitizer needs: diff --git a/.gitlab/ci/macos.yml b/.gitlab/ci/macos.yml index cb0337478..ca84569de 100644 --- a/.gitlab/ci/macos.yml +++ b/.gitlab/ci/macos.yml @@ -90,6 +90,10 @@ test:macos_xcode14: - "ctest $CTEST_TIMEOUT -VV -S .gitlab/ci/ctest_test.cmake" extends: - .cmake_test_artifacts + variables: + CTEST_EXCLUSIONS: >- + smoke_test_make_built_against_test_install + smoke_test_pkgconfig_make_built_against_test_install .macos_build_tags: tags: diff --git a/.gitlab/ci/ubuntu1604.yml b/.gitlab/ci/ubuntu1604.yml index 77e3744dc..d5a849d65 100644 --- a/.gitlab/ci/ubuntu1604.yml +++ b/.gitlab/ci/ubuntu1604.yml @@ -122,3 +122,5 @@ test:ubuntu1604_clang5: - build:ubuntu1604_clang5 needs: - build:ubuntu1604_clang5 + variables: + CTEST_EXCLUSIONS: "make_built_against_test_install" diff --git a/CMake/testing/VTKmTestInstall.cmake b/CMake/testing/VTKmTestInstall.cmake index 53ab591d9..f8bf35317 100644 --- a/CMake/testing/VTKmTestInstall.cmake +++ b/CMake/testing/VTKmTestInstall.cmake @@ -9,7 +9,7 @@ ##============================================================================ # ----------------------------------------------------------------------------- -function(vtkm_test_install ) +function(vtkm_test_install) if(NOT VTKm_INSTALL_ONLY_LIBRARIES) # Find all modules that are not-compiled. Skip these directories. set(dir_exceptions) @@ -89,11 +89,11 @@ set(CMAKE_HIP_COMPILER \"${CMAKE_HIP_COMPILER}\" CACHE FILEPATH \"\") endfunction() # ----------------------------------------------------------------------------- -function(vtkm_test_against_install dir) +function(vtkm_test_against_install_cmake dir) set(name ${dir}) set(install_prefix "${VTKm_BINARY_DIR}/CMakeFiles/_tmp_install") 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 ) 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 #what a 'passing' test means 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") 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 TIMEOUT 600) 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=$\\;${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() diff --git a/docs/changelog/Added_Makefile_contract_tests.md b/docs/changelog/Added_Makefile_contract_tests.md new file mode 100644 index 000000000..ec16b31c1 --- /dev/null +++ b/docs/changelog/Added_Makefile_contract_tests.md @@ -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` diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e291ee6a6..54e4e376a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -57,7 +57,8 @@ endif() if (VTKm_ENABLE_TESTING) # These need to be fast to build as they will # be built each time we run the test - vtkm_test_against_install(demo) - vtkm_test_against_install(histogram) - vtkm_test_against_install(smoke_test) + vtkm_test_against_install_cmake(demo) + vtkm_test_against_install_cmake(histogram) + vtkm_test_against_install_cmake(smoke_test) + vtkm_test_against_install_make(smoke_test) endif() diff --git a/examples/smoke_test/Makefile b/examples/smoke_test/Makefile new file mode 100644 index 000000000..100534df9 --- /dev/null +++ b/examples/smoke_test/Makefile @@ -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 From 2aa04d7c23e865d1faa1cebf43e9c79b077c2698 Mon Sep 17 00:00:00 2001 From: Vicente Adolfo Bolea Sanchez Date: Thu, 7 Sep 2023 14:16:45 -0400 Subject: [PATCH 3/3] ci: fix ctest_memcheck args (cherry picked from commit 1cd6be01c2586a2d567937c03a25ec23d1cda3c0) --- .gitlab/ci/ctest_memcheck.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitlab/ci/ctest_memcheck.cmake b/.gitlab/ci/ctest_memcheck.cmake index f30f4346e..8af8d8c23 100644 --- a/.gitlab/ci/ctest_memcheck.cmake +++ b/.gitlab/ci/ctest_memcheck.cmake @@ -37,20 +37,32 @@ set(test_exclusions $ENV{CTEST_EXCLUSIONS} ) +string(REPLACE " " ";" test_exclusions "${test_exclusions}") string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) - set(test_exclusions "(${test_exclusions})") + set(test_exclusions EXCLUDE "(${test_exclusions})") endif () +if (DEFINED ENV{TEST_INCLUSIONS}) + set(test_inclusions INCLUDE $ENV{TEST_INCLUSIONS}) + unset(test_exclusions) +endif() + +set(PARALLEL_LEVEL "10") +if (DEFINED ENV{CTEST_MAX_PARALLELISM}) + set(PARALLEL_LEVEL $ENV{CTEST_MAX_PARALLELISM}) +endif() + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(junit_args OUTPUT_JUNIT "${CTEST_BINARY_DIRECTORY}/junit.xml") endif() # reduced parallel level so we don't exhaust system resources ctest_memcheck( - PARALLEL_LEVEL "4" + PARALLEL_LEVEL ${PARALLEL_LEVEL} RETURN_VALUE test_result - EXCLUDE "${test_exclusions}" + ${test_exclusions} + ${test_inclusions} DEFECT_COUNT defects ${junit_args} )