Mercurial > hg > CbC > CbC_xv6
annotate src/CMakeLists.txt @ 395:17e8a4bc06a7 default tip
add macOS AR/RANLIB
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 14 Dec 2020 21:59:50 +0900 |
parents | 72c38f531ae2 |
children |
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 |
10 set(USE_CUDA,0) | |
11 # -DUSE_CUDA | |
12 # add_definitions("-Wall -g -O") | |
13 | |
14 # -DCMAKE_BUILD_TYPE=Debug | |
15 set(CMAKE_C_FLAGS_DEBUG "-O0") | |
58 | 16 add_definitions(${PMAKE_ARGS}) |
17 | |
18 #add_custom_command(OUTPUT tools | |
19 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run" | |
20 #) | |
21 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools | |
22 | |
42 | 23 |
24 if (${USE_CUDA}) | |
25 include_directories("/usr/local/cuda/include") | |
86 | 26 #include_directories(${CMAKE_SOURCE_DIR}) |
42 | 27 set(NVCCFLAG "-std=c++11" "-g" "-O0" ) |
28 if (UNIX AND NOT APPLE) # LINUX | |
29 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart") | |
30 elseif (APPLE) | |
31 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") | |
32 endif() | |
33 find_package(CUDA REQUIRED) | |
34 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) | |
35 endif() | |
36 | |
70 | 37 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}") |
61 | 38 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) |
42 | 39 |
40 macro( GearsCommand ) | |
66 | 41 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") |
61 | 42 set(CMAKE_C_COMPILER "${CBC_COM}") |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
43 set(CMAKE_ASM_COMPILER "${CBC_COM}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
44 |
61 | 45 set(CMAKE_LINKER "${X_CMAKE_LINKER}") |
46 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}") | |
42 | 47 set( _OPTIONS_ARGS ) |
48 set( _ONE_VALUE_ARGS TARGET ) | |
49 set( _MULTI_VALUE_ARGS SOURCES ) | |
50 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
|
51 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
|
52 set(CMAKE_KERNEL_DIR_C "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir") |
42 | 53 |
43 | 54 set (_Gears_CBC_SOURCES) |
42 | 55 set (_Gears_CSOURCES) |
56 foreach(i ${_Gears_SOURCES}) | |
57 if (${i} MATCHES "\\.cbc") | |
58 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
59 add_custom_command ( | |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
60 OUTPUT ${CMAKE_KERNEL_DIR_C}/${j} |
42 | 61 DEPENDS ${i} |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
323
diff
changeset
|
62 COMMAND "cd" "${CMAKE_KERNEL_DIR_C}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "--project" "xv6" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i} |
42 | 63 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
64 list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_DIR_C}/${j}") |
70 | 65 #list(APPEND _Gears_CBC_SOURCES ${j}) |
42 | 66 elseif (${i} MATCHES "\\.cu") |
67 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) | |
68 add_custom_command ( | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
69 OUTPUT ${CMAKE_KERNEL_DIR}/${j} |
42 | 70 DEPENDS ${i} |
71 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} | |
72 ) | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
73 list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j}) |
42 | 74 else() |
75 set(j ${i}) | |
73 | 76 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}") |
43 | 77 list(APPEND _Gears_CSOURCES ${j}) |
42 | 78 endif() |
79 endforeach(i) | |
80 | |
61 | 81 #target_link_libraries(syslib) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
82 file(COPY "${CMAKE_SOURCE_DIR}/interface/" DESTINATION ${CMAKE_KERNEL_DIR_C}) |
87 | 83 file(GLOB XV6_HEADERS "${CMAKE_SOURCE_DIR}/*.h") |
84 file(COPY ${XV6_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C}) | |
193 | 85 file(GLOB XV6_IMPL_HEADERS "${CMAKE_SOURCE_DIR}/impl/*.h") |
86 file(COPY ${XV6_IMPL_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C}) | |
87 | 87 include_directories(${CMAKE_KERNEL_DIR_C}) |
42 | 88 add_custom_command ( |
86 | 89 OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c |
66 | 90 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode |
354
fde5f96c6ff1
use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
323
diff
changeset
|
91 COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "--project" "xv6" "-o" ${_Gears_TARGET} "-w" ${_Gears_CBC_SOURCES} |
42 | 92 ) |
84
a4307abefd0b
include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents:
83
diff
changeset
|
93 # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c ) |
86 | 94 file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}") |
95 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c ) | |
53 | 96 # target_link_libraries(${_Gears_TARGET} m pthread) |
42 | 97 endmacro() |
98 | |
66 | 99 |
100 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") | |
101 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") | |
70 | 102 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S) |
103 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir") | |
66 | 104 add_custom_command( |
70 | 105 OUTPUT "initcode" |
66 | 106 DEPENDS initcode.o |
107 | 107 COMMAND "${XV6_OBJCOPY}" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode" |
66 | 108 ) |
70 | 109 #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
|
110 file(COPY "${CMAKE_SOURCE_DIR}/debug.sh" "${CMAKE_SOURCE_DIR}/run-debug.sh" "${CMAKE_SOURCE_DIR}/connect.gdb" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
70 | 111 |
42 | 112 |
53 | 113 GearsCommand ( |
42 | 114 TARGET |
115 kernel | |
116 SOURCES | |
367 | 117 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 |
118 start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.cbc vm.c device/picirq.c device/timer.c device/uart.c | |
389 | 119 SingleLinkedStack.cbc entry.S |
120 impl/KernelRetImpl.cbc impl/KernelError.cbc impl/SyscallDispatchImpl.cbc impl/CbCProcImpl.cbc init_kernel_context.cbc impl/ReadSyscallImpl.cbc impl/ReadSyscallEntry.cbc | |
42 | 121 ) |
149 | 122 |
154 | 123 # sys_read_impl.cbc |