libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

CMakeLists.txt (2845B)


      1 cmake_minimum_required(VERSION 3.1)
      2 
      3 set(LIB_VERSION_MAJOR 1)
      4 set(LIB_VERSION_MINOR 3)
      5 set(LIB_VERSION_PATCH 1)
      6 set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
      7 
      8 set(CMAKE_C_STANDARD 99)
      9 set(CMAKE_C_STANDARD_REQUIRED ON)
     10 set(CMAKE_C_EXTENSIONS OFF)
     11 
     12 project(ansilove C)
     13 
     14 include(CheckFunctionExists)
     15 include(GNUInstallDirs)
     16 
     17 # Check if system has strtonum
     18 check_function_exists(strtonum HAVE_STRTONUM)
     19 check_function_exists(reallocarray HAVE_REALLOCARRAY)
     20 
     21 # Additional include directories for compat functions and headers
     22 include_directories("compat" "include" "src")
     23 
     24 # GD
     25 find_path(GD_INCLUDE_DIRS gd.h)
     26 find_library(GD_LIBRARIES NAMES gd REQUIRED)
     27 include_directories(${GD_INCLUDE_DIRS})
     28 
     29 set(SRC src/clean.c src/drawchar.c src/fonts.c src/error.c src/loadfile.c src/init.c src/output.c src/savefile.c)
     30 set(LOADERS src/loaders/ansi.c src/loaders/artworx.c src/loaders/binary.c src/loaders/icedraw.c src/loaders/pcboard.c src/loaders/tundra.c src/loaders/xbin.c)
     31 
     32 if(NOT HAVE_STRTONUM)
     33   set(SRC ${SRC} compat/strtonum.c)
     34 endif()
     35 
     36 if(NOT HAVE_REALLOCARRAY)
     37   set(SRC ${SRC} compat/reallocarray.c)
     38 endif()
     39 
     40 add_definitions(-D_GNU_SOURCE -Wall -Wextra -pedantic)
     41 
     42 add_library(objlib OBJECT ${SRC} ${LOADERS})
     43 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE ON)
     44 
     45 add_library(ansilove SHARED $<TARGET_OBJECTS:objlib>)
     46 add_library(ansilove-static STATIC $<TARGET_OBJECTS:objlib>)
     47 
     48 target_link_libraries(ansilove ${GD_LIBRARIES} m)
     49 
     50 set_target_properties(ansilove PROPERTIES
     51   VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_MAJOR}
     52   C_VISIBILITY_PRESET hidden)
     53 
     54 install(TARGETS ansilove DESTINATION ${CMAKE_INSTALL_LIBDIR})
     55 install(TARGETS ansilove-static DESTINATION ${CMAKE_INSTALL_LIBDIR})
     56 install(FILES include/ansilove.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
     57 install(FILES man/libansilove.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     58 install(FILES man/ansilove_clean.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     59 install(FILES man/ansilove_error.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     60 install(FILES man/ansilove_init.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     61 install(FILES man/ansilove_loadfile.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     62 install(FILES man/ansilove_savefile.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     63 install(FILES man/ansilove_ansi.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     64 install(FILES man/ansilove_artworx.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     65 install(FILES man/ansilove_binary.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     66 install(FILES man/ansilove_icedraw.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     67 install(FILES man/ansilove_pcboard.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     68 install(FILES man/ansilove_tundra.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)
     69 install(FILES man/ansilove_xbin.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3/)