changeset 70:1e1c6feb7d83

fix build initcode
author anatofuz
date Tue, 30 Jul 2019 18:00:52 +0900
parents f236eba62a76
children 6ebe7043702c
files src/CMakeLists.txt
diffstat 1 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Sun Jul 28 20:03:15 2019 +0900
+++ b/src/CMakeLists.txt	Tue Jul 30 18:00:52 2019 +0900
@@ -33,6 +33,7 @@
     SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
 endif()
 
+set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
 include_directories(".")
 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY)
 
@@ -57,8 +58,8 @@
                 DEPENDS   ${i}
                 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}
             )
-            # list(APPEND _Gears_CBC_SOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
-            list(APPEND _Gears_CBC_SOURCES ${j})
+            list(APPEND _Gears_CBC_SOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
+            #list(APPEND _Gears_CBC_SOURCES ${j})
         elseif (${i} MATCHES "\\.cu")
             string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
             add_custom_command (
@@ -69,29 +70,34 @@
             list(APPEND _Gears_CBC_SOURCES ${j})
         else()
             set(j ${i})
+            #list(APPEND _Gears_CSOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
             list(APPEND _Gears_CSOURCES ${j})
         endif()
     endforeach(i)
 
     #target_link_libraries(syslib)
+    file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
     add_custom_command (
           OUTPUT    ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c
           DEPENDS   ${_Gears_CBC_SOURCES} fs.img initcode
           COMMAND  "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET} ${_Gears_CBC_SOURCES}
     )
-    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
+    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c )
     #  target_link_libraries(${_Gears_TARGET} m pthread)
 endmacro()
 
 
 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}")
 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}")
-add_executable(initcode.o initcode.S)
+add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S)
+set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir")
 add_custom_command(
-  OUTPUT  initcode
+  OUTPUT  "initcode"
   DEPENDS initcode.o
-  COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BINARY_DIR}/initcode.o" "${CMAKE_BINARY_DIR}/initcode"
+  COMMAND "arm-none-eabi-objcopy" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode"
 )
+#file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
 
 GearsCommand (
   TARGET