cmake: Fix python linker issues on windows.
authorRay Molenkamp <github@lazydodo.com>
Wed, 17 Apr 2019 19:26:02 +0000 (13:26 -0600)
committerRay Molenkamp <github@lazydodo.com>
Wed, 17 Apr 2019 19:26:02 +0000 (13:26 -0600)
Recent cmake work made the debug build link both python37.dll and python37_d.dll

build_files/cmake/macros.cmake
build_files/cmake/platform/platform_win32.cmake

index 699f9cb..56d9117 100644 (file)
@@ -383,18 +383,10 @@ function(setup_liblinks
     ${FREETYPE_LIBRARY}
   )
 
-  # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
-  if(WITH_PYTHON)  # AND NOT WITH_PYTHON_MODULE  # WIN32 needs
-    target_link_libraries(${target} ${PYTHON_LINKFLAGS})
 
-    if(WIN32 AND NOT UNIX)
-      file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
-      target_link_libraries_debug(${target} "${PYTHON_LIBRARIES_DEBUG}")
-      target_link_libraries_optimized(${target} "${PYTHON_LIBRARIES}")
-      unset(PYTHON_LIBRARIES_DEBUG)
-    else()
-      target_link_libraries(${target} ${PYTHON_LIBRARIES})
-    endif()
+  if(WITH_PYTHON)
+    target_link_libraries(${target} ${PYTHON_LINKFLAGS})
+    target_link_libraries(${target} ${PYTHON_LIBRARIES})
   endif()
 
   if(WITH_LZO AND WITH_SYSTEM_LZO)
index 7b516d8..dce0e73 100644 (file)
@@ -339,6 +339,8 @@ if(WITH_PYTHON)
   string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
   # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
   set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
+  set(PYTHON_LIBRARY_DEBUG ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.lib)
+
   unset(_PYTHON_VERSION_NO_DOTS)
 
   # Shared includes for both vc2008 and vc2010
@@ -346,7 +348,7 @@ if(WITH_PYTHON)
 
   # uncached vars
   set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
-  set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
+  set(PYTHON_LIBRARIES debug "${PYTHON_LIBRARY_DEBUG}" optimized "${PYTHON_LIBRARY}" )
 endif()
 
 if(WITH_BOOST)