title: CMake not linking Python
body: <p>Sorry if I'm duplicating a question, but I just cannot find the solution to what I'm looking for anywhere on the internet, yet I believe that this is a very simple problem. </p>
  
  <p>I'm trying to extend python with some custom C++ libraries, and building my C++ libraries with CMake. I'm following the instructions on <a href="https://docs.python.org/2/extending/extending.html" rel="nofollow">https://docs.python.org/2/extending/extending.html</a>, but it's not compiling correctly. </p>
  
  <p>When I try to build it, I get these messages:</p>
  
  <pre><code>"C:\Program Files (x86)\JetBrains\CLion 140.2310.6\bin\cmake\bin\cmake.exe" --build C:\Users\pkim2\.clion10\system\cmake\generated\76c451cd\76c451cd\Debug --target parsers -- -j 8
  Linking CXX executable parsers.exe
  CMakeFiles\parsers.dir/objects.a(main.cpp.obj): In function `spam_system':
  C:/code/ground-trac/ground/launch/trunk/Software Support/Data Analysis Scripts/data_review_automation/parsers/main.cpp:9: undefined reference to `_imp__PyArg_ParseTuple'
  C:/code/ground-trac/ground/launch/trunk/Software Support/Data Analysis Scripts/data_review_automation/parsers/main.cpp:12: undefined reference to `_imp__Py_BuildValue'
  c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):(.text.startup+0xa7): undefined reference to `WinMain@16'
  collect2.exe: error: ld returned 1 exit status
  CMakeFiles\parsers.dir\build.make:87: recipe for target 'parsers.exe' failed
  CMakeFiles\Makefile2:59: recipe for target 'CMakeFiles/parsers.dir/all' failed
  CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/parsers.dir/rule' failed
  mingw32-make.exe[3]: *** [parsers.exe] Error 1
  mingw32-make.exe[2]: *** [CMakeFiles/parsers.dir/all] Error 2
  mingw32-make.exe[1]: *** [CMakeFiles/parsers.dir/rule] Error 2
  mingw32-make.exe: *** [parsers] Error 2
  Makefile:109: recipe for target 'parsers' failed
  </code></pre>
  
  <p>Based on this, I suspect that this is a problem with the way I'm linking things in the CMakeLists.txt file, but I have no idea how to do it properly. This is what my CMakeLists.txt looks like right now:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(parsers)
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  set(SOURCE_FILES main.cpp)
  include_directories(C:\\Python27\\include)
  link_directories(C:\\Python27\\) 
  target_link_libraries(python2.7)
  add_executable(parsers ${SOURCE_FILES})
  </code></pre>
  
  <p>How in the world do I get this thing to compile correctly? I am running Windows 7 64-bit, and using CLion as my IDE.</p>