summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2019-09-13 17:59:53 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2020-04-18 15:14:56 (GMT)
commit95ead383754f86f8f794eafbd436b6faf508559b (patch)
treed76a8bdf7386d2dcc2de12f8b2148142ec3c891a /Tests
parentb7304f35b30f77949eb06cb152e75b599402730d (diff)
downloadCMake-95ead383754f86f8f794eafbd436b6faf508559b.zip
CMake-95ead383754f86f8f794eafbd436b6faf508559b.tar.gz
CMake-95ead383754f86f8f794eafbd436b6faf508559b.tar.bz2
FindPkgConfig: fix handling of frameworks
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks.cmake13
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake29
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch-framework.pc9
4 files changed, 53 insertions, 0 deletions
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks.cmake
new file mode 100644
index 0000000..fde886d
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks.cmake
@@ -0,0 +1,13 @@
+find_package(PkgConfig)
+
+set(foobar_LDFLAGS_OTHER "-Wl,xy;-framework;bar;-Wl,other-framework;-framework;baz;-Wl,abc;-framework;gosh;-frameworkcrap;-frame;j;-framework;nix;-Wl,def")
+set(foobar_LIBRARIES "-lz;-lm")
+
+_pkgconfig_extract_frameworks("foobar")
+
+if (NOT foobar_LDFLAGS_OTHER STREQUAL "-Wl,xy;-Wl,other-framework;-Wl,abc;-frameworkcrap;-frame;j;-Wl,def")
+ message(SEND_ERROR "foobar_LDFLAGS_OTHER did not match: ${foobar_LDFLAGS_OTHER}")
+endif ()
+if (NOT foobar_LIBRARIES STREQUAL "-lz;-lm;-framework bar;-framework baz;-framework gosh;-framework nix")
+ message(SEND_ERROR "foobar_LIBRARIES did not match: ${foobar_LIBRARIES}")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake
new file mode 100644
index 0000000..5501d9f
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake
@@ -0,0 +1,29 @@
+# Prepare environment to reuse bletch.pc
+file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig" PC_PATH)
+if(UNIX)
+ string(REPLACE "\\ " " " PC_PATH "${PC_PATH}")
+endif()
+set(ENV{PKG_CONFIG_PATH} "${PC_PATH}")
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(Bletch IMPORTED_TARGET REQUIRED bletch-framework)
+
+if (Bletch_LDFLAGS_OTHER)
+ message(SEND_ERROR "Bletch_LDFLAGS_OTHER should be empty, but is '${Bletch_LDFLAGS_OTHER}'")
+endif ()
+
+if (NOT Bletch_LINK_LIBRARIES STREQUAL "-framework foo;-framework bar;bletch;-framework baz")
+ message(SEND_ERROR "Bletch_LINK_LIBRARIES has wrong value '${Bletch_LINK_LIBRARIES}'")
+endif ()
+
+foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_OPTIONS INTERFACE_COMPILE_OPTIONS)
+ get_target_property(prop_value PkgConfig::Bletch ${prop})
+ if (prop_value)
+ message(SEND_ERROR "target property ${prop} should not be set, but is '${prop_value}'")
+ endif ()
+endforeach ()
+
+get_target_property(prop_value PkgConfig::Bletch INTERFACE_LINK_LIBRARIES)
+if (NOT prop_value STREQUAL Bletch_LINK_LIBRARIES)
+ message(SEND_ERROR "target property INTERFACE_LINK_LIBRARIES has wrong value '${prop_value}'")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index 9df1d5b..dc77915 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -6,8 +6,10 @@ run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH)
run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH)
+run_cmake(FindPkgConfig_extract_frameworks)
if(APPLE)
+ run_cmake(FindPkgConfig_extract_frameworks_target)
run_cmake(FindPkgConfig_CMAKE_FRAMEWORK_PATH)
run_cmake(FindPkgConfig_CMAKE_APPBUNDLE_PATH)
endif()
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch-framework.pc b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch-framework.pc
new file mode 100644
index 0000000..cc680ae
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch-framework.pc
@@ -0,0 +1,9 @@
+prefix=/opt/bletch
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: Bletch
+Description: Dummy packaget to test variable support
+Version: 1.3
+Libs: -L${libdir} -framework foo -framework bar -lbletch -framework baz