ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

CMakeLists.txt (2119B)


      1 cmake_minimum_required(VERSION 3.1)
      2 
      3 set(CMAKE_C_STANDARD 99)
      4 set(CMAKE_C_STANDARD_REQUIRED ON)
      5 set(CMAKE_C_EXTENSIONS OFF)
      6 
      7 project(ansilove C)
      8 
      9 include(CheckFunctionExists)
     10 include(GNUInstallDirs)
     11 
     12 # Conditional build options
     13 set(ENABLE_SECCOMP 0 CACHE BOOL "Enable building with seccomp")
     14 
     15 # Check if system has pledge and strtonum
     16 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_OPENBSD_SOURCE)
     17 check_function_exists(pledge HAVE_PLEDGE)
     18 check_function_exists(strtonum HAVE_STRTONUM)
     19 
     20 if(ENABLE_SECCOMP)
     21   # Check if system has seccomp
     22   message(STATUS "Looking for seccomp")
     23   find_path(SECCOMP NAMES "linux/seccomp.h")
     24   if(SECCOMP)
     25     message(STATUS "Looking for seccomp - found")
     26     add_definitions(-DHAVE_SECCOMP)
     27   else()
     28     message(STATUS "Looking for seccomp - not found")
     29   endif()
     30 endif(ENABLE_SECCOMP)
     31 
     32 # Additional include directories for compat functions
     33 include_directories("compat")
     34 
     35 # Ansilove library
     36 find_path(ANSILOVE_INCLUDE_DIRS ansilove.h)
     37 find_library(ANSILOVE_LIBRARIES NAMES ansilove REQUIRED)
     38 include_directories(${ANSILOVE_INCLUDE_DIRS})
     39 
     40 set(SRC src/ansilove.c src/types.c src/strtolower.c src/sauce.c)
     41 
     42 if(NOT HAVE_PLEDGE)
     43   set(SRC ${SRC} compat/pledge.c)
     44 endif()
     45 
     46 if(NOT HAVE_STRTONUM)
     47   set(SRC ${SRC} compat/strtonum.c)
     48 endif()
     49 
     50 add_definitions(-D_GNU_SOURCE -Wall -Wextra -pedantic)
     51 add_executable(ansilove ${SRC})
     52 
     53 target_link_libraries(ansilove ${ANSILOVE_LIBRARIES})
     54 
     55 install(TARGETS ansilove DESTINATION ${CMAKE_INSTALL_BINDIR})
     56 install(FILES ansilove.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
     57 
     58 enable_testing()
     59 add_test(ansilove ansilove)
     60 add_test(ansi ansilove ${PROJECT_SOURCE_DIR}/tests/bs-alove.ans)
     61 add_test(artworx ansilove ${PROJECT_SOURCE_DIR}/tests/bs-alove.adf)
     62 add_test(bin ansilove -c 80 ${PROJECT_SOURCE_DIR}/tests/bs-alove.bin)
     63 add_test(pcboard ansilove ${PROJECT_SOURCE_DIR}/tests/bs-alove.pcb)
     64 add_test(tundra ansilove ${PROJECT_SOURCE_DIR}/tests/bs-alove.tnd)
     65 add_test(xbin ansilove ${PROJECT_SOURCE_DIR}/tests/bs-alove.xb)
     66 add_test(retina ansilove -r ${PROJECT_SOURCE_DIR}/tests/bs-alove.ans)
     67 add_test(sauce ansilove -s ${PROJECT_SOURCE_DIR}/tests/sauce.txt)