From 331b153be5c58287179e5d6192a9314dbb4085ef Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 24 Feb 2020 14:34:15 +0100 Subject: CMake: Fix FindWrapRt module when it's found multiple times On Windows, when WrapRt is qt_find_pacakge()'d the first time, the result is "not found", whereas a second time it would claim that the package is found. This is due to the WrapRt target being always created even if it has no transitive dependencies, and thus a second search would check only for the existence of the target. Fix the module to only create the target if the relevant library is found. Change-Id: I5c838cbfbafb4029f96da815a0f72e4a8e6716b0 Reviewed-by: Leander Beernaert Reviewed-by: Simon Hausmann --- cmake/FindWrapRt.cmake | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cmake/FindWrapRt.cmake') diff --git a/cmake/FindWrapRt.cmake b/cmake/FindWrapRt.cmake index d14b922062..0e57cadef5 100644 --- a/cmake/FindWrapRt.cmake +++ b/cmake/FindWrapRt.cmake @@ -5,6 +5,8 @@ if(TARGET WrapRt) return() endif() +set(WrapRt_FOUND OFF) + include(CheckCXXSourceCompiles) include(CMakePushCheckState) @@ -25,10 +27,11 @@ int main(int argc, char *argv[]) { cmake_pop_check_state() -add_library(WrapRt INTERFACE IMPORTED) -if (LIBRT_FOUND) - target_link_libraries(WrapRt INTERFACE "${LIBRT}") -endif() - -set(WrapRt_FOUND "${HAVE_GETTIME}") +if(HAVE_GETTIME) + set(WrapRt_FOUND ON) + add_library(WrapRt INTERFACE IMPORTED) + if (LIBRT_FOUND) + target_link_libraries(WrapRt INTERFACE "${LIBRT}") + endif() +endif() -- cgit v1.2.3