CMakeLists.txt 2.4 KB

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