58
|
1 cmake_minimum_required(VERSION 3.8)
|
59
|
2 set(CMAKE_C_COMPILER "/usr/bin/cc")
|
58
|
3 project(usr C ASM)
|
|
4
|
|
5
|
|
6 set(CMAKE_C_FLAGS_DEBUG "-O0")
|
|
7 add_definitions(${PMAKE_ARGS})
|
|
8 set(CMAKE_C_COMPILER "${CBC_COM}")
|
|
9
|
|
10 include_directories("..")
|
|
11
|
|
12 macro( GearsCommand )
|
|
13 set( _OPTIONS_ARGS )
|
|
14 set( _ONE_VALUE_ARGS TARGET )
|
|
15 set( _MULTI_VALUE_ARGS SOURCES )
|
|
16 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
|
|
17
|
|
18 set (_Gears_CBC_SOURCES)
|
|
19 set (_Gears_CSOURCES)
|
|
20 foreach(i ${_Gears_SOURCES})
|
|
21 if (${i} MATCHES "\\.cbc")
|
|
22 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
|
|
23 add_custom_command (
|
|
24 OUTPUT ${j}
|
|
25 DEPENDS ${i}
|
|
26 COMMAND "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i}
|
|
27 )
|
|
28 list(APPEND _Gears_CBC_SOURCES ${j})
|
|
29 elseif (${i} MATCHES "\\.cu")
|
|
30 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
|
|
31 add_custom_command (
|
|
32 OUTPUT ${j}
|
|
33 DEPENDS ${i}
|
|
34 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
|
|
35 )
|
|
36 list(APPEND _Gears_CBC_SOURCES ${j})
|
|
37 else()
|
|
38 set(j ${i})
|
|
39 list(APPEND _Gears_CSOURCES ${j})
|
|
40 endif()
|
|
41 endforeach(i)
|
|
42
|
|
43 add_custom_command (
|
|
44 OUTPUT c/${_Gears_TARGET}-context.c
|
|
45 DEPENDS ${_Gears_CBC_SOURCES}
|
|
46 COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
|
|
47 )
|
|
48 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
|
|
49 target_link_libraries(${_Gears_TARGET} ulib)
|
|
50 endmacro()
|
|
51
|
59
|
52 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c)
|
58
|
53
|
59
|
54 set(USRCOMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello)
|
58
|
55
|
59
|
56 foreach(cmd ${USR_COMMANDS})
|
|
57 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c)
|
|
58 endforeach(cmd)
|
58
|
59
|
|
60 add_custom_command(OUTPUT fs.img
|
|
61 COMMAND ./mkfs fs.img ${USR_COMMAND} UNIX
|
|
62 DEPENDS ${USR_COMMANDS}
|
|
63 )
|
|
64
|