From 2eb722d3a4053eadef3da207c45e644adf17baa8 Mon Sep 17 00:00:00 2001 From: Alex Mayfield Date: Sat, 26 May 2018 17:12:02 -0400 Subject: [PATCH] Link against libpng and libm Tested against Ubuntu 18.04. --- CMakeLists.txt | 8 ++++++++ config.h.cin | 1 + src/CMakeLists.txt | 3 +++ textscreen/CMakeLists.txt | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa1f6c32..7f569d61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,14 @@ find_package(SDL2 2.0.1) find_package(SDL2_mixer 2.0.0) find_package(SDL2_net 2.0.0) +# Check for libpng. +find_package(PNG) +if(PNG_FOUND) + set(HAVE_LIBPNG TRUE) +endif() + +find_package(m) + include(CheckFunctionExists) check_function_exists(strcasecmp HAVE_DECL_STRCASECMP) check_function_exists(strncasecmp HAVE_DECL_STRNCASECMP) diff --git a/config.h.cin b/config.h.cin index f2cbf21a..4a3b8a15 100644 --- a/config.h.cin +++ b/config.h.cin @@ -4,5 +4,6 @@ #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" #cmakedefine PROGRAM_PREFIX "@PROGRAM_PREFIX@" +#cmakedefine01 HAVE_LIBPNG #cmakedefine01 HAVE_DECL_STRCASECMP #cmakedefine01 HAVE_DECL_STRNCASECMP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 452d8321..ca9fc502 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,6 +106,9 @@ set(SOURCE_FILES ${COMMON_SOURCE_FILES} ${GAME_SOURCE_FILES}) set(SOURCE_FILES_WITH_DEH ${SOURCE_FILES} ${DEHACKED_SOURCE_FILES}) set(EXTRA_LIBS textscreen pcsound opl SDL2::SDL2main SDL2::SDL2 SDL2::mixer SDL2::net) +if(PNG_FOUND) + list(APPEND EXTRA_LIBS PNG::PNG) +endif() if(WIN32) add_executable("${PROGRAM_PREFIX}doom" WIN32 ${SOURCE_FILES_WITH_DEH} "${CMAKE_CURRENT_BINARY_DIR}/resource.rc") diff --git a/textscreen/CMakeLists.txt b/textscreen/CMakeLists.txt index bf9fa1fb..2a1802a6 100644 --- a/textscreen/CMakeLists.txt +++ b/textscreen/CMakeLists.txt @@ -25,4 +25,4 @@ add_library(textscreen target_include_directories(textscreen INTERFACE "." PRIVATE "../src/") -target_link_libraries(textscreen SDL2::SDL2) +target_link_libraries(textscreen m SDL2::SDL2)