forked from mtorromeo/gmenu2x
-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
124 lines (99 loc) · 3.74 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
cmake_minimum_required(VERSION 3.4)
project(gmenu2x LANGUAGES CXX VERSION 1.0)
include(GNUInstallDirs)
include(FindPackageHandleStandardArgs)
option(CPUFREQ "Enable CPU frequency control" OFF)
if (CPUFREQ)
add_compile_definitions(ENABLE_CPUFREQ)
endif(CPUFREQ)
option(CLOCK "Display current time at the bottom of the screen" ON)
if (CLOCK)
add_compile_definitions(ENABLE_CLOCK)
endif (CLOCK)
option(BIND_CONSOLE "Support for binding/unbinding terminal" OFF)
if (BIND_CONSOLE)
add_compile_definitions(BIND_CONSOLE)
endif (BIND_CONSOLE)
option(WINDOWED_MODE "Run windowed" OFF)
if (WINDOWED_MODE)
add_compile_definitions(G2X_BUILD_OPTION_WINDOWED_MODE)
endif ()
set(SCREEN_WIDTH "" CACHE STRING "Screen / window width (empty: max available)")
if (SCREEN_WIDTH)
add_compile_definitions(G2X_BUILD_OPTION_SCREEN_WIDTH=${SCREEN_WIDTH})
endif ()
set(SCREEN_HEIGHT "" CACHE STRING "Screen / window height (empty: max available)")
if (SCREEN_HEIGHT)
add_compile_definitions(G2X_BUILD_OPTION_SCREEN_HEIGHT=${SCREEN_HEIGHT})
endif ()
set(DEFAULT_FALLBACK_FONTS "" CACHE STRING "A list of fallback font paths")
if(DEFAULT_FALLBACK_FONTS)
add_compile_definitions(DEFAULT_FALLBACK_FONTS=${DEFAULT_FALLBACK_FONTS})
endif ()
set(CARD_ROOT "/media" CACHE STRING "Top-level filesystem directory")
find_package(SDL REQUIRED)
find_package(SDL_ttf REQUIRED)
find_package(PNG REQUIRED)
find_library(LIBSDL_GFX_LIBRARY SDL_gfx)
find_path(LIBSDL_GFX_INCLUDE_DIR SDL_gfxPrimitives.h ${SDL_INCLUDE_DIR})
find_package_handle_standard_args(libSDL_gfx DEFAULT_MSG
LIBSDL_GFX_LIBRARY LIBSDL_GFX_INCLUDE_DIR)
if(LIBSDL_GFX_FOUND)
set(LIBSDL_GFX_LIBRARIES ${LIBSDL_GFX_LIBRARY})
set(LIBSDL_GFX_INCLUDE_DIRS ${LIBSDL_GFX_INCLUDE_DIR})
else()
message(FATAL_ERROR "Unable to find SDL_gfx")
endif(LIBSDL_GFX_FOUND)
find_library(LIBOPK_LIBRARY opk)
find_path(LIBOPK_INCLUDE_DIR opk.h /usr/include)
find_package_handle_standard_args(libopk DEFAULT_MSG
LIBOPK_LIBRARY LIBOPK_INCLUDE_DIR)
if(LIBOPK_FOUND)
set(LIBOPK_LIBRARIES ${LIBOPK_LIBRARY})
set(LIBOPK_INCLUDE_DIRS ${LIBOPK_INCLUDE_DIR})
add_compile_definitions(HAVE_LIBOPK)
option(INOTIFY "Monitor OPK folder with inotify" ON)
if (INOTIFY)
add_compile_definitions(ENABLE_INOTIFY)
endif (INOTIFY)
endif(LIBOPK_FOUND)
find_library(LIBXDGMIME_LIBRARY xdgmime)
find_path(LIBXDGMIME_INCLUDE_DIR xdgmime.h /usr/include)
find_package_handle_standard_args(libxdgmime DEFAULT_MSG
LIBXDGMIME_LIBRARY LIBXDGMIME_INCLUDE_DIR)
if (LIBXDGMIME_FOUND)
set(LIBXDGMIME_LIBRARIES ${LIBXDGMIME_LIBRARY})
set(LIBXDGMIME_INCLUDE_DIRS ${LIBXDGMIME_INCLUDE_DIR})
add_compile_definitions(HAVE_LIBXDGMIME)
endif(LIBXDGMIME_FOUND)
file(GLOB OBJS src/*.cpp)
add_executable(${PROJECT_NAME} ${OBJS})
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${SDL_LIBRARY}
${SDL_TTF_LIBRARIES}
${LIBSDL_GFX_LIBRARIES}
${PNG_LIBRARIES}
${LIBOPK_LIBRARIES}
${LIBXDGMIME_LIBRARIES}
stdc++fs
)
target_include_directories(${PROJECT_NAME} PRIVATE
${SDL_INCLUDE_DIR}
${SDL_TTF_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
${LIBOPK_INCLUDE_DIRS}
${LIBXDGMIME_INCLUDE_DIRS}
${LIBSDL_GFX_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<CONFIG:Debug>:-fsanitize=undefined;-fsanitize=address;-fsanitize-recover=address>")
target_link_libraries(${PROJECT_NAME} PUBLIC "$<$<CONFIG:Debug>:-fsanitize=undefined;-fsanitize=address;-fsanitize-recover=address>")
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY data/ DESTINATION ${CMAKE_INSTALL_DATADIR}/gmenu2x)
configure_file(buildopts.h.cmakein ${CMAKE_BINARY_DIR}/buildopts.h @ONLY)