Mercurial > hg > CbC > CbC_xv6
annotate src/usr/CMakeLists.txt @ 141:bb1b0676e27b
merge
author | anatofuz |
---|---|
date | Thu, 12 Dec 2019 14:28:15 +0900 |
parents | 239bd73abac6 |
children | 124c59d99fc9 |
rev | line source |
---|---|
58 | 1 cmake_minimum_required(VERSION 3.8) |
59 | 2 set(CMAKE_C_COMPILER "/usr/bin/cc") |
58 | 3 project(usr C ASM) |
4 | |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
5 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
6 set(CMAKE_SYSROOT "${CBC_XV6_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
7 set(CMAKE_OSX_SYSROOT "${CBC_XV6_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
8 include_directories("${CMAKE_OSX_SYSROOT}") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
9 include_directories(SYSTEM "${CMAKE_OSX_SYSROOT}/usr/include") |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
10 include_directories(SYSTEM "${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
|
11 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
|
12 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
|
13 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
|
14 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
|
15 endif() |
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
16 |
58 | 17 |
18 set(CMAKE_C_FLAGS_DEBUG "-O0") | |
19 add_definitions(${PMAKE_ARGS}) | |
20 set(CMAKE_C_COMPILER "${CBC_COM}") | |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
21 set(CMAKE_ASM_COMPILER "${CBC_COM}") |
58 | 22 |
69 | 23 #include_directories("..") |
63 | 24 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") |
25 set(CMAKE_C_LINK_EXECUTABLE "${KERNEL_LINK_EXECUTABLE}") | |
62 | 26 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LIB} -nostdlib") |
58 | 27 |
94
0956648d24e5
impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
87
diff
changeset
|
28 |
58 | 29 macro( GearsCommand ) |
69 | 30 include_directories(${CMAKE_SOURCE_DIR}) |
31 include_directories(${CMAKE_SOURCE_DIR}/usr) | |
32 include_directories(${CMAKE_BINARY_DIR}/usr/c) | |
33 | |
58 | 34 set( _OPTIONS_ARGS ) |
35 set( _ONE_VALUE_ARGS TARGET ) | |
36 set( _MULTI_VALUE_ARGS SOURCES ) | |
37 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
38 | |
39 set (_Gears_CBC_SOURCES) | |
40 set (_Gears_CSOURCES) | |
41 foreach(i ${_Gears_SOURCES}) | |
42 if (${i} MATCHES "\\.cbc") | |
43 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
44 add_custom_command ( | |
45 OUTPUT ${j} | |
46 DEPENDS ${i} | |
69 | 47 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${i} |
58 | 48 ) |
49 list(APPEND _Gears_CBC_SOURCES ${j}) | |
50 elseif (${i} MATCHES "\\.cu") | |
51 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) | |
52 add_custom_command ( | |
53 OUTPUT ${j} | |
54 DEPENDS ${i} | |
55 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} | |
56 ) | |
57 list(APPEND _Gears_CBC_SOURCES ${j}) | |
58 else() | |
59 set(j ${i}) | |
87 | 60 file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION "${CMAKE_BINARY_DIR}/usr/${_Gears_TARGET}.dir") |
58 | 61 list(APPEND _Gears_CSOURCES ${j}) |
62 endif() | |
63 endforeach(i) | |
64 | |
65 add_custom_command ( | |
71 | 66 OUTPUT ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c |
58 | 67 DEPENDS ${_Gears_CBC_SOURCES} |
111
239bd73abac6
add gen context.h at generate_context.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
94
diff
changeset
|
68 COMMAND "cd" "${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES} |
58 | 69 ) |
71 | 70 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c ) |
58 | 71 target_link_libraries(${_Gears_TARGET} ulib) |
72 endmacro() | |
73 | |
59 | 74 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c) |
61 | 75 #add_library(syslib string.c) |
58 | 76 |
75 | 77 # set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello) |
78 set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh hello) | |
58 | 79 |
59 | 80 foreach(cmd ${USR_COMMANDS}) |
81 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c) | |
82 endforeach(cmd) | |
58 | 83 |
63 | 84 set(_USR_COMMANDS) |
85 foreach (i ${USR_COMMANDS}) | |
86 list(APPEND _USR_COMMANDS "_${i}") | |
87 endforeach(i) | |
88 | |
72 | 89 |
90 file(COPY "${CMAKE_SOURCE_DIR}/usr/UNIX" DESTINATION "${CMAKE_BINARY_DIR}/usr") | |
91 | |
63 | 92 add_custom_target(fs.img ALL |
72 | 93 COMMAND ${CMAKE_BINARY_DIR}/tools/mkfs fs.img ${_USR_COMMANDS} UNIX \; cp fs.img ${CMAKE_BINARY_DIR} |
64 | 94 DEPENDS ${_USR_COMMANDS} mkfs |
58 | 95 ) |