From fc8f8d82f27344398ac27a670187a023588165d4 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sat, 29 Oct 2022 22:01:50 +1100 Subject: Tests: Disable parts of FindPkgConfig tests without wide supported Some pkg-config implementations on Windows don't return the same results as those on other platforms. They appear to be bugs in those implementations, the one that comes with Strawberry perl being one case where this was observed. The handling of Libs and Cflags entries is incomplete, resulting in some flags not being reported where they should be. These are faults in the pkg-config implementation, not in CMake or its tests, so we disable those parts of the tests on Windows to avoid reporting false positives. --- .../FindPkgConfig_IMPORTED_TARGET.cmake | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index f149d99..69ab4da 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -113,23 +113,33 @@ message(STATUS "Verifying target \"${tgt}\"") if (NOT TARGET ${tgt}) message(FATAL_ERROR "No import target for fake link options package") endif() -get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS) -if (NOT link_options STREQUAL expected_link_options) - message(FATAL_ERROR - "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" - "expected: \"${expected_link_options}\", but got \"${link_options}\"" - ) -endif() -get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES) -set(expected_inc_dirs "/special" "/other" "/more") +# Some versions of pkg-config on Windows don't parse the Libs and Cflags +# correctly. The pkg-config that comes with Strawberry perl is one example. +# It appears to treat the dummymain part of Libs as a library and only returns +# -e. It also doesn't recognize "-isystem /other", presumably because it doesn't +# support having a space between "-isystem" and the directory after it (it does +# give us the "-isystem/more" flag). Since we can't reliably test for these, +# we don't enable these checks on Windows. +if(NOT WIN32) + get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS) + if (NOT link_options STREQUAL expected_link_options) + message(FATAL_ERROR + "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" + "expected: \"${expected_link_options}\", but got \"${link_options}\"" + ) + endif() -if (NOT inc_dirs STREQUAL expected_inc_dirs) - message(FATAL_ERROR - "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" - "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" - ) -endif () + get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES) + set(expected_inc_dirs "/special" "/other" "/more") + + if (NOT inc_dirs STREQUAL expected_inc_dirs) + message(FATAL_ERROR + "Additional include directories not correctly present in INTERFACE_INCLUDE_DIRECTORIES property\n" + "expected: \"${expected_inc_dirs}\", got \"${inc_dirs}\"" + ) + endif () +endif() get_target_property(c_opts ${tgt} INTERFACE_COMPILE_OPTIONS) set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase -- cgit v0.12