Mercurial > hg > CbC > CbC_xv6
annotate src/CMakeLists.txt @ 82:d419660ad71d
tweak generate_stub.pl
author | anatofuz |
---|---|
date | Fri, 11 Oct 2019 19:32:16 +0900 |
parents | c976a8bbe8c5 |
children | d4e22a45a575 |
rev | line source |
---|---|
42 | 1 cmake_minimum_required(VERSION 3.8) |
43 | 2 project(xv6cbc C ASM) |
62 | 3 set(BUILD_DIR ${PROJECT_BINARY_DIR}) |
59 | 4 add_subdirectory(tools) |
61 | 5 add_subdirectory(usr) |
66 | 6 enable_language(C ASM) |
42 | 7 |
55 | 8 |
42 | 9 set(USE_CUDA,0) |
10 # -DUSE_CUDA | |
11 # add_definitions("-Wall -g -O") | |
12 | |
13 # -DCMAKE_BUILD_TYPE=Debug | |
14 set(CMAKE_C_FLAGS_DEBUG "-O0") | |
58 | 15 add_definitions(${PMAKE_ARGS}) |
16 | |
17 #add_custom_command(OUTPUT tools | |
18 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run" | |
19 #) | |
20 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools | |
21 | |
42 | 22 |
23 if (${USE_CUDA}) | |
24 include_directories("/usr/local/cuda/include") | |
69 | 25 include_directories(${CMAKE_SOURCE_DIR}) |
42 | 26 set(NVCCFLAG "-std=c++11" "-g" "-O0" ) |
27 if (UNIX AND NOT APPLE) # LINUX | |
28 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart") | |
29 elseif (APPLE) | |
30 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") | |
31 endif() | |
32 find_package(CUDA REQUIRED) | |
33 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) | |
34 endif() | |
35 | |
70 | 36 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}") |
42 | 37 include_directories(".") |
82 | 38 include_directories(${CMAKE_SOURCE_DIR}) |
61 | 39 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) |
42 | 40 |
41 macro( GearsCommand ) | |
66 | 42 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") |
61 | 43 set(CMAKE_C_COMPILER "${CBC_COM}") |
44 set(CMAKE_LINKER "${X_CMAKE_LINKER}") | |
45 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}") | |
42 | 46 set( _OPTIONS_ARGS ) |
47 set( _ONE_VALUE_ARGS TARGET ) | |
48 set( _MULTI_VALUE_ARGS SOURCES ) | |
49 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
50 set(CMAKE_KERNEL_DIR "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir") |
42 | 51 |
43 | 52 set (_Gears_CBC_SOURCES) |
42 | 53 set (_Gears_CSOURCES) |
54 foreach(i ${_Gears_SOURCES}) | |
55 if (${i} MATCHES "\\.cbc") | |
56 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
57 add_custom_command ( | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
58 OUTPUT ${CMAKE_KERNEL_DIR}/${j} |
42 | 59 DEPENDS ${i} |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
60 COMMAND "cd" "${CMAKE_KERNEL_DIR}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i} |
42 | 61 ) |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
62 list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_DIR}/${j}") |
70 | 63 #list(APPEND _Gears_CBC_SOURCES ${j}) |
42 | 64 elseif (${i} MATCHES "\\.cu") |
65 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) | |
66 add_custom_command ( | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
67 OUTPUT ${CMAKE_KERNEL_DIR}/${j} |
42 | 68 DEPENDS ${i} |
69 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} | |
70 ) | |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
71 list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j}) |
42 | 72 else() |
73 set(j ${i}) | |
73 | 74 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}") |
43 | 75 list(APPEND _Gears_CSOURCES ${j}) |
42 | 76 endif() |
77 endforeach(i) | |
78 | |
61 | 79 #target_link_libraries(syslib) |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
80 file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_KERNEL_DIR}) |
42 | 81 add_custom_command ( |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
82 OUTPUT ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c |
66 | 83 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode |
73 | 84 COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES} |
42 | 85 ) |
74
10d09cd9fad3
set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents:
73
diff
changeset
|
86 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c ) |
53 | 87 # target_link_libraries(${_Gears_TARGET} m pthread) |
42 | 88 endmacro() |
89 | |
66 | 90 |
91 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") | |
92 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") | |
70 | 93 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S) |
94 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir") | |
66 | 95 add_custom_command( |
70 | 96 OUTPUT "initcode" |
66 | 97 DEPENDS initcode.o |
70 | 98 COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode" |
66 | 99 ) |
70 | 100 #file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
101 | |
42 | 102 |
53 | 103 GearsCommand ( |
42 | 104 TARGET |
105 kernel | |
106 SOURCES | |
61 | 107 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 |
52 | 108 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 |
80 | 109 SingleLinkedStack.cbc |
61 | 110 entry.S |
42 | 111 ) |