From 3cefba0259904a0abf94ab507d2c5137715be318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= Date: Tue, 22 Mar 2022 21:41:44 +0100 Subject: [PATCH] Set tinyxml2_LIBRARIES after find_package() (#3918) If tinyxml2 is found by find_package(), then tinyxml2_LIBRARIES is empty. Set tinyxml2_LIBRARIES to "tinyxml2::tinyxml2" in this case. - Fixes "undefined reference to `tinyxml2::" - printInfo.cmake: Fix indentation of tinyxml2_LIBRARIES --- cmake/findDependencies.cmake | 4 +++- cmake/printInfo.cmake | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index 00bbf53ec..08f2950cd 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -47,7 +47,9 @@ endif() if (NOT USE_BUNDLED_TINYXML2) find_package(tinyxml2 QUIET) - if (NOT tinyxml2_FOUND) + if (TARGET tinyxml2::tinyxml2) + set(tinyxml2_LIBRARIES "tinyxml2::tinyxml2") + else() find_library(tinyxml2_LIBRARIES tinyxml2) if (NOT tinyxml2_LIBRARIES) message(FATAL_ERROR "tinyxml2 has not been found") diff --git a/cmake/printInfo.cmake b/cmake/printInfo.cmake index e8c9995a8..c70edb12b 100644 --- a/cmake/printInfo.cmake +++ b/cmake/printInfo.cmake @@ -66,7 +66,7 @@ endif() message( STATUS ) message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" ) if (NOT USE_BUNDLED_TINYXML2) - message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}") + message(STATUS "tinyxml2_LIBRARIES = ${tinyxml2_LIBRARIES}") endif() message( STATUS ) message( STATUS "USE_BOOST = ${USE_BOOST}" )