From 911fd457922d9749180719e21f359704f17d88b0 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pawelczyk Date: Tue, 8 Feb 2011 00:30:08 +0100 Subject: [PATCH] Fix SQLite support for CMake users. FindPkgConfig obviously uses pkg-config's output for setting convenient variables such as _LIBRARIES or _INCLUDE_DIRS. It also sets _FOUND to 1 if module exists. So why checking for SQLITE3_FOUND is better than (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)? Apart from obvious readability factor, latter condition has strong assumption that both variables are filled with appropriate paths, which is unjustifiable unless you add another assumptions... pkg-config by default strips -I/usr/include from Cflags and -L/usr/lib from Libs if some environment variables are not set, PKG_CONFIG_ALLOW_SYSTEM_CFLAGS and PKG_CONFIG_ALLOW_SYSTEM_LIBS respectively. This behavior is sane, because it prevents polluting the compilation and linking commands with superfluous entries. In debian SQLITE3_INCLUDE_DIRS is empty for instance. Remark for developers: Always check commands invoked by CMake after changing CMakeLists.txt. VERBOSE=1 cmake --build . --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7f96515c..7bf491ef1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ IF (NOT WIN32) pkg_check_modules(SQLITE3 sqlite3) ENDIF () -IF (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) +IF (SQLITE3_FOUND) ADD_DEFINITIONS(-DGIT2_SQLITE_BACKEND) INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIRS}) ENDIF ()