THRIFT-3097 cmake targets unconditionally depend on optional libraries
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2800167..f19f999 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,11 @@
 if(WITH_CPP)
     add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
     if(BUILD_TESTING)
-        add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
+        if(WITH_LIBEVENT)
+            add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
+        else()
+            message(WARNING "libevent not found or disabled; will not build some tests")
+        endif()
     endif()
 endif()
 
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index f2eb76d..7d8b032 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -24,7 +24,7 @@
 option(BUILD_COMPILER "Build Thrift compiler" ON)
 option(BUILD_TESTING "Build with unit tests" ON)
 option(BUILD_EXAMPLES "Build examples" ON)
-option(BUILD_LIBRARIES "Build Thrfit libraries" ON)
+option(BUILD_LIBRARIES "Build Thrift libraries" ON)
 
 # Libraries to build
 
@@ -74,9 +74,10 @@
                        "BUILD_LIBRARIES;JAVA_FOUND;ANT_FOUND" OFF)
 
 # Python
-include(FindPythonInterp QUIET)
+include(FindPythonInterp QUIET) # for Python executable
+include(FindPythonLibs QUIET) # for Python.h
 CMAKE_DEPENDENT_OPTION(WITH_PYTHON "Build Python library" ON
-                       "BUILD_LIBRARIES;PYTHONINTERP_FOUND" OFF)
+                       "BUILD_LIBRARIES;PYTHONLIBS_FOUND" OFF)
 
 # Common library options
 option(WITH_SHARED_LIB "Build shared libraries" ON)
diff --git a/lib/py/CMakeLists.txt b/lib/py/CMakeLists.txt
index e92658d..ef987b6 100755
--- a/lib/py/CMakeLists.txt
+++ b/lib/py/CMakeLists.txt
@@ -17,6 +17,8 @@
 # under the License.
 #
 
+include_directories(${PYTHON_INCLUDE_DIRS})
+
 add_custom_target(python_build ALL
     COMMAND ${PYTHON_EXECUTABLE} setup.py build
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}