enlight created this revision.
enlight added reviewers: brucem, zturner.
enlight added a subscriber: lldb-commits.
enlight set the repository for this revision to rL LLVM.

Previously `CMAKE_BUILD_TYPE` was used to determine whether to link in 
`python27.lib` or `python27_d.lib`, unfortunately this only works reliably when 
using a CMake generator that generates a single build configuration (e.g. 
Ninja). The Visual Studio CMake generator generates four build configurations 
at once (`Debug`, `Release`, `RelWithDebInfo`, `MinSizeRel`), so if 
`CMAKE_BUILD_TYPE` is set to `Debug` all four build configurations end up 
linking in `python27_d.lib`, this is clearly undesirable.

To ensure that the correct Python lib is used for each build configuration the 
value of `PYTHON_LIBRARY` is now determined using generator expressions that 
evaluate to either the debug or release Python lib. The values of 
`PYTHON_EXECUTABLE` and `PYTHON_DLL` are now likewise determined using 
generator expressions.

Note that these changes only apply to the Windows build.

Repository:
  rL LLVM

http://reviews.llvm.org/D13234

Files:
  cmake/modules/LLDBConfig.cmake

Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -48,15 +48,19 @@
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
     if (NOT "${PYTHON_HOME}" STREQUAL "")
       file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
-      if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_EXECUTABLE)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27_d.lib" PYTHON_LIBRARY)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python27_d.dll" PYTHON_DLL)
-      else()
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_EXECUTABLE)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27.lib" PYTHON_LIBRARY)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python27.dll" PYTHON_DLL)
-      endif()
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_DEBUG_EXE)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27_d.lib" PYTHON_DEBUG_LIB)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python27_d.dll" PYTHON_DEBUG_DLL)
+
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_RELEASE_EXE)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27.lib" PYTHON_RELEASE_LIB)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python27.dll" PYTHON_RELEASE_DLL)
+
+      # Note that it's imperative that there is no whitespace between the 
debug and not-debug generator expressions
+      # below, otherwise CMake will replace the whitespace with a semicolon in 
some contexts (which would stuff things up).
+      set (PYTHON_EXECUTABLE 
$<$<CONFIG:Debug>:${PYTHON_DEBUG_EXE}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_EXE}>)
+      set (PYTHON_LIBRARY 
$<$<CONFIG:Debug>:${PYTHON_DEBUG_LIB}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_LIB}>)
+      set (PYTHON_DLL 
$<$<CONFIG:Debug>:${PYTHON_DEBUG_DLL}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_DLL}>)
 
       file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIR)
       if (NOT LLDB_RELOCATABLE_PYTHON)


Index: cmake/modules/LLDBConfig.cmake
===================================================================
--- cmake/modules/LLDBConfig.cmake
+++ cmake/modules/LLDBConfig.cmake
@@ -48,15 +48,19 @@
   if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
     if (NOT "${PYTHON_HOME}" STREQUAL "")
       file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
-      if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_EXECUTABLE)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27_d.lib" PYTHON_LIBRARY)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python27_d.dll" PYTHON_DLL)
-      else()
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_EXECUTABLE)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27.lib" PYTHON_LIBRARY)
-        file(TO_CMAKE_PATH "${PYTHON_HOME}/python27.dll" PYTHON_DLL)
-      endif()
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_DEBUG_EXE)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27_d.lib" PYTHON_DEBUG_LIB)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python27_d.dll" PYTHON_DEBUG_DLL)
+
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_RELEASE_EXE)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/python27.lib" PYTHON_RELEASE_LIB)
+      file(TO_CMAKE_PATH "${PYTHON_HOME}/python27.dll" PYTHON_RELEASE_DLL)
+
+      # Note that it's imperative that there is no whitespace between the debug and not-debug generator expressions
+      # below, otherwise CMake will replace the whitespace with a semicolon in some contexts (which would stuff things up).
+      set (PYTHON_EXECUTABLE $<$<CONFIG:Debug>:${PYTHON_DEBUG_EXE}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_EXE}>)
+      set (PYTHON_LIBRARY $<$<CONFIG:Debug>:${PYTHON_DEBUG_LIB}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_LIB}>)
+      set (PYTHON_DLL $<$<CONFIG:Debug>:${PYTHON_DEBUG_DLL}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_DLL}>)
 
       file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIR)
       if (NOT LLDB_RELOCATABLE_PYTHON)
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to