From bc404d052a4e0fb6c0e80cf1d61f46c62d6c6240 Mon Sep 17 00:00:00 2001 From: Pierre Pebay Date: Thu, 20 Feb 2025 22:12:22 +0100 Subject: [PATCH 1/3] #125: Fix install target and rename standalone app --- apps/CMakeLists.txt | 7 ++++++- apps/{vt-tv_standalone.cc => vttv.cc} | 2 +- build.sh | 12 ++++++++++++ cmake/load_vtk_package.cmake | 19 +++++++++++++++++++ tests/unit/render/test_standalone_app.cc | 4 ++-- 5 files changed, 40 insertions(+), 4 deletions(-) rename apps/{vt-tv_standalone.cc => vttv.cc} (98%) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 8d7001a55c..6102005c3a 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,6 +1,6 @@ macro(add_test_for_app_vt_tv test_name test_exec) - if(${test_name} STREQUAL "vt-tv:vt-tv_standalone") + if(${test_name} STREQUAL "vt-tv:vttv") add_test( NAME ${test_name} COMMAND ${test_exec} -c tests/config/conf.yaml @@ -57,4 +57,9 @@ foreach(APP_FULL ${PROJECT_APPS}) MODULES ${VTK_LIBRARIES} ) + install( + TARGETS ${APP} + DESTINATION bin + ) + endforeach() diff --git a/apps/vt-tv_standalone.cc b/apps/vttv.cc similarity index 98% rename from apps/vt-tv_standalone.cc rename to apps/vttv.cc index b4f16e5674..79425045e8 100644 --- a/apps/vt-tv_standalone.cc +++ b/apps/vttv.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// example2.cc +// vttv.cc // DARMA/vt-tv => Virtual Transport -- Task Visualizer // // Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC diff --git a/build.sh b/build.sh index 07ea3266c0..c9e05e754d 100755 --- a/build.sh +++ b/build.sh @@ -45,6 +45,8 @@ GCOV="${GCOV:-gcov}" VT_TV_DIR="${VT_TV_DIR:-$CURRENT_DIR}" VT_TV_BUILD_DIR="${VT_TV_BUILD_DIR:-$PARENT_DIR/vt-tv/build}" VT_TV_OUTPUT_DIR="${VT_TV_OUTPUT_DIR:-$CURRENT_DIR/output}" +VT_TV_INSTALL="${VT_TV_INSTALL:-OFF}" +VT_TV_INSTALL_DIR="${VT_TV_INSTALL_DIR:-$VT_TV_BUILD_DIR/install}" # >> Build settings VT_TV_BUILD=$(on_off ${VT_TV_BUILD:-ON}) # option to turn off the build to only run tests VT_TV_BUILD_TYPE=${VT_TV_BUILD_TYPE:-Release} @@ -76,6 +78,8 @@ help() { -b --build=[bool] Build vt-tv. Can be turned off for example to run tests without rebuilding. (VT_TV_BUILD=$VT_TV_BUILD) -d --build-dir=[str] Build directory (VT_TV_BUILD_DIR=$VT_TV_BUILD_DIR) + -i --install Enable installation after build (VT_TV_INSTALL=$VT_TV_INSTALL) + -l --install-dir=[str] Installation directory (VT_TV_INSTALL_DIR=$VT_TV_INSTALL_DIR) -m --build-type=[str] Set the CMAKE_BUILD_TYPE value (Debug|Release|...) (VT_TV_BUILD_TYPE=$VT_TV_BUILD_TYPE) -y --clean=[bool] Clean the output directory and the CMake cache. (VT_TV_CLEAN=$VT_TV_CLEAN) -p --bindings Build with Python bindings (VT_TV_PYTHON_BINDINGS_ENABLED=$VT_TV_PYTHON_BINDINGS_ENABLED) @@ -124,6 +128,8 @@ while getopts btch-: OPT; do # allow -b -t -c -h, and --long_attr=value" case "$OPT" in b | build ) VT_TV_BUILD=$(on_off $OPTARG) ;; d | build-dir ) VT_TV_BUILD_DIR=$(realpath "$OPTARG") ;; + i | install) VT_TV_INSTALL=$(on_off $OPTARG) ;; + l | install-dir) VT_TV_INSTALL_DIR=$(realpath "$OPTARG") ;; m | build-type) VT_TV_BUILD_TYPE=$(on_off $OPTARG) ;; p | bindings ) VT_TV_PYTHON_BINDINGS_ENABLED=$(on_off $OPTARG) ;; c | cc) CC="$OPTARG" ;; @@ -185,6 +191,7 @@ if [[ "${VT_TV_BUILD}" == "ON" ]]; then \ -DCMAKE_C_COMPILER="${CC}" \ -DCMAKE_CXX_COMPILER="${CXX}" \ + -DCMAKE_INSTALL_PREFIX="${VT_TV_INSTALL_DIR}" \ \ -DVT_TV_WERROR_ENABLED="${VT_TV_WERROR_ENABLED}" \ \ @@ -201,6 +208,11 @@ if [[ "${VT_TV_BUILD}" == "ON" ]]; then time cmake --build . --parallel -j "${VT_TV_CMAKE_JOBS}" + if [[ "$VT_TV_INSTALL" == "ON" ]]; then + echo "> Installing to ${VT_TV_INSTALL_DIR}..." + cmake --install . --prefix "${VT_TV_INSTALL_DIR}" + fi + popd fi # End build diff --git a/cmake/load_vtk_package.cmake b/cmake/load_vtk_package.cmake index 6d0c04dad8..35956d8951 100644 --- a/cmake/load_vtk_package.cmake +++ b/cmake/load_vtk_package.cmake @@ -20,3 +20,22 @@ find_package( message(STATUS "VTK version: ${VTK_VERSION}") message(STATUS "VTK libraries: ${VTK_LIBRARIES}") + +foreach(VTK_LIBRARY ${VTK_LIBRARIES}) + get_target_property(VTK_RUNTIME_LIBRARY_DIR ${VTK_LIBRARY} LOCATION) + + list( + APPEND + VTK_RUNTIME_LIBRARY_DIRS + "${VTK_RUNTIME_LIBRARY_DIR}" + ) +endforeach() + +if(NOT VTK_RUNTIME_LIBRARY_DIRS) + message(FATAL_ERROR "VTK runtime library paths could not be determined!") +endif() + +install( + FILES ${VTK_RUNTIME_LIBRARY_DIRS} + DESTINATION lib +) diff --git a/tests/unit/render/test_standalone_app.cc b/tests/unit/render/test_standalone_app.cc index 51743e02be..7631f40cd5 100644 --- a/tests/unit/render/test_standalone_app.cc +++ b/tests/unit/render/test_standalone_app.cc @@ -73,9 +73,9 @@ TEST_P(StandaloneAppTest, test_run) { fmt::format("{}/tests/config/{}", SRC_DIR, std::get<0>(GetParam())); int expected_phases = std::get<1>(GetParam()); - // Run vt-tv_standalone process + // Run vttv process auto cmd = - fmt::format("{}/apps/vt-tv_standalone --conf={}", BUILD_DIR, config_file); + fmt::format("{}/apps/vttv --conf={}", BUILD_DIR, config_file); const auto [status, output] = Util::exec(cmd.c_str()); fmt::print(output); From eace6ecf42841d3637c7a90c4e11b851b0da58f3 Mon Sep 17 00:00:00 2001 From: Pierre Pebay Date: Thu, 20 Feb 2025 22:39:19 +0100 Subject: [PATCH 2/3] #125: Fix cmake target name conflicts between app and binding --- bindings/python/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 13291f9023..0f7839611d 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -10,12 +10,16 @@ file( nanobind_build_library(nanobind SHARED) # Create the Python bindings for the module -nanobind_add_module(vttv ${PYTHON_BINDING_SRCS} tv.cc) +# small workaround here, use pyvttv target name to avoid conflict with binary executable +# target, called vttv as well; we want the python package to be called vttv too, +# thus the set_target_properties on OUTPUT_NAME. +nanobind_add_module(pyvttv ${PYTHON_BINDING_SRCS} tv.cc) +set_target_properties(${PYTHON_MODULE_TARGET} PROPERTIES OUTPUT_NAME "vttv") # .. Link it to necessary libraries -target_link_libraries(vttv PUBLIC ${VT_TV_LIBRARY_NS} ${JSON_LIBRARY} ${FMT_LIBRARY}) +target_link_libraries(pyvttv PUBLIC ${VT_TV_LIBRARY_NS} ${JSON_LIBRARY} ${FMT_LIBRARY}) vtk_module_autoinit( - TARGETS vttv + TARGETS pyvttv MODULES ${VTK_LIBRARIES} ) From f32edbb0157b1d6c3d99e3a20e9f84b3b3f358cc Mon Sep 17 00:00:00 2001 From: Pierre Pebay Date: Thu, 20 Feb 2025 22:48:31 +0100 Subject: [PATCH 3/3] #125: Fix binding cmake target name --- bindings/python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 0f7839611d..5b125a1ee8 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -14,7 +14,7 @@ nanobind_build_library(nanobind SHARED) # target, called vttv as well; we want the python package to be called vttv too, # thus the set_target_properties on OUTPUT_NAME. nanobind_add_module(pyvttv ${PYTHON_BINDING_SRCS} tv.cc) -set_target_properties(${PYTHON_MODULE_TARGET} PROPERTIES OUTPUT_NAME "vttv") +set_target_properties(pyvttv PROPERTIES OUTPUT_NAME "vttv") # .. Link it to necessary libraries target_link_libraries(pyvttv PUBLIC ${VT_TV_LIBRARY_NS} ${JSON_LIBRARY} ${FMT_LIBRARY})