CMakeLists.txt 1.99 KB
Newer Older
deuce's avatar
deuce committed
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
project (ConIOLib C)

cmake_minimum_required(VERSION 2.8.11)

INCLUDE (CheckFunctionExists)
INCLUDE (FindSDL)
INCLUDE (FindX11)
INCLUDE (FindCurses)
INCLUDE (FindThreads)

set(SOURCE
	ansi_cio.c
	ciolib.c
	cterm.c
	vidmodes.c
	allfonts.c
	mouse.c
)

if(WIN32)
	list(APPEND SOURCE SDL_win32_main.c win32cio.c ciolib_res.c)
endif()

if(CURSES_FOUND)
	list(APPEND SOURCE curs_cio.c)
endif()

if(X11_FOUND)
29
30
31
	list(APPEND SOURCE x_events.c x_cio.c)
	set(NEED_BITMAP TRUE)
	set(NEED_DLOPEN TRUE)
deuce's avatar
deuce committed
32
33
34
35
endif()

if(SDL_FOUND)
	list(APPEND SOURCE sdl_con.c)
36
37
38
	list(APPEND SOURCE sdlfuncs.c)
	if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
		list(APPEND SOURCE SDLMain.m)
deuce's avatar
deuce committed
39
	endif()
40
41
	set(NEED_BITMAP TRUE)
	set(NEED_DLOPEN TRUE)
deuce's avatar
deuce committed
42
43
44
45
46
47
48
endif()

if(NEED_BITMAP)
	list(APPEND SOURCE bitmap_con.c)
endif()

add_library(ciolib SHARED ${SOURCE})
49
50
51
52
53
if(NOT ${PARENT_DIRECTORY})
	find_package(XPDev REQUIRED)
	include(${XPDev_CONFIG})
endif()
add_dependencies(ciolib XPDev)
deuce's avatar
deuce committed
54
55
target_include_directories(ciolib PRIVATE "${XPDev_DIR}/../../../include/xpdev")
target_compile_definitions(ciolib PRIVATE $<TARGET_PROPERTY:xpdev,INTERFACE_COMPILE_DEFINITIONS>)
56
target_include_directories(ciolib PRIVATE $<TARGET_PROPERTY:xpdev,INTERFACE_INCLUDE_DIRECTORIES>)
deuce's avatar
deuce committed
57
58
59
target_link_libraries(ciolib xpdev)

if(SDL_FOUND)
60
61
	target_include_directories(ciolib PRIVATE ${SDL_INCLUDE_DIR})
	target_compile_definitions(ciolib PUBLIC WITH_SDL)
deuce's avatar
deuce committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
endif()

if(NOT WIN32)
	target_link_libraries(ciolib pthread)
endif()

if(CURSES_FOUND)
	if(CURSES_HAVE_NCURSES_H)
		target_compile_definitions(ciolib PRIVATE N_CURSES_LIB)
	endif()
	target_link_libraries(ciolib ${CURSES_LIBRARIES})
endif()

CHECK_FUNCTION_EXISTS(vasprintf HAVE_VASPRINTF) 
if(HAVE_VASPRINTF)
	target_compile_definitions(ciolib PRIVATE HAVE_VASPRINTF)
endif()

target_link_libraries(ciolib ${CMAKE_DL_LIBS})

set(INSTALL_HEADERS
	ciolib.h
	cterm.h
)

export(PACKAGE CIOLib)

install(TARGETS ciolib DESTINATION lib EXPORT CIOLibConfig)
install(FILES ${INSTALL_HEADERS} DESTINATION include)
install(EXPORT CIOLibConfig DESTINATION lib/cmake/CIOLib)