summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeCommands
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-04-24 15:01:01 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2018-06-06 15:22:39 (GMT)
commitc1f5a44b28047cde74e2fb10e8d68e314272f699 (patch)
tree6124b73331c13c92480b5352045686758d3df86f /Tests/CMakeCommands
parent8e28d2630a60475dad715162a1802d301ada35bd (diff)
downloadCMake-c1f5a44b28047cde74e2fb10e8d68e314272f699.zip
CMake-c1f5a44b28047cde74e2fb10e8d68e314272f699.tar.gz
CMake-c1f5a44b28047cde74e2fb10e8d68e314272f699.tar.bz2
LINK_OPTIONS: Add new family of properties
This family enable to manage link flags Three new properties: * directory property: LINK_OPTIONS * target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS Two new commands * add_link_options(): to populate directory property * target_link_options(): to populate target properties Fixes: #16543
Diffstat (limited to 'Tests/CMakeCommands')
-rw-r--r--Tests/CMakeCommands/add_link_options/CMakeLists.txt20
-rw-r--r--Tests/CMakeCommands/add_link_options/LinkOptionsExe.c4
-rw-r--r--Tests/CMakeCommands/target_link_options/CMakeLists.txt19
-rw-r--r--Tests/CMakeCommands/target_link_options/LinkOptionsLib.c7
4 files changed, 50 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/add_link_options/CMakeLists.txt b/Tests/CMakeCommands/add_link_options/CMakeLists.txt
new file mode 100644
index 0000000..bb7dcbb
--- /dev/null
+++ b/Tests/CMakeCommands/add_link_options/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(add_link_options LANGUAGES C)
+
+
+add_link_options(-LINK_FLAG)
+
+add_executable(add_link_options EXCLUDE_FROM_ALL LinkOptionsExe.c)
+
+get_target_property(result add_link_options LINK_OPTIONS)
+if (NOT result MATCHES "-LINK_FLAG")
+ message(SEND_ERROR "add_link_options not populated the LINK_OPTIONS target property")
+endif()
+
+
+add_library(imp UNKNOWN IMPORTED)
+get_target_property(result imp LINK_OPTIONS)
+if (result)
+ message(FATAL_ERROR "add_link_options populated the LINK_OPTIONS target property")
+endif()
diff --git a/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_options/CMakeLists.txt b/Tests/CMakeCommands/target_link_options/CMakeLists.txt
new file mode 100644
index 0000000..c66cd37
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_options/CMakeLists.txt
@@ -0,0 +1,19 @@
+
+cmake_minimum_required(VERSION 3.11)
+
+project(target_link_options LANGUAGES C)
+
+add_library(target_link_options SHARED LinkOptionsLib.c)
+# Test no items
+target_link_options(target_link_options PRIVATE)
+
+add_library(target_link_options_2 SHARED EXCLUDE_FROM_ALL LinkOptionsLib.c)
+target_link_options(target_link_options_2 PRIVATE -PRIVATE_FLAG INTERFACE -INTERFACE_FLAG)
+get_target_property(result target_link_options_2 LINK_OPTIONS)
+if (NOT result MATCHES "-PRIVATE_FLAG")
+ message(SEND_ERROR "target_link_options not populated the LINK_OPTIONS target property")
+endif()
+get_target_property(result target_link_options_2 INTERFACE_LINK_OPTIONS)
+if (NOT result MATCHES "-INTERFACE_FLAG")
+ message(SEND_ERROR "target_link_options not populated the INTERFACE_LINK_OPTIONS target property")
+endif()
diff --git a/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c
new file mode 100644
index 0000000..9bbd24c
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}