[Lldb-commits] [lldb] r230262 - [CMake] On Windows, require manual specification of python libs.
Zachary Turner
zturner at google.com
Mon Feb 23 13:20:59 PST 2015
Author: zturner
Date: Mon Feb 23 15:20:59 2015
New Revision: 230262
URL: http://llvm.org/viewvc/llvm-project?rev=230262&view=rev
Log:
[CMake] On Windows, require manual specification of python libs.
Embedding python with MSVC is very finicky, for reasons having
to do with the operating system's CRT, the implementation of
python itself on Windows, and even bugs in CMake.
One side effect of this is that we cannot rely on FindPythonLibs
and FindPythonInterp CMake functions to locate the correct
version of Python. We must instead manually specify the location
of PYTHON_LIBRARY and PYTHON_INCLUDE_DIR.
As a side effect, this fixes building LLDB in release mode by
specifying -DCMAKE_BUILD_TYPE=Release, which was previously
broken.
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/source/CMakeLists.txt
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=230262&r1=230261&r2=230262&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Feb 23 15:20:59 2015
@@ -72,15 +72,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
include(HandleLLVMOptions)
# Verify that we can find a Python 2 interpreter. Python 3 is unsupported.
- set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
- include(FindPythonInterp)
- if( NOT PYTHONINTERP_FOUND )
- message(FATAL_ERROR
- "Unable to find Python interpreter, required for builds and testing.
-
- Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
+ if (PYTHON_EXECUTABLE STREQUAL "")
+ set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
+ include(FindPythonInterp)
+ if( NOT PYTHONINTERP_FOUND )
+ message(FATAL_ERROR
+ "Unable to find Python interpreter, required for builds and testing.
+ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
+ endif()
+ else()
+ message("-- Found PythonInterp: ${PYTHON_EXECUTABLE}")
endif()
-
# Import CMake library targets from LLVM and Clang.
include("${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
include("${LLDB_PATH_TO_CLANG_BUILD}/share/clang/cmake/ClangConfig.cmake")
@@ -136,8 +138,18 @@ if (NOT LLDB_DISABLE_PYTHON)
set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
endif()
endif()
- find_package(PythonLibs REQUIRED)
- include_directories(${PYTHON_INCLUDE_DIRS})
+ if (MSVC)
+ if (PYTHON_INCLUDE_DIR STREQUAL "" OR PYTHON_LIBRARY STREQUAL "")
+ message(FATAL_ERROR "Building on MSVC requires manual specification of "
+ "PYTHON_INCLUDE_DIR and PYTHON_LIBRARY")
+ else()
+ message("-- Found PythonLibs: ${PYTHON_LIBRARY}")
+ include_directories(${PYTHON_INCLUDE_DIR})
+ endif()
+ else()
+ find_package(PythonLibs REQUIRED)
+ include_directories(${PYTHON_INCLUDE_DIRS})
+ endif()
endif()
include_directories(../clang/include)
Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=230262&r1=230261&r2=230262&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Mon Feb 23 15:20:59 2015
@@ -47,20 +47,26 @@ add_lldb_library(liblldb SHARED
${LLDB_VERS_GENERATED_FILE}
)
+
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
-target_link_libraries(liblldb PRIVATE lldbAPI)
+ target_link_libraries(liblldb PRIVATE lldbAPI)
+ # Only MSVC has the ABI compatibility and avoids using FindPythonLibs,
+ # so only it needs to explicitly link against ${PYTHON_LIBRARY}
+ if (MSVC)
+ target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARY})
+ endif()
-set_target_properties(liblldb
- PROPERTIES
- OUTPUT_NAME liblldb
- VERSION ${LLDB_VERSION}
- )
+ set_target_properties(liblldb
+ PROPERTIES
+ OUTPUT_NAME liblldb
+ VERSION ${LLDB_VERSION}
+ )
else()
-set_target_properties(liblldb
- PROPERTIES
- OUTPUT_NAME lldb
- VERSION ${LLDB_VERSION}
- )
+ set_target_properties(liblldb
+ PROPERTIES
+ OUTPUT_NAME lldb
+ VERSION ${LLDB_VERSION}
+ )
endif()
if (LLDB_WRAP_PYTHON OR LLDB_VERS_GENERATED_FILE)
More information about the lldb-commits
mailing list