forked from MEGA65/mega65-libc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (46 loc) · 1.93 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
cmake_minimum_required(VERSION 3.5)
set(LLVM_MOS_PLATFORM mega65)
find_package(llvm-mos-sdk REQUIRED)
project(mega65libc VERSION 1.0.0 LANGUAGES C ASM)
# all source and header files
set(assembler src/fileio.s src/dirent.s)
set(objects src/conio.c src/debug.c src/fat32.c src/hal.c src/memory.c src/mouse.c
src/random.c src/sdcard.c src/targets.c src/tests.c src/time.c)
set(headers include/conio.h include/debug.h include/hal.h include/memory.h include/random.h
include/sdcard.h include/targets.h include/tests.h include/time.h include/fileio.h include/dirent.h)
set_source_files_properties(${objects} PROPERTIES LANGUAGE C)
set_source_files_properties(${assembler} PROPERTIES LANGUAGE ASM)
set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON)
# mega65libc target
add_library(mega65libc ${objects} ${headers} ${assembler})
target_include_directories(mega65libc
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
set_target_properties(mega65libc PROPERTIES PUBLIC_HEADER "${headers}")
target_compile_options(mega65libc PRIVATE -mcpu=mos65c02 -Os -Wall -Wextra -Wshadow -Wconversion -Wno-language-extension-token)
# install target
include(GNUInstallDirs)
install(TARGETS mega65libc
EXPORT mega65libc-export
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION include
)
install(FILES cmake/mega65libcConfig.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mega65libc)
# export mega65libc
install(EXPORT mega65libc-export
FILE
mega65libcTargets.cmake
NAMESPACE
mega65libc::
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/mega65libc
)
# compile example prg file
add_executable(example src/example.c)
target_link_libraries(example mega65libc)
set_target_properties(example PROPERTIES OUTPUT_NAME example.prg EXCLUDE_FROM_ALL true)