Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support finding visit_struct in the system also if it is installed without any CMake config file #70

Merged
merged 4 commits into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endif()
# Fetching visit_struct
include(CMakeDependentOption)
find_package(visit_struct QUIET)
cmake_dependent_option(USE_SYSTEM_visit_struct "Use system visit_struct" ON "visit_struct_FOUND" OFF)
option(USE_SYSTEM_visit_struct "Use system visit_struct" ${visit_struct_FOUND})
if(USE_SYSTEM_visit_struct)
find_package(visit_struct REQUIRED)
else()
Expand Down Expand Up @@ -219,6 +219,9 @@ install(TARGETS matioCpp
install(FILES "cmake/FindMATIO.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/matioCpp/cmake")
file(COPY "cmake/FindMATIO.cmake" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/share/matioCpp/cmake")

install(FILES "cmake/Findvisit_struct.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/matioCpp/cmake")
file(COPY "cmake/Findvisit_struct.cmake" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/share/matioCpp/cmake")

include(InstallBasicPackageFiles)

install_basic_package_files(${PROJECT_NAME}
Expand Down
33 changes: 33 additions & 0 deletions cmake/Findvisit_struct.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# - Try to find visit_struct
#
# The following are set after configuration is done:
# visit_struct_FOUND
#
# The following imported targets are created:
#
# visit_struct::visit_struct
#

include(FindPackageHandleStandardArgs)

find_package(visit_struct CONFIG QUIET)

if(NOT visit_struct_FOUND)
find_path(VISIT_STRUCT_INCLUDE_DIR visit_struct/visit_struct_intrusive.hpp)
mark_as_advanced(VISIT_STRUCT_INCLUDE_DIR)

if(VISIT_STRUCT_INCLUDE_DIR)
set(visit_struct_FOUND TRUE)
endif()
endif()

find_package_handle_standard_args(visit_struct DEFAULT_MSG visit_struct_FOUND)

if(visit_struct_FOUND)
if(NOT TARGET visit_struct::visit_struct)
add_library(visit_struct::visit_struct INTERFACE IMPORTED)
set_target_properties(visit_struct::visit_struct PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${VISIT_STRUCT_INCLUDE_DIR}")
endif()
endif()