Skip to content

Commit

Permalink
Merge pull request #70 from traversaro/vcpkgvisitstruct
Browse files Browse the repository at this point in the history
Support finding visit_struct in the system also if it is installed without any CMake config file
  • Loading branch information
S-Dafarra committed May 20, 2023
2 parents 02be0a0 + c73482f commit a0daf06
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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()

0 comments on commit a0daf06

Please sign in to comment.