diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-24 14:34:15 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-25 15:43:16 +0100 |
commit | 331b153be5c58287179e5d6192a9314dbb4085ef (patch) | |
tree | 0c57419975303eb0025819acc9fc81bdd0f1d0ee /cmake/FindWrapRt.cmake | |
parent | 160184d6a5d0b89d9b885581f2d93a5650eede0a (diff) |
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 <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'cmake/FindWrapRt.cmake')
-rw-r--r-- | cmake/FindWrapRt.cmake | 15 |
1 files changed, 9 insertions, 6 deletions
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() |