title: Using CMake for a c++ extension in Python using SWIG with dependencies on pre-existing libraries
body: <p>Starting with SWIG's help file, I want to run the following code </p>
  
  <pre><code># This is a CMake example for Python
  
  FIND_PACKAGE(SWIG REQUIRED)
  INCLUDE(${SWIG_USE_FILE})
  
  FIND_PACKAGE(PythonLibs)
  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
  
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
  
  SET(CMAKE_SWIG_FLAGS "")
  
  SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES CPLUSPLUS ON)
  SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall")
  SWIG_ADD_MODULE(example python example.i example.cxx) # I need to link to an external library
  SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})
  </code></pre>
  
  <p>This would work fine except that example.cxx in my case needs to be linked to a prexisting library, let's call it libmylibrary.a. I tried add this to the SWIG_LINK_LIBRARIES command but that didn't do the trick. Any ideas?</p>