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.
This commit is contained in:
Craig Scott
2022-10-29 22:01:50 +11:00
parent 96d7b5a6d1
commit fc8f8d82f2

View File

@@ -113,24 +113,34 @@ 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}\""
)
# 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()
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(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 ()
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
if (NOT c_opts STREQUAL expected_c_opts)