annotate src/CMakeLists.txt @ 94:d876c9a65239 default tip

impl mac os target
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 23 Oct 2019 14:31:38 +0900
parents add5e775339c
children
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)
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
2 project(xv6cbc NONE)
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
3 set(BUILD_DIR ${PROJECT_BINARY_DIR})
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
4
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
5
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
6 add_subdirectory(tools)
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
7 add_subdirectory(usr)
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
8 enable_language(C ASM)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
9
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
10 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
11 set(CMAKE_SYSROOT "${CBC_XV6_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
12 set(CMAKE_OSX_SYSROOT "${CBC_XV6_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
13 include_directories("${CMAKE_OSX_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
14 include_directories("${CMAKE_OSX_SYSROOT}/usr/include")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
15 include_directories("${CMAKE_OSX_SYSROOT}/usr/include/arm-linux-gnueabihf")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
16 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
17 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
18 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
19 set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
20 endif()
55
4f5d1aa8b594 fix use linker
anatofuz
parents: 54
diff changeset
21
42
997c54d8912c fix include dir
kono
parents:
diff changeset
22 set(USE_CUDA,0)
997c54d8912c fix include dir
kono
parents:
diff changeset
23 # -DUSE_CUDA
997c54d8912c fix include dir
kono
parents:
diff changeset
24 # add_definitions("-Wall -g -O")
997c54d8912c fix include dir
kono
parents:
diff changeset
25
997c54d8912c fix include dir
kono
parents:
diff changeset
26 # -DCMAKE_BUILD_TYPE=Debug
997c54d8912c fix include dir
kono
parents:
diff changeset
27 set(CMAKE_C_FLAGS_DEBUG "-O0")
58
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
28 add_definitions(${PMAKE_ARGS})
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
29
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
30 #add_custom_command(OUTPUT tools
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
31 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run"
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
32 #)
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
33 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
34
42
997c54d8912c fix include dir
kono
parents:
diff changeset
35
997c54d8912c fix include dir
kono
parents:
diff changeset
36 if (${USE_CUDA})
997c54d8912c fix include dir
kono
parents:
diff changeset
37 include_directories("/usr/local/cuda/include")
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
38 #include_directories(${CMAKE_SOURCE_DIR})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
39 set(NVCCFLAG "-std=c++11" "-g" "-O0" )
997c54d8912c fix include dir
kono
parents:
diff changeset
40 if (UNIX AND NOT APPLE) # LINUX
997c54d8912c fix include dir
kono
parents:
diff changeset
41 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
997c54d8912c fix include dir
kono
parents:
diff changeset
42 elseif (APPLE)
997c54d8912c fix include dir
kono
parents:
diff changeset
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")
997c54d8912c fix include dir
kono
parents:
diff changeset
44 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
45 find_package(CUDA REQUIRED)
997c54d8912c fix include dir
kono
parents:
diff changeset
46 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
997c54d8912c fix include dir
kono
parents:
diff changeset
47 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
48
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
49 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
50 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
51
997c54d8912c fix include dir
kono
parents:
diff changeset
52 macro( GearsCommand )
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
53 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL")
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
54 set(CMAKE_C_COMPILER "${CBC_COM}")
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
55 set(CMAKE_ASM_COMPILER "${CBC_COM}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
56
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
57 set(CMAKE_LINKER "${X_CMAKE_LINKER}")
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
58 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}")
42
997c54d8912c fix include dir
kono
parents:
diff changeset
59 set( _OPTIONS_ARGS )
997c54d8912c fix include dir
kono
parents:
diff changeset
60 set( _ONE_VALUE_ARGS TARGET )
997c54d8912c fix include dir
kono
parents:
diff changeset
61 set( _MULTI_VALUE_ARGS SOURCES )
997c54d8912c fix include dir
kono
parents:
diff changeset
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
997c54d8912c fix include dir
kono
parents:
diff changeset
65
43
b94d72292dfa fix build arm asm file
anatofuz
parents: 42
diff changeset
66 set (_Gears_CBC_SOURCES)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
67 set (_Gears_CSOURCES)
997c54d8912c fix include dir
kono
parents:
diff changeset
68 foreach(i ${_Gears_SOURCES})
997c54d8912c fix include dir
kono
parents:
diff changeset
69 if (${i} MATCHES "\\.cbc")
997c54d8912c fix include dir
kono
parents:
diff changeset
70 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
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
997c54d8912c fix include dir
kono
parents:
diff changeset
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
997c54d8912c fix include dir
kono
parents:
diff changeset
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
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
77 #list(APPEND _Gears_CBC_SOURCES ${j})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
78 elseif (${i} MATCHES "\\.cu")
997c54d8912c fix include dir
kono
parents:
diff changeset
79 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
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
997c54d8912c fix include dir
kono
parents:
diff changeset
82 DEPENDS ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
83 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
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
997c54d8912c fix include dir
kono
parents:
diff changeset
86 else()
997c54d8912c fix include dir
kono
parents:
diff changeset
87 set(j ${i})
73
0bf6872eb250 fix build kernel.dir
anatofuz
parents: 70
diff changeset
88 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}")
43
b94d72292dfa fix build arm asm file
anatofuz
parents: 42
diff changeset
89 list(APPEND _Gears_CSOURCES ${j})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
90 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
91 endforeach(i)
997c54d8912c fix include dir
kono
parents:
diff changeset
92
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
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
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
95 file(GLOB XV6_HEADERS "${CMAKE_SOURCE_DIR}/*.h")
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
96 file(COPY ${XV6_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C})
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
97 include_directories(${CMAKE_KERNEL_DIR_C})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
98 add_custom_command (
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
99 OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
100 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode
73
0bf6872eb250 fix build kernel.dir
anatofuz
parents: 70
diff changeset
101 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
102 )
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
103 # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c )
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
104 file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}")
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
105 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c )
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
106 # target_link_libraries(${_Gears_TARGET} m pthread)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
107 endmacro()
997c54d8912c fix include dir
kono
parents:
diff changeset
108
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
109
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
110 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}")
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
111 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}")
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
112 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S)
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
113 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir")
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
114 add_custom_command(
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
115 OUTPUT "initcode"
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
116 DEPENDS initcode.o
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
117 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
118 )
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
119 #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
120
42
997c54d8912c fix include dir
kono
parents:
diff changeset
121
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
122 GearsCommand (
42
997c54d8912c fix include dir
kono
parents:
diff changeset
123 TARGET
997c54d8912c fix include dir
kono
parents:
diff changeset
124 kernel
997c54d8912c fix include dir
kono
parents:
diff changeset
125 SOURCES
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
126 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
127 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
128 SingleLinkedStack.cbc
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
129 entry.S
42
997c54d8912c fix include dir
kono
parents:
diff changeset
130 )