Fix names of INTERFACE libraries.

git grep -l -e add_library --and -e INTERFACE | xargs sed -i 's|boost::\([^ ]\+\) INTERFACE)|boost_\1 INTERFACE)\nadd_library(boost::\1 ALIAS boost_\1)|'
Use the INTERFACE name in mutating commands, not the ALIAS name.

git grep -l -e add_library --and -e INTERFACE | xargs sed -i 's|boost::\([^ ]\+\) INTERFACE|boost_\1 INTERFACE|'
Install the INTERFACE, not the ALIAS.

git grep -l TARGETS | xargs sed -i 's|TARGETS boost::\([^ ]\+\)|TARGETS boost_\1|'
Export targets with a namespace.

git grep -l "FILE \${PROJECT_NAME}Targets.cmake" | xargs sed -i 's|FILE \${PROJECT_NAME}Targets.cmake|FILE \${PROJECT_NAME}Targets.cmake\n  NAMESPACE boost::|'
Export targets with proper names.
Fix the boost::random::device names.
Fix up some special cases with double namespaces
Install Targets files in a more suitable location.
Use simpler syntax to set the INTERFACE_INCLUDE_DIRECTORIES

git grep -l "EXPORT \${PROJECT_NAME}Targets)" | xargs sed -i 's|EXPORT \${PROJECT_NAME}Targets)|EXPORT ${PROJECT_NAME}Targets\n  INCLUDES DESTINATION include\n  )|'
git grep -l "\$<INSTALL_INTERFACE:\${CMAKE_INSTALL_PREFIX}/include>" | xargs sed -i '/\$<INSTALL_INTERFACE:\${CMAKE_INSTALL_PREFIX}\/include>/d'
Add macro to write a config file.
Add some CMake Config files.

.#!/usr/bin/env python

import os

handle = os.popen("git grep \"^project\"", "r")

info = handle.read().splitlines()

packages = {}

files = []

for item in info:
  f, content = item.split(":", 1)
  name = content.split("project(")[1].split()[0].split("Boost")[1]

  if name[-1] == ")":
    name = name[:-1]

  handle = os.popen("git grep -h \"ALIAS\" " + f, "r")

  matches = handle.read().splitlines()

  files.append(f)

  for match in matches:
    lib = match.split("add_library(")[1].split()[0]
    packages[lib] = name

for f in files:
  handle = open(f)
  lines = handle.read().splitlines()
  processingLibs = False
  deps = []
  for line in lines:
    if "target_link_libraries" in line and ("INTERFACE" in line or "PUBLIC" in line):
      processingLibs = True
      continue
    if processingLibs and ")" in line:
      break
    if processingLibs:
      lib = line.strip()
      if "boost::" in lib:
        deps.append(packages[lib])

  if deps:
    handle = open(f, "a")
    handle.write('''
write_config_file(\"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake\"
''')
    for dep in deps:
      handle.write("  " + dep + "\n")
    handle.write('''  )
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  VERSION ${BOOST_VERSION}
  COMPATIBILITY AnyNewerVersion
  )

install(FILES
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  DESTINATION lib/cmake/${PROJECT_NAME}
)
''')
Write more config files

These libraries do not list any dependencies in their LINK_LIBRARIES,
(which is a bug in all cases), but create a config file for them
anyway.

Slightly modified script:

.#!/usr/bin/env python

import os

handle = os.popen("git grep \"^project\"", "r")

info = handle.read().splitlines()

packages = {}

files = []

for item in info:
  f, content = item.split(":", 1)
  name = content.split("project(")[1].split()[0].split("Boost")[1]

  if name[-1] == ")":
    name = name[:-1]

  handle = os.popen("git grep -h \"ALIAS\" " + f, "r")

  matches = handle.read().splitlines()

  files.append(f)

  for match in matches:
    lib = match.split("add_library(")[1].split()[0]
    packages[lib] = name

for f in files:
  handle = open(f)
  content = handle.read()
  if "write_config_file" in content:
    continue

  lines = content.splitlines()
  processingLibs = False
  deps = []
  for line in lines:
    if "target_link_libraries" in line and ("INTERFACE" in line or "PUBLIC" in line):
      processingLibs = True
      continue
    if processingLibs and ")" in line:
      break
    if processingLibs:
      lib = line.strip()
      if "boost::" in lib:
        deps.append(packages[lib])

  handle = open(f, "a")
  handle.write('''
write_config_file(\"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake\")
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  VERSION ${BOOST_VERSION}
  COMPATIBILITY AnyNewerVersion
  )

install(FILES
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  DESTINATION lib/cmake/${PROJECT_NAME}
)
''')
Merge pull request #1 from steveire/master

Fix some use of ALIAS and INTERFACE targets