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