comparison src/CMakeLists.txt @ 70:1e1c6feb7d83

fix build initcode
author anatofuz
date Tue, 30 Jul 2019 18:00:52 +0900
parents f236eba62a76
children 0bf6872eb250
comparison
equal deleted inserted replaced
69:f236eba62a76 70:1e1c6feb7d83
31 endif() 31 endif()
32 find_package(CUDA REQUIRED) 32 find_package(CUDA REQUIRED)
33 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) 33 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
34 endif() 34 endif()
35 35
36 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
36 include_directories(".") 37 include_directories(".")
37 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY) 38 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY)
38 39
39 macro( GearsCommand ) 40 macro( GearsCommand )
40 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL") 41 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL")
55 add_custom_command ( 56 add_custom_command (
56 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/${j} 57 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/${j}
57 DEPENDS ${i} 58 DEPENDS ${i}
58 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j} ${CMAKE_SOURCE_DIR}/${i} 59 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j} ${CMAKE_SOURCE_DIR}/${i}
59 ) 60 )
60 # list(APPEND _Gears_CBC_SOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}") 61 list(APPEND _Gears_CBC_SOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
61 list(APPEND _Gears_CBC_SOURCES ${j}) 62 #list(APPEND _Gears_CBC_SOURCES ${j})
62 elseif (${i} MATCHES "\\.cu") 63 elseif (${i} MATCHES "\\.cu")
63 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) 64 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
64 add_custom_command ( 65 add_custom_command (
65 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/${j} 66 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/${j}
66 DEPENDS ${i} 67 DEPENDS ${i}
67 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} 68 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
68 ) 69 )
69 list(APPEND _Gears_CBC_SOURCES ${j}) 70 list(APPEND _Gears_CBC_SOURCES ${j})
70 else() 71 else()
71 set(j ${i}) 72 set(j ${i})
73 #list(APPEND _Gears_CSOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
72 list(APPEND _Gears_CSOURCES ${j}) 74 list(APPEND _Gears_CSOURCES ${j})
73 endif() 75 endif()
74 endforeach(i) 76 endforeach(i)
75 77
76 #target_link_libraries(syslib) 78 #target_link_libraries(syslib)
79 file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
77 add_custom_command ( 80 add_custom_command (
78 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c 81 OUTPUT ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c
79 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode 82 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode
80 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET} ${_Gears_CBC_SOURCES} 83 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET} ${_Gears_CBC_SOURCES}
81 ) 84 )
82 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c ) 85 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c )
83 # target_link_libraries(${_Gears_TARGET} m pthread) 86 # target_link_libraries(${_Gears_TARGET} m pthread)
84 endmacro() 87 endmacro()
85 88
86 89
87 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}") 90 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}")
88 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}") 91 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}")
89 add_executable(initcode.o initcode.S) 92 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S)
93 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir")
90 add_custom_command( 94 add_custom_command(
91 OUTPUT initcode 95 OUTPUT "initcode"
92 DEPENDS initcode.o 96 DEPENDS initcode.o
93 COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BINARY_DIR}/initcode.o" "${CMAKE_BINARY_DIR}/initcode" 97 COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode"
94 ) 98 )
99 #file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
100
95 101
96 GearsCommand ( 102 GearsCommand (
97 TARGET 103 TARGET
98 kernel 104 kernel
99 SOURCES 105 SOURCES