From 19c748533949b3dcc45816383b9f6dd4e06130d1 Mon Sep 17 00:00:00 2001 From: Sfan5 Date: Sun, 9 Mar 2014 12:18:48 +0100 Subject: [PATCH] Allow selecting include dir & library for libgd --- CMakeLists.txt | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a861bbc..dec60f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,28 +6,34 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) set(CMAKE_CXX_FLAGS_RELEASE "-std=c++0x -Wall -DNDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -std=c++0x -Wall -Wextra -DDEBUG") +# Find libgd +find_library(LIBGD_LIBRARY gd) +find_path(LIBGD_INCLUDE_DIR gd.h) +message (STATUS "libgd library: ${LIBGD_LIBRARY}") +message (STATUS "libgd headers: ${LIBGD_INCLUDE_DIR}") +if(NOT LIBGD_LIBRARY OR NOT LIBGD_INCLUDE_DIR) + message(FATAL_ERROR "libgd not found!") +endif(NOT LIBGD_LIBRARY OR NOT LIBGD_INCLUDE_DIR) find_package(PkgConfig) include(FindPackageHandleStandardArgs) +# Find libsqlite3 pkg_check_modules(PC_LIBSQLITE QUIET sqlite3) set(LIBSQLITE3_DEFINITIONS ${PC_LIBSQLITE_CFLAGS_OTHER}) - find_path(LIBSQLITE3_INCLUDE_DIR sqlite3.h HINTS ${PC_LIBSQLITE_INCLUDEDIR} ${PC_LIBSQLITE_INCLUDE_DIRS} PATH_SUFFIXES libsqlite3) find_library(LIBSQLITE3_LIBRARY NAMES sqlite3 libsqlite3 HINTS ${PC_LIBSQLITE_LIBDIR} ${PC_LIBSQLITE_LIBRARY_DIRS}) -set(LIBSQLITE3_LIBRARIES ${LIBSQLITE3_LIBRARY} ) +set(LIBSQLITE3_LIBRARIES ${LIBSQLITE3_LIBRARY}) set(LIBSQLITE3_INCLUDE_DIRS ${LIBSQLITE3_INCLUDE_DIR}) - find_package_handle_standard_args(LibSqlite3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIBSQLITE3_INCLUDE_DIR) - mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY) -if (LIBSQLITE3_INCLUDE_DIR) -else (LIBSQLITE3_INCLUDE_DIR) +if(NOT LIBSQLITE3_INCLUDE_DIR) message(FATAL_ERROR "Could not find sqlite3") -endif (LIBSQLITE3_INCLUDE_DIR) +endif(NOT LIBSQLITE3_INCLUDE_DIR) +# Find leveldb set(USE_LEVELDB 0) OPTION(ENABLE_LEVELDB "Enable LevelDB backend") @@ -47,6 +53,7 @@ if(ENABLE_LEVELDB) endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) endif(ENABLE_LEVELDB) +# Find xxd find_program(XXD_EXECUTABLE xxd) if (XXD_EXECUTABLE) @@ -55,6 +62,7 @@ else (XXD_EXECUTABLE) message(FATAL_ERROR "xxd not found") endif (XXD_EXECUTABLE) +# Add command to turn colors.txt into a C header file add_custom_command( OUTPUT colors.h COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/colors.txt colors.txt @@ -68,6 +76,7 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" ${LIBSQLITE3_INCLUDE_DIRS} + ${LIBGD_INCLUDE_DIR} ) configure_file( @@ -97,6 +106,6 @@ target_link_libraries( minetestmapper ${LIBSQLITE3_LIBRARIES} ${LEVELDB_LIBRARY} - gd + ${LIBGD_LIBRARY} z )