Fix OLD behavior of CMP0021.

Exclude Ninja and Xcode from the CMP0021 test

They do not behave the same as the makefile generator with
relative paths.

Don't overwrite the header file for in-source builds.
This commit is contained in:
Stephen Kelly 2013-08-22 23:52:00 +02:00
parent 374af6529a
commit eef6df5c7d
5 changed files with 35 additions and 1 deletions

View File

@ -3303,9 +3303,12 @@ static void processIncludeDirectories(cmTarget *tgt,
if (!noMessage)
{
tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
if (messageType == cmake::FATAL_ERROR)
{
return;
}
}
}
if (testIsOff && !cmSystemTools::IsOff(li->c_str()))
{

View File

@ -0,0 +1,14 @@
cmake_policy(SET CMP0021 OLD)
add_executable(cmp0021exe main.cpp)
if(NOT CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/includes")
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy_directory
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
"${CMAKE_CURRENT_BINARY_DIR}/includes"
)
endif()
set_property(TARGET cmp0021exe PROPERTY
INCLUDE_DIRECTORIES includes/cmp0021)

View File

@ -0,0 +1,2 @@
#define CMP0021_DEFINE

View File

@ -0,0 +1,11 @@
#include "cmp0021.h"
#ifndef CMP0021_DEFINE
#error Expected CMP0021_DEFINE
#endif
int main(int, char **)
{
return 0;
}

View File

@ -86,3 +86,7 @@ get_target_property(incs empty_entry_test INCLUDE_DIRECTORIES)
if (NOT incs STREQUAL ";/one/two")
message(SEND_ERROR "Empty include_directories entry was not ignored.")
endif()
if(NOT CMAKE_GENERATOR STREQUAL Xcode AND NOT CMAKE_GENERATOR STREQUAL Ninja)
add_subdirectory(CMP0021)
endif()