[cmake-developers] Support for imported targets in CMAKE_REQUIRED_LIBRARIES
Alexander Neundorf
neundorf at kde.org
Thu Feb 16 06:32:02 EST 2012
On Monday 30 January 2012, Brad King wrote:
...
> You're running into the same can of worms I (now) remember running into
> a few years ago when you first proposed handling imported targets with
> try_compile. That's one reason it never got done. Let's just drop the
> C++ side of this again. Your CMake-code-only solution is probably good
> enough for typical use cases. Please refine that based on my original
> comments and post again. I'm sorry for leading you on this goose chase.
Done, and pushed to stage.
I added the prefix "cmake_" to the function, and added a test for it.
Additionally some fixes and style changes.
This is the test:
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES exp_testLib2)
check_function_exists(testLib1 HAVE_TESTLIB1_FUNCTION)
if (NOT HAVE_TESTLIB1_FUNCTION)
message(SEND_ERROR "Using imported target testLib2 failed !")
endif()
I.e. it uses the imported target exp_testLib2 in CMAKE_REQUIRED_LIBRARIES, and
checks for a function from testLib1, which must have been pulled in
transitively.
Ok to merge ?
Alex
More information about the cmake-developers
mailing list