Mercurial > hg > CbC > CbC_xv6
annotate src/usr/CMakeLists.txt @ 309:c6cbe4711e02
tweak
author | menikon |
---|---|
date | Mon, 03 Feb 2020 15:29:54 +0900 |
parents | 124c59d99fc9 |
children | 045299ad7e97 |
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}) | |
60 list(APPEND _Gears_CSOURCES ${j}) | |
61 endif() | |
62 endforeach(i) | |
63 | |
64 add_custom_command ( | |
150 | 65 OUTPUT CMakeFiles/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c |
58 | 66 DEPENDS ${_Gears_CBC_SOURCES} |
150 | 67 COMMAND "cd" "CMakeFiles/${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} "-w" ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES} |
58 | 68 ) |
150 | 69 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} CMakeFiles/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c ) |
58 | 70 target_link_libraries(${_Gears_TARGET} ulib) |
71 endmacro() | |
72 | |
59 | 73 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c) |
61 | 74 #add_library(syslib string.c) |
58 | 75 |
75 | 76 # set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello) |
77 set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh hello) | |
58 | 78 |
59 | 79 foreach(cmd ${USR_COMMANDS}) |
80 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c) | |
81 endforeach(cmd) | |
58 | 82 |
63 | 83 set(_USR_COMMANDS) |
84 foreach (i ${USR_COMMANDS}) | |
85 list(APPEND _USR_COMMANDS "_${i}") | |
86 endforeach(i) | |
87 | |
72 | 88 |
89 file(COPY "${CMAKE_SOURCE_DIR}/usr/UNIX" DESTINATION "${CMAKE_BINARY_DIR}/usr") | |
90 | |
63 | 91 add_custom_target(fs.img ALL |
72 | 92 COMMAND ${CMAKE_BINARY_DIR}/tools/mkfs fs.img ${_USR_COMMANDS} UNIX \; cp fs.img ${CMAKE_BINARY_DIR} |
64 | 93 DEPENDS ${_USR_COMMANDS} mkfs |
58 | 94 ) |