CMakeLists.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. # MAXPATH less 25 for last /and/deeper/simple.cxx part and small safety
  22. MATH(EXPR MAXPATH "${MAXPATH} - 25")
  23. STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
  24. WHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}")
  25. SET(DEEPDIR ${DEEPDIR}/and/deeper)
  26. STRING(LENGTH "${DEEPDIR}" DEEPDIR_LEN)
  27. ENDWHILE("${DEEPDIR_LEN}" LESS "${MAXPATH}")
  28. SET(DEEPSRC ${DEEPDIR}/simple.cxx)
  29. STRING(LENGTH "${DEEPSRC}" DEEPSRC_LEN)
  30. CONFIGURE_FILE(simple.cxx.in ${DEEPSRC} COPYONLY)
  31. # Watcom WMake seems to have problems with long command lines. Just
  32. # disable this part of the test until it is resolved.
  33. IF(${CMAKE_GENERATOR} MATCHES "Watcom WMake")
  34. SET(DEEPSRC "")
  35. ADD_DEFINITIONS(-DNO_DEEPSRC)
  36. ENDIF(${CMAKE_GENERATOR} MATCHES "Watcom WMake")
  37. ADD_LIBRARY(testlib testlib.cxx)
  38. ADD_EXECUTABLE (simple simple.cxx ../simple.cxx ${DEEPSRC})
  39. TARGET_LINK_LIBRARIES(simple testlib outlib)
  40. ENDIF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
  41. # test getting a definition from a subdir
  42. SET (WEASELS SIZZLING)
  43. GET_DIRECTORY_PROPERTY(incDirs INCLUDE_DIRECTORIES)
  44. IF(NOT incDirs)
  45. MESSAGE(FATAL_ERROR "GET_DIRECTORY_PROPERTY(INCLUDE_DIRECTORIES) returned empty list")
  46. ENDIF(NOT incDirs)