Mercurial > hg > Members > menikon > CbC_xv6
annotate src/CMakeLists.txt @ 265:f9169495d476
order log calc
author | tobaru |
---|---|
date | Sun, 26 Jan 2020 18:20:40 +0900 |
parents | 1301727600cc |
children | 08cd784ddbc0 cd9092628a63 |
rev | line source |
---|---|
42 | 1 cmake_minimum_required(VERSION 3.8) |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
2 project(xv6cbc NONE) |
62 | 3 set(BUILD_DIR ${PROJECT_BINARY_DIR}) |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
4 |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
5 |
59 | 6 add_subdirectory(tools) |
61 | 7 add_subdirectory(usr) |
66 | 8 enable_language(C ASM) |
42 | 9 |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
10 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
11 set(CMAKE_SYSROOT "${CBC_XV6_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
12 set(CMAKE_OSX_SYSROOT "${CBC_XV6_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
13 include_directories("${CMAKE_OSX_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
14 include_directories("${CMAKE_OSX_SYSROOT}/usr/include") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
15 include_directories("${CMAKE_OSX_SYSROOT}/usr/include/arm-linux-gnueabihf") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
16 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
17 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
18 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
19 set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
20 endif() |
55 | 21 |
42 | 22 set(USE_CUDA,0) |
23 # -DUSE_CUDA | |
24 # add_definitions("-Wall -g -O") | |
25 | |
26 # -DCMAKE_BUILD_TYPE=Debug | |
27 set(CMAKE_C_FLAGS_DEBUG "-O0") | |
58 | 28 add_definitions(${PMAKE_ARGS}) |
29 | |
30 #add_custom_command(OUTPUT tools | |
31 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run" | |
32 #) | |
33 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools | |
34 | |
42 | 35 |
36 if (${USE_CUDA}) | |
37 include_directories("/usr/local/cuda/include") | |
86 | 38 #include_directories(${CMAKE_SOURCE_DIR}) |
42 | 39 set(NVCCFLAG "-std=c++11" "-g" "-O0" ) |
40 if (UNIX AND NOT APPLE) # LINUX | |
41 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart") | |
42 elseif (APPLE) | |
43 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") | |
44 endif() | |
45 find_package(CUDA REQUIRED) | |
46 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) | |
47 endif() | |
48 | |
70 | 49 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}") |
61 | 50 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) |
42 | 51 |
52 macro( GearsCommand ) | |
66 | 53 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") |
61 | 54 set(CMAKE_C_COMPILER "${CBC_COM}") |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
55 set(CMAKE_ASM_COMPILER "${CBC_COM}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
56 |
61 | 57 set(CMAKE_LINKER "${X_CMAKE_LINKER}") |
58 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}") | |
42 | 59 set( _OPTIONS_ARGS ) |
60 set( _ONE_VALUE_ARGS TARGET ) | |
61 set( _MULTI_VALUE_ARGS SOURCES ) | |
62 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
63 set(CMAKE_KERNEL_DIR "${CMAKE_BINARY_DIR}") |
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
64 set(CMAKE_KERNEL_DIR_C "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir") |
42 | 65 |
43 | 66 set (_Gears_CBC_SOURCES) |
42 | 67 set (_Gears_CSOURCES) |
68 foreach(i ${_Gears_SOURCES}) | |
69 if (${i} MATCHES "\\.cbc") | |
70 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
71 add_custom_command ( | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
72 OUTPUT ${CMAKE_KERNEL_DIR_C}/${j} |
42 | 73 DEPENDS ${i} |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
74 COMMAND "cd" "${CMAKE_KERNEL_DIR_C}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i} |
42 | 75 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
76 list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_DIR_C}/${j}") |
70 | 77 #list(APPEND _Gears_CBC_SOURCES ${j}) |
42 | 78 elseif (${i} MATCHES "\\.cu") |
79 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) | |
80 add_custom_command ( | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
81 OUTPUT ${CMAKE_KERNEL_DIR}/${j} |
42 | 82 DEPENDS ${i} |
83 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} | |
84 ) | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
85 list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j}) |
42 | 86 else() |
87 set(j ${i}) | |
73 | 88 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}") |
43 | 89 list(APPEND _Gears_CSOURCES ${j}) |
42 | 90 endif() |
91 endforeach(i) | |
92 | |
61 | 93 #target_link_libraries(syslib) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
94 file(COPY "${CMAKE_SOURCE_DIR}/interface/" DESTINATION ${CMAKE_KERNEL_DIR_C}) |
87 | 95 file(GLOB XV6_HEADERS "${CMAKE_SOURCE_DIR}/*.h") |
96 file(COPY ${XV6_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C}) | |
200 | 97 file(GLOB XV6_IMPL_HEADERS "${CMAKE_SOURCE_DIR}/impl/*.h") |
98 file(COPY ${XV6_IMPL_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C}) | |
87 | 99 include_directories(${CMAKE_KERNEL_DIR_C}) |
42 | 100 add_custom_command ( |
86 | 101 OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c |
66 | 102 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
107
diff
changeset
|
103 COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${_Gears_CBC_SOURCES} |
42 | 104 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
105 # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c ) |
86 | 106 file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}") |
107 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c ) | |
53 | 108 # target_link_libraries(${_Gears_TARGET} m pthread) |
42 | 109 endmacro() |
110 | |
66 | 111 |
112 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") | |
113 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") | |
70 | 114 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S) |
115 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir") | |
66 | 116 add_custom_command( |
70 | 117 OUTPUT "initcode" |
66 | 118 DEPENDS initcode.o |
107 | 119 COMMAND "${XV6_OBJCOPY}" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode" |
66 | 120 ) |
70 | 121 #file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
126
99be03babde3
copy debug scripts from cmake sources
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
111
diff
changeset
|
122 file(COPY "${CMAKE_SOURCE_DIR}/debug.sh" "${CMAKE_SOURCE_DIR}/run-debug.sh" "${CMAKE_SOURCE_DIR}/connect.gdb" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
70 | 123 |
42 | 124 |
53 | 125 GearsCommand ( |
42 | 126 TARGET |
127 kernel | |
128 SOURCES | |
61 | 129 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 |
132 | 130 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 |
200 | 131 SingleLinkedStack.cbc entry.S impl/vm_impl.cbc impl/vm_impl_private.cbc |
42 | 132 ) |
149 | 133 |
154 | 134 # sys_read_impl.cbc |