-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
89 lines (74 loc) · 2.63 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
cmake_minimum_required(VERSION 2.8)
project(libtermbox C)
option(WITH_TRUECOLOR "Enable true-color support" 0)
option(BUILD_DEMOS "Build demos" 1)
option(BUILD_SHARED_LIBS "Build Shared Library (OFF for static-only)" ON)
include(cmake/add_cflag_if_supported.cmake)
add_cflag_if_supported("-std=gnu99")
add_cflag_if_supported("-Wall")
add_cflag_if_supported("-Wextra")
# Must nog have errors
add_cflag_if_supported("-Werror")
# Source fortification
add_cflag_if_supported("-D_FORTIFY_SOURCE=2")
add_cflag_if_supported("-fstrict-aliasing=1")
add_cflag_if_supported("-Wl,-z,relro")
add_cflag_if_supported("-Wl,-z,now")
add_cflag_if_supported("-fPIC")
# Extra warnings
add_cflag_if_supported("-Wshadow")
add_cflag_if_supported("-Wformat")
add_cflag_if_supported("-Wformat-security")
add_cflag_if_supported("-Wno-sign-conversion")
add_cflag_if_supported("-Wno-type-limits")
add_cflag_if_supported("-Wno-format-truncation")
#add_cflag_if_supported("-Wconversion")
add_cflag_if_supported("-Wmisleading-indentation")
add_cflag_if_supported("-Wno-float-conversion")
add_cflag_if_supported("-Wmaybe-uninitialized")
#add_cflag_if_supported("-Wmissing-variable-declarations")
#add_cflag_if_supported("-Wshorten-64-to-32")
add_cflag_if_supported("-Wimplicit-function-declaration")
add_cflag_if_supported("-Wredundant-decls")
add_cflag_if_supported("-Wundef")
add_cflag_if_supported("-Wswitch")
add_cflag_if_supported("-Wfloat-equal")
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
add_cflag_if_supported("-Og")
add_cflag_if_supported("-g")
else()
add_cflag_if_supported("-O3")
endif()
add_definitions(-D_XOPEN_SOURCE)
set(SRC src/termbox.c src/utf8.c)
#include_directories(src)
add_library(${PROJECT_NAME}-static STATIC ${SRC})
set_target_properties(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME ${PROJECT_NAME} PREFIX "")
if (BUILD_DEMOS)
file(GLOB DEMOS demos/*.c)
foreach(DEMO ${DEMOS})
MESSAGE("----> Adding demo ${DEMO}")
get_filename_component(DEMOEXE ${DEMO} NAME_WE)
add_executable(${DEMOEXE} ${DEMO})
add_dependencies(${DEMOEXE} ${PROJECT_NAME}-static)
target_link_libraries(${DEMOEXE} ${PROJECT_NAME}-static rt)
if(${DEMO} MATCHES "dirmenu.c") # this demo requires pthread
target_link_libraries(${DEMOEXE} pthread)
endif()
endforeach()
endif()
if (BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME}-shared SHARED ${SRC})
set_target_properties(${PROJECT_NAME}-shared PROPERTIES OUTPUT_NAME ${PROJECT_NAME} PREFIX "")
install(TARGETS ${PROJECT_NAME}-shared
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif()
install(TARGETS ${PROJECT_NAME}-static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(FILES src/termbox.h
DESTINATION include
)