CMakeLists.txt 2.3 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()
  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()
  42. add_library(testlib testlib.cxx)
  43. add_executable (simple simple.cxx ../simple.cxx ${DEEPSRC})
  44. target_link_libraries(simple testlib outlib)
  45. endif ()
  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()