42
|
1 cmake_minimum_required(VERSION 3.8)
|
43
|
2 project(xv6cbc C ASM)
|
42
|
3
|
55
|
4
|
42
|
5 set(USE_CUDA,0)
|
|
6 # -DUSE_CUDA
|
|
7 # add_definitions("-Wall -g -O")
|
|
8
|
|
9 # -DCMAKE_BUILD_TYPE=Debug
|
|
10 set(CMAKE_C_FLAGS_DEBUG "-O0")
|
58
|
11 add_definitions(${PMAKE_ARGS})
|
|
12 set(CMAKE_C_COMPILER "${CBC_COM}")
|
|
13
|
|
14 #add_custom_command(OUTPUT tools
|
|
15 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run"
|
|
16 #)
|
|
17 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools
|
|
18 add_subdirectory(tools)
|
|
19 add_subdirectory(usr)
|
|
20
|
42
|
21
|
|
22 if (${USE_CUDA})
|
|
23 include_directories("/usr/local/cuda/include")
|
|
24 set(NVCCFLAG "-std=c++11" "-g" "-O0" )
|
|
25 if (UNIX AND NOT APPLE) # LINUX
|
|
26 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
|
|
27 elseif (APPLE)
|
|
28 set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /usr/local/cuda/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib")
|
|
29 endif()
|
|
30 find_package(CUDA REQUIRED)
|
|
31 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
|
|
32 endif()
|
|
33
|
|
34 include_directories(".")
|
|
35
|
|
36 macro( GearsCommand )
|
|
37 set( _OPTIONS_ARGS )
|
|
38 set( _ONE_VALUE_ARGS TARGET )
|
|
39 set( _MULTI_VALUE_ARGS SOURCES )
|
|
40 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
|
|
41
|
43
|
42 set (_Gears_CBC_SOURCES)
|
42
|
43 set (_Gears_CSOURCES)
|
|
44 foreach(i ${_Gears_SOURCES})
|
|
45 if (${i} MATCHES "\\.cbc")
|
|
46 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
|
|
47 add_custom_command (
|
|
48 OUTPUT ${j}
|
|
49 DEPENDS ${i}
|
|
50 COMMAND "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i}
|
|
51 )
|
43
|
52 list(APPEND _Gears_CBC_SOURCES ${j})
|
42
|
53 elseif (${i} MATCHES "\\.cu")
|
|
54 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
|
|
55 add_custom_command (
|
|
56 OUTPUT ${j}
|
|
57 DEPENDS ${i}
|
|
58 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
|
|
59 )
|
43
|
60 list(APPEND _Gears_CBC_SOURCES ${j})
|
42
|
61 else()
|
|
62 set(j ${i})
|
43
|
63 list(APPEND _Gears_CSOURCES ${j})
|
42
|
64 endif()
|
|
65 endforeach(i)
|
|
66
|
|
67 add_custom_command (
|
|
68 OUTPUT c/${_Gears_TARGET}-context.c
|
43
|
69 DEPENDS ${_Gears_CBC_SOURCES}
|
|
70 COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
|
42
|
71 )
|
53
|
72 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
|
|
73 # target_link_libraries(${_Gears_TARGET} m pthread)
|
42
|
74 endmacro()
|
|
75
|
|
76
|
53
|
77 GearsCommand (
|
42
|
78 TARGET
|
|
79 kernel
|
|
80 SOURCES
|
52
|
81 lib/string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc
|
|
82 start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c
|
54
|
83 lib/string.c entry.S
|
42
|
84 )
|
|
85
|