title: How can I add C/C++ and swig generated code to the same library using cmake
body: <p>The SWIG plugin to CMake is currently puzzling me. I want to build a single shared object that contains executable code compiled directly from C/C++ code as well as indirectly from input files to swig.</p>
  
  <p>In my <code>CMakeLists.txt</code> file I therefore have </p>
  
  <pre><code>file (GLOB SOURCES ./src/ice/ice/*.c ./src/ice/ice/*.cpp)
  add_library (ice SHARED ${SOURCES})
  target_include_directories (ice PUBLIC ./bld/build/gen)
  ...
  set_property(SOURCE ./src/ice/ice/ice_swig.i PROPERTY CPLUSPLUS ON) 
  swig_add_library (ice LANGUAGE tcl SOURCES ./src/ice/ice/ice_swig.i ) 
  ...
  </code></pre>
  
  <p>During configuration, I get this error:</p>
  
  <blockquote>
    <p>CMake Error at /public/public64/packages/development/cmake-3.8.1/share/cmake-3.8/Modules/UseSWIG.cmake:275
    (add_library):<br>
            add_library cannot create target "ice" because another target with the
            same name already exists.  The existing target is a shared library created in 
            source directory "/home/steve/cmake_games/src/ice/ice".<br>
    See documentation for policy CMP0002 for more details.
            Call Stack (most recent call first): src/ice/ice/CMakeLists.txt:20 (swig_add_library)<br>
    -- Configuring incomplete, errors occurred!</p>
  </blockquote>
  
  <p>It seems that both <code>add_libary</code> and <code>swig_add_library</code> are defining a target with the same name. This does not allow me to add both C/C++ "handcrafted" code and swig generated code to the same library. What is the correct way of using CMake to add SWIG generated C/C++ to the same library?</p>