diff src/CMakeLists.txt @ 73:0bf6872eb250

fix build kernel.dir
author anatofuz
date Wed, 31 Jul 2019 19:35:57 +0900
parents 1e1c6feb7d83
children 10d09cd9fad3
line wrap: on
line diff
--- a/src/CMakeLists.txt	Wed Jul 31 18:59:59 2019 +0900
+++ b/src/CMakeLists.txt	Wed Jul 31 19:35:57 2019 +0900
@@ -46,7 +46,6 @@
     set( _ONE_VALUE_ARGS TARGET )
     set( _MULTI_VALUE_ARGS SOURCES )
     cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
-    set(CMAKE_KERNEL_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir")
 
     set (_Gears_CBC_SOURCES)
     set (_Gears_CSOURCES)
@@ -54,35 +53,35 @@
         if (${i} MATCHES "\\.cbc")
             string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
             add_custom_command (
-                OUTPUT    ${CMAKE_KERNEL_OUTPUT_DIR}/${j}
+                OUTPUT    ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}
                 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}
+                COMMAND  "cd" "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${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 "${CMAKE_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 (
-                OUTPUT    ${CMAKE_KERNEL_OUTPUT_DIR}/${j}
+                OUTPUT    ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}
                 DEPENDS   ${i}
                 COMMAND  nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
             )
-            list(APPEND _Gears_CBC_SOURCES ${j})
+            list(APPEND _Gears_CBC_SOURCES ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j})
         else()
             set(j ${i})
-            #list(APPEND _Gears_CSOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
+            #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_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})
+    file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir)
     add_custom_command (
-          OUTPUT    ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c
+          OUTPUT    ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.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}
+          COMMAND  "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
     )
-    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_OUTPUT_DIR}/c/${_Gears_TARGET}-context.c )
+    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c )
     #  target_link_libraries(${_Gears_TARGET} m pthread)
 endmacro()