title: python/c++ - Compiling shared library with cmake and installing with distutils
body: <p>I have a boost.python project that I compile using cmake and make. It's part of a python module, and I want to be able to install that module using distutils. I have followed the instructions <a href="http://bloerg.net/2012/11/10/cmake-and-distutils.html">here</a> to create a CMakeLists.txt file that first compiles the shared library, then sets up setup.py so that make install with install the python module. However, whilst all the python files are recognised by distutils and moved to the build directory, the shared library isn't, and I really don't know why.</p>
  
  <p>My project directory structure:</p>
  
  <ul>
  <li>project
  <ul>
  <li>build (python distutils directory)</li>
  <li>doc (module documentation)</li>
  <li>module (main module directory)
  <ul>
  <li>core (dir for the boost project/library
  <ul>
  <li>CMakeLists.txt - builds shared library</li>
  </ul></li>
  <li>other_py_files (several directories of pure python files)</li>
  </ul></li>
  <li>CMakeLists.txt</li>
  <li>setup.py.in</li>
  <li>setup.py (generated by cmake)</li>
  </ul></li>
  </ul>
  
  <p>My setup.py.in file:</p>
  
  <pre><code>from distutils.core import setup
  setup(
      name='module',
      version='${PACKAGE_VERSION}',
      packages=['module', 'module.core', 'module.other_py_files'],
      package_dir={'': '${CMAKE_CURRENT_SOURCE_DIR}'},
  )
  </code></pre>
  
  <p>My CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.6)
  project (module)
  
  add_subdirectory(module/core)
  
  find_program(PYTHON "python")
  
  if (PYTHON)
    set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
    set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
    set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/pyQCD/__init__.py")
    set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
  
    configure_file(${SETUP_PY_IN} ${SETUP_PY})
  
    add_custom_command(OUTPUT ${OUTPUT}
      COMMAND ${PYTHON} ${SETUP_PY} build
      COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
      DEPENDS ${DEPS})
  
    add_custom_target(target ALL DEPENDS ${OUTPUT})
  
    install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
  
  endif()
  </code></pre>
  
  <p>I thought distutils was supposed to add shared library extensions automatically to build directory, or have I got that wrong somewhere? (The shared library is an importable python module built on the C api (boost.python), so it should work right?)</p>