diff --git a/cmake/load_local_packages.cmake b/cmake/load_local_packages.cmake index b2eccfa0a3..ac98393db5 100644 --- a/cmake/load_local_packages.cmake +++ b/cmake/load_local_packages.cmake @@ -7,24 +7,20 @@ include(cmake/local_package.cmake) if (EXISTS "${PROJECT_LIB_DIR}/detector") add_subdirectory(${PROJECT_LIB_DIR}/detector) - set(vt_find_detector_dep 0) else() # require directories for these packages require_pkg_directory(detector "VT detector library") # find these required packages locally find_package_local(detector "${detector_DIR}" detector) - set(vt_find_detector_dep 1) endif() if (EXISTS "${PROJECT_LIB_DIR}/checkpoint") add_subdirectory(${PROJECT_LIB_DIR}/checkpoint) - set(vt_find_checkpoint_dep 0) else() # require directories for these packages require_pkg_directory(checkpoint "VT checkpoint library") # find these required packages locally find_package_local(checkpoint "${checkpoint_DIR}" checkpoint) - set(vt_find_checkpoint_dep 1) endif() set(CHECKPOINT_LIBRARY vt::lib::checkpoint) diff --git a/cmake/local_package.cmake b/cmake/local_package.cmake index 7c2d22ae84..8f8227fda9 100644 --- a/cmake/local_package.cmake +++ b/cmake/local_package.cmake @@ -24,6 +24,10 @@ endmacro(require_pkg_directory) macro(find_package_local pkg_name pkg_directory pkg_other_name) get_directory_property(hasParent PARENT_DIRECTORY) + + # Whether we loaded the package in the following loop with find_package() + set(${pkg_name}_PACKAGE_LOADED 0) + if(hasParent) # Skip this logic when this macro was not invoked from the # top-level CMakeLists.txt file under the assumption that this @@ -31,7 +35,7 @@ macro(find_package_local pkg_name pkg_directory pkg_other_name) # Note that this will also skip if you call this macro from # a subdirectory in your own package, so just don't do it! - #message(STATUS "skipping find_package for ${pkg_name}") + # message(STATUS "skipping find_package for ${pkg_name}") else() message( STATUS "find_package_local: pkg name=\"${pkg_name}\", " @@ -45,9 +49,6 @@ macro(find_package_local pkg_name pkg_directory pkg_other_name) # Default search paths: root, /cmake and /CMake subdirectories list(APPEND prefix_args "/" "/cmake" "/CMake") - # Whether we loaded the package in the following loop with find_package() - set(${pkg_name}_PACKAGE_LOADED 0) - foreach(prefix ${prefix_args}) set(potential_path ${pkg_directory}/${prefix}) # message("prefix: ${potential_path}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de91b9e551..88d4f10ef7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -318,12 +318,12 @@ if (vt_libfort_enabled) install(TARGETS ${FORT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY}) endif() -if (vt_find_detector_dep EQUAL 0) +if (NOT detector_PACKAGE_LOADED) install(TARGETS detector EXPORT ${VIRTUAL_TRANSPORT_LIBRARY}) set(DETECTOR_EXPORT detector) endif() -if (vt_find_checkpoint_dep EQUAL 0) +if (NOT checkpoint_PACKAGE_LOADED) install(TARGETS checkpoint EXPORT ${VIRTUAL_TRANSPORT_LIBRARY}) set(CHECKPOINT_EXPORT checkpoint) endif()