commit 3b1db6ea701dc8282bf6fd8bc65e656ef86fd41c
Author: Maia Kozheva <[email protected]>
Date: Mon Dec 21 18:36:06 2009 +0600
Optional dependency support for cmake
CMakeLists.txt | 78 ++++++++++++++++++++++++++++++++++++++++++--
cmake/FindFLAC.cmake | 2 +
cmake/FindGnomeVFS.cmake | 3 ++
cmake/FindHAL.cmake | 3 ++
cmake/FindVorbisFile.cmake | 2 +
cmake/config.h.in | 25 +-------------
6 files changed, 86 insertions(+), 27 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9970845..5ac7541 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,8 @@
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+ message("In-source build attempted; use out-of source builds.")
+ message(FATAL_ERROR "Refer to the CMake documentation for more details.")
+endif()
+
message("-------------------------------------------")
message("Configuration started")
message("-------------------------------------------")
@@ -11,8 +16,15 @@ set(GETTEXT_PACKAGE ${CMAKE_PROJECT_NAME})
set(PACKAGE_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share)
set(PACKAGE_LOCALE_DIR ${PACKAGE_DATA_DIR}/${PACKAGE}/locale)
-option(USE_CLANG "OFF")
-option(USE_LOCAL_DATA_FILES "OFF")
+option(USE_CLANG "Use clang instead of gcc to compile" OFF)
+option(USE_LOCAL_DATA_FILES
+ "Use data files in the source directory when running" OFF)
+option(WANT_CURL "Enable build with CURL" ON)
+option(WANT_GNOME_VFS "Enable build with GNOME VFS" ON)
+option(WANT_HAL "Enable build with HAL" ON)
+option(WANT_LIBVORBISFILE "Enable build with libvorbisfile" ON)
+option(WANT_FLAC "Enable build with FLAC" ON)
+option(LINK_AS_NEEDED "Link with -Wl,--as-needed" ON)
if(USE_CLANG)
set(CMAKE_C_COMPILER clang)
@@ -22,7 +34,6 @@ if(USE_LOCAL_DATA_FILES)
set(PACKAGE_DATA_DIR ${CMAKE_SOURCE_DIR})
endif()
-message(${PACKAGE_DATA_DIR})
include(flex)
include(CheckIncludeFile)
@@ -33,6 +44,64 @@ find_package(LibXml2 REQUIRED)
find_package(Libgpod REQUIRED)
find_package(ID3tag REQUIRED)
+set(OPT_INCLUDES "")
+set(OPT_CFLAGS "")
+set(OPT_LIBS "")
+
+if(WANT_CURL)
+ message("-- Checking for CURL...")
+ find_package(CURL)
+ if(CURL_FOUND)
+ set(HAVE_CURL ON)
+ set(OPT_INCLUDES ${OPT_INCLUDES} ${CURL_INCLUDE_DIRS})
+ set(OPT_LIBS ${OPT_LIBS} ${CURL_LIBRARIES})
+ endif()
+endif()
+
+if(WANT_GNOME_VFS)
+ find_package(GnomeVFS)
+ if(GNOME_VFS_FOUND)
+ set(HAVE_GNOME_VFS 1)
+ set(OPT_INCLUDES ${OPT_INCLUDES} ${GNOME_VFS_INCLUDE_DIRS})
+ set(OPT_CFLAGS ${OPT_CFLAGS} ${GNOME_VFS_CFLAGS_OTHER})
+ set(OPT_LIBS ${OPT_LIBS} ${GNOME_VFS_LDFLAGS})
+ endif()
+endif()
+
+if(WANT_HAL)
+ find_package(HAL)
+ if(HAL_FOUND)
+ set(HAVE_HAL 1)
+ set(OPT_INCLUDES ${OPT_INCLUDES} ${HAL_INCLUDE_DIRS})
+ set(OPT_CFLAGS ${OPT_CFLAGS} ${HAL_CFLAGS_OTHER})
+ set(OPT_LIBS ${OPT_LIBS} ${HAL_LDFLAGS})
+ endif()
+endif()
+
+if(WANT_LIBVORBISFILE)
+ find_package(VorbisFile)
+ if(VORBISFILE_FOUND)
+ set(HAVE_LIBVORBISFILE 1)
+ set(OPT_INCLUDES ${OPT_INCLUDES} ${VORBISFILE_INCLUDE_DIRS})
+ set(OPT_CFLAGS ${OPT_CFLAGS} ${VORBISFILE_CFLAGS_OTHER})
+ set(OPT_LIBS ${OPT_LIBS} ${VORBISFILE_LDFLAGS})
+ endif()
+endif()
+
+if(WANT_FLAC)
+ find_package(FLAC)
+ if(FLAC_FOUND)
+ set(HAVE_FLAC 1)
+ set(OPT_INCLUDES ${OPT_INCLUDES} ${FLAC_INCLUDE_DIRS})
+ set(OPT_CFLAGS ${OPT_CFLAGS} ${FLAC_CFLAGS_OTHER})
+ set(OPT_LIBS ${OPT_LIBS} ${FLAC_LDFLAGS})
+ endif()
+endif()
+
+if(LINK_AS_NEEDED)
+ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed)
+endif()
+
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
@@ -44,6 +113,7 @@ include_directories(
${GLADE2_INCLUDE_DIRS}
${LIBGPOD_INCLUDE_DIRS}
${ID3TAG_INCLUDE_DIRS}
+ ${OPT_INCLUDES}
)
add_definitions(
@@ -52,6 +122,7 @@ add_definitions(
${GLADE2_CFLAGS_OTHER}
${LIBGPOD_CFLAGS_OTHER}
${ID3TAG_CFLAGS_OTHER}
+ ${OPT_CFLAGS}
-DHAVE_CONFIG_H
)
@@ -67,4 +138,5 @@ target_link_libraries(gtkpod
${GLADE2_LDFLAGS}
${LIBGPOD_LDFLAGS}
${ID3TAG_LDFLAGS}
+ ${OPT_LIBS}
)
diff --git a/cmake/FindFLAC.cmake b/cmake/FindFLAC.cmake
new file mode 100644
index 0000000..167eced
--- /dev/null
+++ b/cmake/FindFLAC.cmake
@@ -0,0 +1,2 @@
+message("-- Checking for FLAC...")
+pkg_check_modules(FLAC flac)
diff --git a/cmake/FindGnomeVFS.cmake b/cmake/FindGnomeVFS.cmake
new file mode 100644
index 0000000..cc031e8
--- /dev/null
+++ b/cmake/FindGnomeVFS.cmake
@@ -0,0 +1,3 @@
+set(GNOME_VFS_REQUIRED_VERSION 2.6.0)
+message("-- Checking for gnome-vfs >= ${GNOME_VFS_REQUIRED_VERSION}...")
+pkg_check_modules(GNOME_VFS gnome-vfs-2.0>=${GNOME_VFS_REQUIRED_VERSION})
diff --git a/cmake/FindHAL.cmake b/cmake/FindHAL.cmake
new file mode 100644
index 0000000..363dc30
--- /dev/null
+++ b/cmake/FindHAL.cmake
@@ -0,0 +1,3 @@
+set(HAL_REQUIRED_VERSION 0.5)
+message("-- Checking for hal >= ${HAL_REQUIRED_VERSION}...")
+pkg_check_modules(HAL hal>=${HAL_REQUIRED_VERSION})
diff --git a/cmake/FindVorbisFile.cmake b/cmake/FindVorbisFile.cmake
new file mode 100644
index 0000000..7a4d87d
--- /dev/null
+++ b/cmake/FindVorbisFile.cmake
@@ -0,0 +1,2 @@
+message("-- Checking for vorbisfile...")
+pkg_check_modules(VORBISFILE vorbisfile)
diff --git a/cmake/config.h.in b/cmake/config.h.in
index e4a7bae..99d8e37 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -1,7 +1,7 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* always defined to indicate that i18n is enabled */
-#cmakedefine ENABLE_NLS
+#define ENABLE_NLS
/* "Gettext package name" */
#cmakedefine GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
@@ -45,24 +45,6 @@
/* Name of package */
#cmakedefine PACKAGE "@PACKAGE@"
-/* Define to the address where bug reports for this package should be sent. */
-#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
-
-/* Define to the full name of this package. */
-#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
-
-/* Define to the full name and version of this package. */
-#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
-
-/* Define to the one symbol short name of this package. */
-#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
-
-/* Define to the home page for this package. */
-#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
-
-/* Define to the version of this package. */
-#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
-
/* Define to the package data directory. */
#cmakedefine PACKAGE_DATA_DIR "@PACKAGE_DATA_DIR@"
@@ -74,8 +56,3 @@
/* Version number of package */
#cmakedefine VERSION "@VERSION@"
-
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
- `char[]'. */
-#cmakedefine YYTEXT_POINTER
-
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2