Mercurial > hg > Members > anatofuz > CbC_xv6
comparison src/CMakeLists.txt @ 55:4f5d1aa8b594
fix use linker
author | anatofuz |
---|---|
date | Thu, 06 Jun 2019 19:25:42 +0900 |
parents | aa0095c4c2b0 |
children | a5ca5cc4661c |
comparison
equal
deleted
inserted
replaced
54:aa0095c4c2b0 | 55:4f5d1aa8b594 |
---|---|
1 cmake_minimum_required(VERSION 3.8) | 1 cmake_minimum_required(VERSION 3.8) |
2 project(xv6cbc C ASM) | 2 project(xv6cbc C ASM) |
3 | 3 |
4 # https://github.com/llvm-mirror/libcxx/blob/master/cmake/Modules/HandleCompilerRT.cmake | 4 # https://github.com/llvm-mirror/libcxx/blob/master/cmake/Modules/HandleCompilerRT.cmake |
5 function(find_compiler_rt_library dest) | 5 function(find_compiler_rt_library dest) |
6 #if (NOT DEFINED LIBC_COMPILE_FLAGS) | |
7 # message(FATAL_ERROR "LIBC_COMPILE_FLAGS must be defined when using this function") | |
8 #endif() | |
9 set(dest "" PARENT_SCOPE) | 6 set(dest "" PARENT_SCOPE) |
10 set(CLANG_COMMAND ${CMAKE_C_COMPILER} | 7 set(CLANG_COMMAND ${CMAKE_C_COMPILER} |
11 "--print-libgcc-file-name") | 8 "--print-libgcc-file-name") |
12 if (CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) | 9 if (CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) |
13 list(APPEND CLANG_COMMAND "--target=${CMAKE_C_COMPILER_TARGET}") | 10 list(APPEND CLANG_COMMAND "--target=${CMAKE_C_COMPILER_TARGET}") |
14 endif() | 11 endif() |
15 #get_property(LIBC_C_FLAGS CACHE CMAKE_C_FLAGS PROPERTY VALUE) | |
16 string(REPLACE " " ";" LIBC_C_FLAGS "${LIBC_C_FLAGS}") | 12 string(REPLACE " " ";" LIBC_C_FLAGS "${LIBC_C_FLAGS}") |
17 list(APPEND CLANG_COMMAND ${LIBC_C_FLAGS}) | 13 list(APPEND CLANG_COMMAND ${LIBC_C_FLAGS}) |
18 execute_process( | 14 execute_process( |
19 COMMAND ${CLANG_COMMAND} | 15 COMMAND ${CLANG_COMMAND} |
20 RESULT_VARIABLE HAD_ERROR | 16 RESULT_VARIABLE HAD_ERROR |
21 OUTPUT_VARIABLE LIBRARY_FILE | 17 OUTPUT_VARIABLE LIBRARY_FILE |
22 ) | 18 ) |
23 string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE) | 19 string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE) |
24 set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE) | 20 set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE) |
25 endfunction() | 21 endfunction() |
22 | |
23 | |
26 | 24 |
27 set(USE_CUDA,0) | 25 set(USE_CUDA,0) |
28 # -DUSE_CUDA | 26 # -DUSE_CUDA |
29 # add_definitions("-Wall -g -O") | 27 # add_definitions("-Wall -g -O") |
30 | 28 |
36 -Wno-nullability-completeness -Wno-expansion-to-defined") | 34 -Wno-nullability-completeness -Wno-expansion-to-defined") |
37 set(CMAKE_EXE_LINKER_FLAGS "-L. -arch armv7 -T kernel-cmake.ld -o kernel.elf ") | 35 set(CMAKE_EXE_LINKER_FLAGS "-L. -arch armv7 -T kernel-cmake.ld -o kernel.elf ") |
38 else (APPLE) | 36 else (APPLE) |
39 set(CMAKE_C_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc) | 37 set(CMAKE_C_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc) |
40 set(CMAKE_ASM_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc) | 38 set(CMAKE_ASM_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc) |
41 set(CMAKE_EXE_LINK_EXECUTABLE "/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld") | |
42 add_definitions("-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | 39 add_definitions("-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- |
43 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0") | 40 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0") |
44 find_compiler_rt_library("LIBRARY_FILE") | 41 find_compiler_rt_library("LIBRARY_FILE") |
45 set(CMAKE_EXE_LINKER_FLAGS "-L. -T kernel-cmake.ld ${LIBRARY_FILE} -o kernel.elf -b binary -nostdlib ") | 42 set(CMAKE_C_LINK_EXECUTABLE "/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld -L. -T kernel-cmake.ld ${LIBRARY_FILE} -o kernel.elf -b binary -nostdlib ") |
46 | 43 |
47 endif (APPLE) | 44 endif (APPLE) |
48 | 45 |
49 # -DCMAKE_BUILD_TYPE=Debug | 46 # -DCMAKE_BUILD_TYPE=Debug |
50 set(CMAKE_C_FLAGS_DEBUG "-O0") | 47 set(CMAKE_C_FLAGS_DEBUG "-O0") |