From 73cb38d8604e21ffd30a81ceac1f89581318c103 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 26 Oct 2022 16:28:55 -0600 Subject: [PATCH] Output complete list of libraries for external Makefiles There is a Makefile include, `vtkm_config.mk`, and a package include, `vtkm.pc`, that are configured so that external programs that do not use CMake have a way of importing VTK-m's configuration. However, the set of libraries was hardcoded. In particular, many of the new filter libraries were missing. Rather than try to maintain this list manually, use the module mechanism in the CMake configuration to get a list of libraries built and automatically build these lists. --- CMakeLists.txt | 27 +++++++++++++++++++++++++++ config/vtkm.pc.in | 12 +----------- config/vtkm_config.mk.in | 12 +----------- docs/changelog/external-lib-lists.md | 11 +++++++++++ 4 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 docs/changelog/external-lib-lists.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 1abac4e37..374c44a56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,33 @@ write_basic_package_version_file( VERSION ${VTKm_VERSION} COMPATIBILITY ExactVersion ) +#----------------------------------------------------------------------------- +# Create makefile/package files for projects not using CMake + +set(lib_args) +vtkm_module_get_list(module_list) +list(REVERSE module_list) +foreach(module IN LISTS module_list) + get_target_property(type ${module} TYPE) + if (NOT type MATCHES "LIBRARY" OR type STREQUAL "INTERFACE_LIBRARY") + continue() + endif() + get_target_property(library ${module} OUTPUT_NAME) + if (NOT library) + continue() + endif() + set(lib_args "${lib_args} \\ + -l${library}") +endforeach() +if (TARGET vtkmdiympi) + set(lib_args "${lib_args} \\ + -lvtkmdiympi") +endif() +if (TARGET vtkmdiympi_nompi) + set(lib_args "${lib_args} \\ + -lvtkmdiympi_nompi") +endif() + configure_file(${VTKm_SOURCE_DIR}/config/vtkm_config.mk.in ${VTKm_BINARY_DIR}/config/vtkm_config.mk @ONLY) install(FILES ${VTKm_BINARY_DIR}/config/vtkm_config.mk diff --git a/config/vtkm.pc.in b/config/vtkm.pc.in index 71f7c71ac..162e7fdaa 100644 --- a/config/vtkm.pc.in +++ b/config/vtkm.pc.in @@ -18,14 +18,4 @@ Name: VTKm Description: The VTKm library Version: @VTKm_VERSION@ Cflags: -I${includedir}/vtkm-@CMAKE_INSTALL_PREFIX@ -Libs: -L${libdir} \ - -lvtkm_rendering-@VTKm_VERSION@ \ - -lvtkm_filter_contour-@VTKm_VERSION@ \ - -lvtkm_filter_gradient-@VTKm_VERSION@ \ - -lvtkm_filter_extra-@VTKm_VERSION@ \ - -lvtkm_filter_common-@VTKm_VERSION@ \ - -lvtkm_worklet-@VTKm_VERSION@ \ - -lvtkm_source-@VTKm_VERSION@ \ - -lvtkm_io-@VTKm_VERSION@ \ - -lvtkm_cont-@VTKm_VERSION@ \ - -lvtkmdiympi_nompi +Libs: -L${libdir}@lib_args@ diff --git a/config/vtkm_config.mk.in b/config/vtkm_config.mk.in index 0325e2dee..35d1bb968 100644 --- a/config/vtkm_config.mk.in +++ b/config/vtkm_config.mk.in @@ -25,14 +25,4 @@ VTKm_ENABLE_EGL_CONTEXT = @VTKm_ENABLE_EGL_CONTEXT@ VTKm_ENABLE_MPI = @VTKm_ENABLE_MPI@ VTKm_INCLUDE_FLAGS = -I $(VTKm_DIR)/include -VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib \ - -lvtkm_rendering-$(VTKM_VERSION) \ - -lvtkm_filter_contour-$(VTKM_VERSION) \ - -lvtkm_filter_gradient-$(VTKM_VERSION) \ - -lvtkm_filter_extra-$(VTKM_VERSION) \ - -lvtkm_filter_common-$(VTKM_VERSION) \ - -lvtkm_worklet-$(VTKM_VERSION) \ - -lvtkm_source-$(VTKM_VERSION) \ - -lvtkm_io-$(VTKM_VERSION) \ - -lvtkm_cont-$(VTKM_VERSION) \ - -lvtkmdiympi_nompi +VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib@lib_args@ diff --git a/docs/changelog/external-lib-lists.md b/docs/changelog/external-lib-lists.md new file mode 100644 index 000000000..df29ab543 --- /dev/null +++ b/docs/changelog/external-lib-lists.md @@ -0,0 +1,11 @@ +# Output complete list of libraries for external Makefiles + +There is a Makefile include, `vtkm_config.mk`, and a package include, +`vtkm.pc`, that are configured so that external programs that do not use +CMake have a way of importing VTK-m's configuration. However, the set of +libraries was hardcoded. In particular, many of the new filter libraries +were missing. + +Rather than try to maintain this list manually, the new module mechanism +in the CMake configuration is used to get a list of libraries built and +automatically build these lists.