1
+ # https://github.com/fo-fo/cc65-toolchain-example
2
+
3
+ # CMake toolchain file for cc65
4
+ # This is largely a result of experimentation, so some things may be done
5
+ # suboptimally/wrong. Some compilation options/CMake features may not work.
6
+ # Some generators will also not work (like MSVS). Ninja has been tested to work.
7
+ # What is supported: C, assembly, static libraries
8
+
9
+ set ( CMAKE_SYSTEM_NAME Generic )
10
+
11
+ macro ( __compilerCc65 lang )
12
+ set ( CMAKE_${lang} _COMPILER cl65 CACHE PATH "${lang} compiler" )
13
+ set ( CMAKE_${lang} _COMPILER_ID cc65 )
14
+
15
+ # We cannot run tests for the cc65 compiler, because of cross-compilation,
16
+ # so force the compiler tests to passed.
17
+ set ( CMAKE_${lang} _COMPILER_ID_RUN TRUE )
18
+ # Don't know if these are necessary.
19
+ set ( CMAKE_${lang} _COMPILER_ID_WORKS TRUE )
20
+ set ( CMAKE_${lang} _COMPILER_ID_FORCED TRUE )
21
+
22
+ set ( CMAKE_DEPFILE_FLAGS_${lang} "--create-dep <DEPFILE>" )
23
+ set ( CMAKE_${lang} _VERBOSE_FLAG "-v" )
24
+ set ( CMAKE_${lang} _FLAGS_DEBUG_INIT "-g -D DEBUG --asm-define DEBUG" )
25
+ endmacro ()
26
+
27
+ __compilerCc65( C )
28
+ __compilerCc65( ASM )
29
+
30
+ set ( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm )
31
+
32
+ # Not sure why CMake by default looks for the compilers, but not the archiver.
33
+ # Force it to try to find the archiver.
34
+ find_program ( CMAKE_AR ar65 )
35
+
36
+ # \note Need to delete the old file first because ar65 can only add files
37
+ # into an archive (or remove named files, but we don't know the names).
38
+ set ( CMAKE_C_CREATE_STATIC_LIBRARY
39
+ "<CMAKE_COMMAND> -E remove <TARGET> "
40
+ "<CMAKE_AR> a <TARGET> <LINK_FLAGS> <OBJECTS>"
41
+ )
42
+ set ( CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY} )
0 commit comments