annotate src/CMakeLists.txt @ 84:a4307abefd0b

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