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

Account for potential target namespace when finding cmake module... #2

Merged
merged 5 commits into from
Dec 13, 2018
Merged
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
9 changes: 7 additions & 2 deletions cmake/Modules/FindTinyXML2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
find_package(TinyXML2 CONFIG QUIET)
if(TinyXML2_FOUND)
message(STATUS "Found TinyXML2 via Config file: ${TinyXML2_DIR}")
if(NOT TINYXML2_LIBRARY AND TARGET tinyxml2)
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
set(TINYXML2_LIBRARY tinyxml2)
if(TARGET tinyxml2)
set(TINYXML2_LIBRARY tinyxml2)
jacobperron marked this conversation as resolved.
Show resolved Hide resolved
elseif(TARGET tinyxml2::tinyxml2)
set(TINYXML2_LIBRARY tinyxml2::tinyxml2)
endif()
endif()
else()
find_path(TINYXML2_INCLUDE_DIR NAMES tinyxml2.h)
Expand All @@ -20,6 +24,7 @@ else()
find_package_handle_standard_args(tinyxml2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR)

mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY)
set(TinyXML2_FOUND ${tinyxml2_FOUND})
endif()

if(NOT TinyXML2_INCLUDE_DIRS)
Expand Down