Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 27, 2024
1 parent b8350c3 commit e2014dd
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions find-external/TinyXML/FindTinyXML2.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Imported from https://github.com/ros/urdfdom/blob/master/cmake/FindTinyXML2.cmake, BSD-3-Clause
# Imported from
# https://github.com/ros/urdfdom/blob/master/cmake/FindTinyXML2.cmake,
# BSD-3-Clause

# TinyXML2_FOUND
# TinyXML2_INCLUDE_DIRS
# TinyXML2_LIBRARIES
# TinyXML2_FOUND TinyXML2_INCLUDE_DIRS TinyXML2_LIBRARIES

# try to find the CMake config file for TinyXML2 first
if(NOT TinyXML2_FOUND)
Expand All @@ -11,8 +11,8 @@ endif()
if(TinyXML2_FOUND)
message(STATUS "Found TinyXML2 via Config file: ${TinyXML2_DIR}")
if(NOT TINYXML2_LIBRARY)
# in this case, we're probably using TinyXML2 version 5.0.0 or greater
# in which case tinyxml2 is an exported target and we should use that
# in this case, we're probably using TinyXML2 version 5.0.0 or greater in
# which case tinyxml2 is an exported target and we should use that
if(TARGET tinyxml2)
set(TINYXML2_LIBRARY tinyxml2)
elseif(TARGET tinyxml2::tinyxml2)
Expand All @@ -24,32 +24,43 @@ if(TinyXML2_FOUND)
else()
# Only perform that logic once
if(NOT TARGET tinyxml2::tinyxml2)
# TINYXML2_LIBRARY is composed of debug;<path\to\debug.lib>;optimized;<path\to\release.lib>
# we have to extract the appropriate component based on the current configuration.
# TINYXML2_LIBRARY is composed of
# debug;<path\to\debug.lib>;optimized;<path\to\release.lib> we have to
# extract the appropriate component based on the current configuration.
list(LENGTH TINYXML2_LIBRARY TINYXML_LIBRARY_LIST_LENGTH)
if(NOT ${TINYXML_LIBRARY_LIST_LENGTH} EQUAL 4)
message(FATAL_ERROR "Unable to extract the library file path from ${TINYXML2_LIBRARY}")
message(
FATAL_ERROR
"Unable to extract the library file path from ${TINYXML2_LIBRARY}")
endif()
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
list(GET TINYXML2_LIBRARY 0 ASSERT_DEBUG)
if(NOT ${ASSERT_DEBUG} STREQUAL "debug")
message(FATAL_ERROR "could not parse debug library path from ${TINYXML2_LIBRARY}")
message(
FATAL_ERROR
"could not parse debug library path from ${TINYXML2_LIBRARY}")
endif()
list(GET TINYXML2_LIBRARY 1 TINYXML2_LIBRARY_PATH)
else()
list(GET TINYXML2_LIBRARY 2 ASSERT_OPTIMIZED)
if(NOT ${ASSERT_OPTIMIZED} STREQUAL "optimized")
message(FATAL_ERROR "could not parse library path from ${TINYXML2_LIBRARY}")
message(
FATAL_ERROR "could not parse library path from ${TINYXML2_LIBRARY}")
endif()
list(GET TINYXML2_LIBRARY 3 TINYXML2_LIBRARY_PATH)
endif()
if(NOT EXISTS ${TINYXML2_LIBRARY_PATH})
message(FATAL_ERROR "library file path ${TINYXML2_LIBRARY_PATH} does not exist")
message(
FATAL_ERROR
"library file path ${TINYXML2_LIBRARY_PATH} does not exist")
endif()

add_library(tinyxml2::tinyxml2 UNKNOWN IMPORTED)
set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION ${TINYXML2_LIBRARY_PATH})
set_property(TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR})
set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION
${TINYXML2_LIBRARY_PATH})
set_property(
TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES
${TINYXML2_INCLUDE_DIR})
list(APPEND TinyXML2_TARGETS tinyxml2::tinyxml2)
endif()
endif()
Expand All @@ -59,14 +70,17 @@ else()
find_library(TINYXML2_LIBRARY tinyxml2)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR)
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY
TINYXML2_INCLUDE_DIR)

mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY)

if(NOT TARGET tinyxml2::tinyxml2)
add_library(tinyxml2::tinyxml2 UNKNOWN IMPORTED)
set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION ${TINYXML2_LIBRARY})
set_property(TARGET tinyxml2::tinyxml2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR})
set_property(TARGET tinyxml2::tinyxml2 PROPERTY IMPORTED_LOCATION
${TINYXML2_LIBRARY})
set_property(TARGET tinyxml2::tinyxml2
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TINYXML2_INCLUDE_DIR})
list(APPEND TinyXML2_TARGETS tinyxml2::tinyxml2)
endif()
endif()
Expand Down

0 comments on commit e2014dd

Please sign in to comment.