Commit 07b248b2 authored by jan.koester's avatar jan.koester
Browse files

test

parent 3c360bd7
Loading
Loading
Loading
Loading
+60 −0
Changes for cmake/Findtinyxml2.cmake: 60 added lines, 0 removed lines.
Original line number Diff line number Diff line
# - Try to find the TinyXML-2 library (tinyxml2)
# Once done this will define:
#
#  TinyXML2_FOUND - True if tinyxml2 was found
#  TinyXML2_INCLUDE_DIR - The directory containing tinyxml2.h
#  TinyXML2_LIBRARIES - The libraries needed to use tinyxml2

# 1. Look for the header file (tinyxml2.h)
find_path(TinyXML2_INCLUDE_DIR tinyxml2.h
    PATHS
        /usr/include
        /usr/local/include
        /opt/local/include
        /sw/include
    PATH_SUFFIXES
        tinyxml2
        # This suffix is often necessary if the install places the header
        # directly in /usr/include/tinyxml2/tinyxml2.h
)

# 2. Look for the library file (libtinyxml2.so/.a/.lib)
find_library(TinyXML2_LIBRARIES NAMES tinyxml2
    PATHS
        /usr/lib
        /usr/local/lib
        /opt/local/lib
        /sw/lib
)

# 3. Handle the standard arguments to report success/failure
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(TinyXML2 DEFAULT_MSG
    TinyXML2_LIBRARIES
    TinyXML2_INCLUDE_DIR
)

# 4. Set the resulting variables for use by the project
if(TinyXML2_FOUND)
    # The variable TINYXML2_LIBRARIES is already set from find_library
    set(TINYXML2_LIBRARIES ${TinyXML2_LIBRARIES})
    set(TINYXML2_INCLUDE_DIR ${TinyXML2_INCLUDE_DIR})

    # Create an imported target for modern CMake usage
    if(NOT TARGET tinyxml2::tinyxml2)
        add_library(tinyxml2::tinyxml2 UNKNOWN IMPORTED)
        set_target_properties(tinyxml2::tinyxml2 PROPERTIES
            INTERFACE_INCLUDE_DIRECTORIES "${TINYXML2_INCLUDE_DIR}"
            IMPORTED_LOCATION "${TINYXML2_LIBRARIES}"
            IMPORTED_LINK_INTERFACE_LIBRARIES ""
        )
    endif()

else()
    # Clean up the variables if not found
    set(TINYXML2_LIBRARIES "")
    set(TINYXML2_INCLUDE_DIR "")
endif()

# Hide the intermediate variables from the CMake cache
mark_as_advanced(TinyXML2_INCLUDE_DIR TinyXML2_LIBRARIES)