Allow selecting include dir & library for libgd

This commit is contained in:
Sfan5 2014-03-09 12:18:48 +01:00
parent 0a5a0d0d51
commit 19c7485339

@ -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_RELEASE "-std=c++0x -Wall -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -std=c++0x -Wall -Wextra -DDEBUG") 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) find_package(PkgConfig)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
# Find libsqlite3
pkg_check_modules(PC_LIBSQLITE QUIET sqlite3) pkg_check_modules(PC_LIBSQLITE QUIET sqlite3)
set(LIBSQLITE3_DEFINITIONS ${PC_LIBSQLITE_CFLAGS_OTHER}) 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_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}) 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}) set(LIBSQLITE3_INCLUDE_DIRS ${LIBSQLITE3_INCLUDE_DIR})
find_package_handle_standard_args(LibSqlite3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIBSQLITE3_INCLUDE_DIR) find_package_handle_standard_args(LibSqlite3 DEFAULT_MSG LIBSQLITE3_LIBRARY LIBSQLITE3_INCLUDE_DIR)
mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY) mark_as_advanced(LIBSQLITE3_INCLUDE_DIR LIBSQLITE3_LIBRARY)
if (LIBSQLITE3_INCLUDE_DIR) if(NOT LIBSQLITE3_INCLUDE_DIR)
else (LIBSQLITE3_INCLUDE_DIR)
message(FATAL_ERROR "Could not find sqlite3") message(FATAL_ERROR "Could not find sqlite3")
endif (LIBSQLITE3_INCLUDE_DIR) endif(NOT LIBSQLITE3_INCLUDE_DIR)
# Find leveldb
set(USE_LEVELDB 0) set(USE_LEVELDB 0)
OPTION(ENABLE_LEVELDB "Enable LevelDB backend") OPTION(ENABLE_LEVELDB "Enable LevelDB backend")
@ -47,6 +53,7 @@ if(ENABLE_LEVELDB)
endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
endif(ENABLE_LEVELDB) endif(ENABLE_LEVELDB)
# Find xxd
find_program(XXD_EXECUTABLE xxd) find_program(XXD_EXECUTABLE xxd)
if (XXD_EXECUTABLE) if (XXD_EXECUTABLE)
@ -55,6 +62,7 @@ else (XXD_EXECUTABLE)
message(FATAL_ERROR "xxd not found") message(FATAL_ERROR "xxd not found")
endif (XXD_EXECUTABLE) endif (XXD_EXECUTABLE)
# Add command to turn colors.txt into a C header file
add_custom_command( add_custom_command(
OUTPUT colors.h OUTPUT colors.h
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/colors.txt colors.txt 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_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
${LIBSQLITE3_INCLUDE_DIRS} ${LIBSQLITE3_INCLUDE_DIRS}
${LIBGD_INCLUDE_DIR}
) )
configure_file( configure_file(
@ -97,6 +106,6 @@ target_link_libraries(
minetestmapper minetestmapper
${LIBSQLITE3_LIBRARIES} ${LIBSQLITE3_LIBRARIES}
${LEVELDB_LIBRARY} ${LEVELDB_LIBRARY}
gd ${LIBGD_LIBRARY}
z z
) )