diff options
author | Chuck Atkins <chuck.atkins@kitware.com> | 2015-08-24 18:33:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-09-21 14:12:13 (GMT) |
commit | 9784af1b50a142c0160058734c7e12cee5f2a15e (patch) | |
tree | 864a958bf6accb58c6d9de434e1675f4addd38b7 /Tests/RunCMake/CMP0065 | |
parent | 402bf096ec4aac75af096c3708ce51efaf4589d0 (diff) | |
download | CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.zip CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.tar.gz CMake-9784af1b50a142c0160058734c7e12cee5f2a15e.tar.bz2 |
CMP0065: Restrict the use of CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS
This new policy restricts the addition of the shared library link flags
to executables only when the ENABLE_EXPORTS property is set to True.
Diffstat (limited to 'Tests/RunCMake/CMP0065')
-rw-r--r-- | Tests/RunCMake/CMP0065/BuildTargetInSubProject.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/NEWBad.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/NEWGood.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/OLDBad1.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/OLDBad2.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/RunCMakeTest.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/WARN-OFF.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/WARN-ON-stderr.txt | 10 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/WARN-ON.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/subproject/CMakeLists.txt | 22 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0065/subproject/main.c | 7 |
12 files changed, 87 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMP0065/BuildTargetInSubProject.cmake b/Tests/RunCMake/CMP0065/BuildTargetInSubProject.cmake new file mode 100644 index 0000000..9339e46 --- /dev/null +++ b/Tests/RunCMake/CMP0065/BuildTargetInSubProject.cmake @@ -0,0 +1,15 @@ +function(BuildTargetInSubProject P T E) + try_compile(RESULTVAR + ${CMAKE_CURRENT_BINARY_DIR}/subproject + ${CMAKE_CURRENT_SOURCE_DIR}/subproject + ${P} ${T} OUTPUT_VARIABLE O) + if(E AND RESULTVAR) + message(STATUS "${P} target ${T} succeeded as expected") + elseif(E AND NOT RESULTVAR) + message(FATAL_ERROR "${P} target ${T} failed but should have succeeded. Output:${O}") + elseif(NOT E AND NOT RESULTVAR) + message(STATUS "${P} target ${T} failed as expected") + elseif(NOT E AND RESULTVAR) + message(FATAL_ERROR "${P} target ${T} succeeded but should have failed. Output:${O}") + endif() +endfunction() diff --git a/Tests/RunCMake/CMP0065/CMakeLists.txt b/Tests/RunCMake/CMP0065/CMakeLists.txt new file mode 100644 index 0000000..74b3ff8 --- /dev/null +++ b/Tests/RunCMake/CMP0065/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.3) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0065/NEWBad.cmake b/Tests/RunCMake/CMP0065/NEWBad.cmake new file mode 100644 index 0000000..79d9adb --- /dev/null +++ b/Tests/RunCMake/CMP0065/NEWBad.cmake @@ -0,0 +1,4 @@ +enable_language(C) +include(BuildTargetInSubProject.cmake) + +BuildTargetInSubProject(TestPolicyCMP0065 FooNEWBad FALSE) diff --git a/Tests/RunCMake/CMP0065/NEWGood.cmake b/Tests/RunCMake/CMP0065/NEWGood.cmake new file mode 100644 index 0000000..a5b5d04 --- /dev/null +++ b/Tests/RunCMake/CMP0065/NEWGood.cmake @@ -0,0 +1,4 @@ +enable_language(C) +include(BuildTargetInSubProject.cmake) + +BuildTargetInSubProject(TestPolicyCMP0065 FooNEWGood TRUE) diff --git a/Tests/RunCMake/CMP0065/OLDBad1.cmake b/Tests/RunCMake/CMP0065/OLDBad1.cmake new file mode 100644 index 0000000..6d780b4 --- /dev/null +++ b/Tests/RunCMake/CMP0065/OLDBad1.cmake @@ -0,0 +1,4 @@ +enable_language(C) +include(BuildTargetInSubProject.cmake) + +BuildTargetInSubProject(TestPolicyCMP0065 FooOLDBad1 FALSE) diff --git a/Tests/RunCMake/CMP0065/OLDBad2.cmake b/Tests/RunCMake/CMP0065/OLDBad2.cmake new file mode 100644 index 0000000..7196473 --- /dev/null +++ b/Tests/RunCMake/CMP0065/OLDBad2.cmake @@ -0,0 +1,4 @@ +enable_language(C) +include(BuildTargetInSubProject.cmake) + +BuildTargetInSubProject(TestPolicyCMP0065 FooOLDBad2 FALSE) diff --git a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake new file mode 100644 index 0000000..254a4ec --- /dev/null +++ b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake @@ -0,0 +1,8 @@ +include(RunCMake) + +run_cmake(OLDBad1) +run_cmake(OLDBad2) +run_cmake(NEWBad) +run_cmake(NEWGood) +run_cmake(WARN-OFF) +run_cmake(WARN-ON) diff --git a/Tests/RunCMake/CMP0065/WARN-OFF.cmake b/Tests/RunCMake/CMP0065/WARN-OFF.cmake new file mode 100644 index 0000000..dbc9562 --- /dev/null +++ b/Tests/RunCMake/CMP0065/WARN-OFF.cmake @@ -0,0 +1,3 @@ + +enable_language(C) +add_executable(main subproject/main.c) diff --git a/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt b/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt new file mode 100644 index 0000000..dda4fe5 --- /dev/null +++ b/Tests/RunCMake/CMP0065/WARN-ON-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0065 is not set: Do not add flags to export symbols from + executables without the ENABLE_EXPORTS target property. Run "cmake + --help-policy CMP0065" for policy details. Use the cmake_policy command to + set the policy and suppress this warning. + + For compatibility with older versions of CMake, additional flags may be + added to export symbols on all executables regardless of thier + ENABLE_EXPORTS property. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0065/WARN-ON.cmake b/Tests/RunCMake/CMP0065/WARN-ON.cmake new file mode 100644 index 0000000..6ed4a41 --- /dev/null +++ b/Tests/RunCMake/CMP0065/WARN-ON.cmake @@ -0,0 +1,3 @@ +set(CMAKE_POLICY_WARNING_CMP0065 1) +enable_language(C) +add_executable(main subproject/main.c) diff --git a/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt b/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt new file mode 100644 index 0000000..bed5960 --- /dev/null +++ b/Tests/RunCMake/CMP0065/subproject/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.3) + +project(TestPolicyCMP0065 C) +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS BADFLAGS) + +#---------------------------------------------------------------------- +cmake_policy(SET CMP0065 OLD) +add_executable(FooOLDBad1 main.c) + +#---------------------------------------------------------------------- +cmake_policy(SET CMP0065 OLD) +add_executable(FooOLDBad2 main.c) +set_target_properties(FooOLDBad2 PROPERTIES ENABLE_EXPORTS ON) + +#---------------------------------------------------------------------- +cmake_policy(SET CMP0065 NEW) +add_executable(FooNEWGood main.c) + +#---------------------------------------------------------------------- +cmake_policy(SET CMP0065 NEW) +add_executable(FooNEWBad main.c) +set_target_properties(FooNEWBad PROPERTIES ENABLE_EXPORTS ON) diff --git a/Tests/RunCMake/CMP0065/subproject/main.c b/Tests/RunCMake/CMP0065/subproject/main.c new file mode 100644 index 0000000..98725db --- /dev/null +++ b/Tests/RunCMake/CMP0065/subproject/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char **argv) +{ + printf("Hello World\n"); + return 0; +} |