| 1 |
include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
| 2 |
|
| 3 |
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") |
| 4 |
set(BUILD_SHARED_LIBS 1) |
| 5 |
|
| 6 |
# Construct a source file outside the tree whose full path is close to |
| 7 |
# the path length limit. This will cause the full path to the object |
| 8 |
# file in the build tree to exceed the maximum path length which will |
| 9 |
# test cmLocalGenerator::CreateSafeUniqueObjectFileName. |
| 10 |
get_filename_component(DEEPDIR |
| 11 |
${OutOfSource_BINARY_DIR}/../OutOfSourceDeep/deeper ABSOLUTE) |
| 12 |
|
| 13 |
# Test giving the generator a custom limit. |
| 14 |
set(CMAKE_OBJECT_PATH_MAX 220) |
| 15 |
|
| 16 |
# Use a separate variable for computation. |
| 17 |
set(MAXPATH "${CMAKE_OBJECT_PATH_MAX}") |
| 18 |
|
| 19 |
# VS adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the |
| 20 |
# path of the source file for no good reason. Reduce the length |
| 21 |
# limit by 46 characters to account for it. It should still be long |
| 22 |
# enough to require special object file name conversion. |
| 23 |
if(${CMAKE_GENERATOR} MATCHES "Visual Studio") |
| 24 |
math(EXPR MAXPATH "${MAXPATH} - 46") |
| 25 |
endif() |
| 26 |
|
| 27 |
# Ninja imposes a maximum path component count of 30. Permit more |
| 28 |
# path components in the source path. |
| 29 |
if(${CMAKE_GENERATOR} MATCHES "Ninja") |
| 30 |
math(EXPR MAXPATH "${MAXPATH} - 44") |
| 31 |
endif() |
| 32 |
|
| 33 |
# MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety |
| 34 |
math(EXPR MAXPATH "${MAXPATH} - 25") |
| 35 |
string(LENGTH "${DEEPDIR}" DEEPDIR_LEN) |
| 36 |
while("${DEEPDIR_LEN}" LESS "${MAXPATH}") |
| 37 |
set(DEEPDIR ${DEEPDIR}/and/deeper) |
| 38 |
string(LENGTH "${DEEPDIR}" DEEPDIR_LEN) |
| 39 |
endwhile() |
| 40 |
set(DEEPSRC ${DEEPDIR}/simple.cxx) |
| 41 |
string(LENGTH "${DEEPSRC}" DEEPSRC_LEN) |
| 42 |
configure_file(simple.cxx.in ${DEEPSRC} COPYONLY) |
| 43 |
|
| 44 |
# Watcom WMake seems to have problems with long command lines. Just |
| 45 |
# disable this part of the test until it is resolved. |
| 46 |
if(${CMAKE_GENERATOR} MATCHES "Watcom WMake") |
| 47 |
set(DEEPSRC "") |
| 48 |
add_definitions(-DNO_DEEPSRC) |
| 49 |
endif() |
| 50 |
|
| 51 |
add_library(testlib testlib.cxx) |
| 52 |
add_executable (simple simple.cxx ../simple.cxx ${DEEPSRC}) |
| 53 |
target_link_libraries(simple testlib outlib) |
| 54 |
endif () |
| 55 |
|
| 56 |
# test getting a definition from a subdir |
| 57 |
set (WEASELS SIZZLING) |
| 58 |
|
| 59 |
get_directory_property(incDirs INCLUDE_DIRECTORIES) |
| 60 |
if(NOT incDirs) |
| 61 |
message(FATAL_ERROR "get_directory_property(INCLUDE_DIRECTORIES) returned empty list") |
| 62 |
endif() |