CMakeLists.txt 1.79 KB
Newer Older
deuce's avatar
deuce committed
1
2
3
4
project (ConIOLib C)

cmake_minimum_required(VERSION 2.8.11)

deuce's avatar
deuce committed
5
INCLUDE(../build/SynchronetMacros.cmake)
deuce's avatar
deuce committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
22
	list(APPEND SOURCE win32cio.c ciolib.rc)
deuce's avatar
deuce committed
23
24
25
26
27
28
29
endif()

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

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

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

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

add_library(ciolib SHARED ${SOURCE})
deuce's avatar
deuce committed
53
require_lib(ciolib xpdev)
deuce's avatar
deuce committed
54
55
target_compile_definitions(ciolib PRIVATE CIOLIB_EXPORTS)
target_compile_definitions(ciolib INTERFACE CIOLIB_IMPORTS)
deuce's avatar
deuce committed
56
57

if(SDL_FOUND)
58
59
	target_include_directories(ciolib PRIVATE ${SDL_INCLUDE_DIR})
	target_compile_definitions(ciolib PUBLIC WITH_SDL)
deuce's avatar
deuce committed
60
61
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
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)