-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (60 loc) · 2.09 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
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0076 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CheckLanguage)
include(CheckTypeSize)
include(CMakePrintHelpers)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/M68kUnknownElfToolchain.cmake")
project("ehbc-firmware")
# Build Configurations
set(TARGET "m68k-proto1" CACHE STRING "Target name to build")
string(REPLACE "-" ";" TARGET ${TARGET})
list(GET TARGET 0 TARGET_ARCH)
list(GET TARGET 1 TARGET_BOARD)
enable_language(C ASM)
# Target Configurations
add_executable(firmware)
set_target_properties(firmware PROPERTIES SUFFIX ".elf")
# Compiler Tests
check_type_size("void*" VOIDPTR_SIZE)
if (${VOIDPTR_SIZE} GREATER 4)
set(MADDR_MSIZE_64BIT 1)
endif()
configure_file("config.h.in" "config.h")
# Dependencies
add_subdirectory(libehbcfw)
add_subdirectory(utils)
# Compile Options
target_compile_features(firmware PUBLIC c_std_11)
target_compile_features(firmware PUBLIC cxx_std_14)
target_compile_options(firmware PUBLIC
$<$<COMPILE_LANGUAGE:C,CXX>:
-Werror
-Wall
-Wno-unused-function
-Wno-unused-variable
-Wno-unused-but-set-variable
-pedantic
-pedantic-errors>)
target_link_libraries(firmware gcc)
target_link_libraries(firmware libehbcfw)
target_include_directories(firmware PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_include_directories(firmware PRIVATE "${CMAKE_SOURCE_DIR}/src")
target_include_directories(firmware PRIVATE "${CMAKE_BINARY_DIR}")
target_include_directories(firmware PUBLIC libehbcfw::libehbcfw)
# Subdirectories
add_subdirectory(arch)
add_subdirectory(src)
add_subdirectory(rsrc)
add_subdirectory(examples)
add_custom_target(rom_image ALL
COMMAND ${CMAKE_OBJCOPY} -O binary "$<TARGET_FILE:firmware>" firmware.bin
DEPENDS firmware
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Creating binary file")
add_custom_target(elfinfo
COMMAND ${CMAKE_OBJDUMP} -xdS "$<TARGET_FILE:firmware>" > firmware.objdump
DEPENDS firmware
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
COMMENT "Creating ELF analysis"
USES_TERMINAL)