changeset 74:10d09cd9fad3

set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
author anatofuz
date Wed, 31 Jul 2019 20:45:13 +0900
parents 0bf6872eb250
children 624fe2ec975c
files src/CMakeLists.txt
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/CMakeLists.txt	Wed Jul 31 19:35:57 2019 +0900
+++ b/src/CMakeLists.txt	Wed Jul 31 20:45:13 2019 +0900
@@ -46,6 +46,7 @@
     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_DIR "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir")
 
     set (_Gears_CBC_SOURCES)
     set (_Gears_CSOURCES)
@@ -53,20 +54,20 @@
         if (${i} MATCHES "\\.cbc")
             string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
             add_custom_command (
-                OUTPUT    ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}
+                OUTPUT    ${CMAKE_KERNEL_DIR}/${j}
                 DEPENDS   ${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}
+                COMMAND  "cd" "${CMAKE_KERNEL_DIR}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i}
             )
-            list(APPEND _Gears_CBC_SOURCES "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}")
+            list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_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_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j}
+                OUTPUT    ${CMAKE_KERNEL_DIR}/${j}
                 DEPENDS   ${i}
                 COMMAND  nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
             )
-            list(APPEND _Gears_CBC_SOURCES ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/${j})
+            list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j})
         else()
             set(j ${i})
             #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}")
@@ -75,13 +76,13 @@
     endforeach(i)
 
     #target_link_libraries(syslib)
-    file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir)
+    file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION ${CMAKE_KERNEL_DIR})
     add_custom_command (
-          OUTPUT    ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c
+          OUTPUT    ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c
           DEPENDS   ${_Gears_CBC_SOURCES} fs.img initcode
           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_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c )
+    add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c )
     #  target_link_libraries(${_Gears_TARGET} m pthread)
 endmacro()