summaryrefslogtreecommitdiffstats
path: root/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
blob: d4188098f0bfd98746370a72c9485648b0ff8804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
  set(BUILD_SHARED_LIBS 1)

  # Construct a source file outside the tree whose full path is close to
  # the path length limit.  This will cause the full path to the object
  # file in the build tree to exceed the maximum path length which will
  # test cmLocalGenerator::CreateSafeUniqueObjectFileName.
  get_filename_component(DEEPDIR
    ${OutOfSource_BINARY_DIR}/../OutOfSourceDeep/deeper ABSOLUTE)

  # Test giving the generator a custom limit.
  set(CMAKE_OBJECT_PATH_MAX 220)

  # Use a separate variable for computation.
  set(MAXPATH "${CMAKE_OBJECT_PATH_MAX}")

  # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the
  # path of the source file for no good reason.  Reduce the length
  # limit by 46 characters to account for it.  It should still be long
  # enough to require special object file name conversion.
  if(${CMAKE_GENERATOR} MATCHES "Visual Studio (8|10)")
    math(EXPR MAXPATH "${MAXPATH} - 46")
  endif()

  # Ninja imposes a maximum path component count of 30.  Permit more
  # path components in the source path.
  if(${CMAKE_GENERATOR} MATCHES "Ninja")
    math(EXPR MAXPATH "${MAXPATH} - 44")
  endif()

  # MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety
  math(EXPR MAXPATH "${MAXPATH} - 25")
  string(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
  while("${DEEPDIR_LEN}" LESS "${MAXPATH}")
    set(DEEPDIR ${DEEPDIR}/and/deeper)
    string(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
  endwhile("${DEEPDIR_LEN}" LESS "${MAXPATH}")
  set(DEEPSRC ${DEEPDIR}/simple.cxx)
  string(LENGTH "${DEEPSRC}" DEEPSRC_LEN)
  configure_file(simple.cxx.in ${DEEPSRC} COPYONLY)

  # Watcom WMake seems to have problems with long command lines.  Just
  # disable this part of the test until it is resolved.
  if(${CMAKE_GENERATOR} MATCHES "Watcom WMake")
    set(DEEPSRC "")
    add_definitions(-DNO_DEEPSRC)
  endif(${CMAKE_GENERATOR} MATCHES "Watcom WMake")

  add_library(testlib testlib.cxx)
  add_executable (simple simple.cxx ../simple.cxx ${DEEPSRC})
  target_link_libraries(simple testlib outlib)
endif ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")

# test getting a definition from a subdir
set (WEASELS SIZZLING)

get_directory_property(incDirs INCLUDE_DIRECTORIES)
if(NOT incDirs)
   message(FATAL_ERROR "get_directory_property(INCLUDE_DIRECTORIES) returned empty list")
endif(NOT incDirs)