-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
79 lines (78 loc) · 2.92 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
cmake_minimum_required(VERSION 3.24)
project(efi_wrapper C)
add_definitions(-Werror=stack-usage=12288 -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast)
add_definitions(-Wno-unused-function -fshort-wchar -D_GNU_SOURCE)
list(APPEND DEFAULT_C_FLAGS "-rdynamic" "-fstack-protector-all")
set(CMAKE_C_STANDARD 11)
find_package(PkgConfig REQUIRED)
include_directories(include ${CMAKE_CURRENT_BINARY_DIR})
option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
option(ENABLE_WERROR "Treat all warnings as fatal errors" ON)
option(ENABLE_SDL2 "Enable SDL2 for GraphicsOutput" AUTO)
option(ENABLE_VNCSERVER "Enable vncserver for GraphicsOutput" AUTO)
option(ENABLE_LIBELF "Enable libelf for elf debug symbol tables" AUTO)
option(ENABLE_LIBDW "Enable libdw for elf debug line numbers" AUTO)
if(ENABLE_WERROR)
add_definitions(-Wall -Wextra -Werror)
endif()
if("${ENABLE_ASAN}" STREQUAL "ON")
list(APPEND DEFAULT_C_FLAGS
"-fsanitize=address" "-fsanitize=undefined" "-fsanitize=leak"
"-fsanitize-recover=all" "-fno-omit-frame-pointer" "-fsanitize=leak"
)
endif()
if(ENABLE_SDL2 STREQUAL "AUTO")
pkg_check_modules(SDL2 IMPORTED_TARGET sdl2)
elseif(ENABLE_SDL2 STREQUAL "ON")
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
endif()
if(ENABLE_LIBELF STREQUAL "AUTO")
pkg_check_modules(ELF IMPORTED_TARGET libelf)
elseif(ENABLE_LIBELF STREQUAL "ON")
pkg_check_modules(ELF REQUIRED IMPORTED_TARGET libelf)
endif()
if(ENABLE_LIBDW STREQUAL "AUTO")
pkg_check_modules(LIBDW IMPORTED_TARGET libdw)
elseif(ENABLE_LIBDW STREQUAL "ON")
pkg_check_modules(LIBDW REQUIRED IMPORTED_TARGET libdw)
endif()
if(ENABLE_VNCSERVER STREQUAL "AUTO")
pkg_check_modules(VNCSERVER IMPORTED_TARGET libvncserver)
elseif(ENABLE_VNCSERVER STREQUAL "ON")
pkg_check_modules(VNCSERVER REQUIRED IMPORTED_TARGET libvncserver)
endif()
if(SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIRS})
endif()
if(ELF_FOUND)
include_directories(${ELF_INCLUDE_DIRS})
endif()
if(DWFL_FOUND)
include_directories(${DWFL_INCLUDE_DIRS})
endif()
if(VNCSERVER_FOUND)
include_directories(${VNCSERVER_INCLUDE_DIRS})
endif()
configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h")
add_subdirectory(lib)
add_executable(efi_wrapper efi-wrapper/main.c)
target_compile_options(efi_wrapper PRIVATE ${DEFAULT_C_FLAGS})
target_link_options(efi_wrapper PRIVATE ${DEFAULT_C_FLAGS})
target_link_libraries(efi_wrapper -Wl,--start-group -Wl,--whole-archive)
add_subdirectory(efi-wrapper)
target_link_libraries(efi_wrapper global_lib)
target_link_libraries(efi_wrapper -Wl,--no-whole-archive)
add_subdirectory(libs)
if(SDL2_FOUND)
target_link_libraries(efi_wrapper ${SDL2_LIBRARIES})
endif()
if(ELF_FOUND)
target_link_libraries(efi_wrapper ${ELF_LIBRARIES})
endif()
if(DWFL_FOUND)
target_link_libraries(efi_wrapper ${DWFL_LIBRARIES})
endif()
if(VNCSERVER_FOUND)
target_link_libraries(efi_wrapper ${VNCSERVER_LIBRARIES})
endif()
target_link_libraries(efi_wrapper -Wl,--end-group)