/
CMakeLists.txt
37 lines (26 loc) · 987 Bytes
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cmake_minimum_required (VERSION 2.6)
project (ansilove C)
include(CheckFunctionExists)
include(GNUInstallDirs)
# Check if system has pledge and strtonum
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_OPENBSD_SOURCE)
check_function_exists(pledge HAVE_PLEDGE)
check_function_exists(strtonum HAVE_STRTONUM)
# Additional include directories for compat functions
include_directories("compat")
# Ansilove library
find_path(ANSILOVE_INCLUDE_DIRS ansilove.h)
find_library(ANSILOVE_LIBRARIES NAMES ansilove REQUIRED)
include_directories(${ANSILOVE_INCLUDE_DIRS})
set(SRC src/main.c src/strtolower.c src/sauce.c)
if(NOT HAVE_PLEDGE)
set (SRC ${SRC} compat/pledge.c)
endif()
if(NOT HAVE_STRTONUM)
set (SRC ${SRC} compat/strtonum.c)
endif()
add_definitions(-Wall -Wextra -std=c99 -pedantic)
add_executable(ansilove ${SRC})
target_link_libraries(ansilove ${ANSILOVE_LIBRARIES} m)
install(TARGETS ansilove DESTINATION bin)
install(FILES ansilove.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)