simplified data_to_c macro in cmake
authorCampbell Barton <ideasman42@gmail.com>
Sat, 11 Aug 2012 13:32:19 +0000 (13:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 11 Aug 2012 13:32:19 +0000 (13:32 +0000)
build_files/cmake/macros.cmake
source/blender/editors/datafiles/CMakeLists.txt
source/blender/gpu/CMakeLists.txt

index 5a5f02b41fac24e786e3710d9117ba8ce7bffa60..af122541ae56c95810fa74ca4c450f57e93f5371 100644 (file)
@@ -744,3 +744,31 @@ macro(data_to_c
                DEPENDS ${file_from})
 endmacro()
 
+# same as above but generates the var name and output automatic.
+macro(data_to_c_simple
+      file_from
+      list_to_add)
+
+    # get var name automatic from name
+    get_filename_component(_file_from_only ${file_from} NAME)
+    string(REPLACE "." "_" _file_from_only ${_file_from_only})
+    set(_var_name "datatoc_${_file_from_only}")
+
+    # only to avoid confusion
+    set(_file_to ${file_from}.c)
+
+       list(APPEND ${list_to_add} ${CMAKE_CURRENT_BINARY_DIR}/${_file_to})
+
+       add_custom_command(
+               OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
+               COMMAND ${CMAKE_COMMAND}
+                               -DFILE_FROM=${CMAKE_CURRENT_SOURCE_DIR}/${file_from}
+                               -DFILE_TO=${CMAKE_CURRENT_BINARY_DIR}/${_file_to}
+                               -DVAR_NAME=${_var_name}
+                               -P ${CMAKE_SOURCE_DIR}/build_files/cmake/data_to_c.cmake
+               DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file_from})
+
+    unset(_file_from_only)
+    unset(_var_name)
+    unset(_file_to)
+endmacro()
index c0edd8d263202ddef5f403de0c242e894d908b20..31846f9b3007ec26ceeebaacfbcf4a32ac1281d0 100644 (file)
@@ -80,16 +80,10 @@ if(WITH_BLENDER)
                        vertexdraw.png.c
                )
 
-               data_to_c(${CMAKE_SOURCE_DIR}/release/datafiles/preview.blend
-                         ${CMAKE_CURRENT_BINARY_DIR}/preview.blend.c
-                         datatoc_preview_blend SRC)
-
+               data_to_c_simple(../../../../release/datafiles/preview.blend SRC)
        endif()
 
-       data_to_c(${CMAKE_SOURCE_DIR}/release/datafiles/startup.blend
-                 ${CMAKE_CURRENT_BINARY_DIR}/startup.blend.c
-                 datatoc_startup_blend SRC)
-
+       data_to_c_simple(../../../../release/datafiles/startup.blend SRC)
 endif()
 
 blender_add_lib(bf_editor_datafiles "${SRC}" "${INC}" "${INC_SYS}")
index 8b0d9e3fac4f9c6d7925c3f7fc4bd5d43bc3c09d..9ce42d9e0bbaa0cceed3f21f6c8fb7e479a97175 100644 (file)
@@ -58,27 +58,12 @@ set(SRC
        intern/gpu_codegen.h
 )
 
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_material.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_material.glsl.c
-          datatoc_gpu_shader_material_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_vertex.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_vertex.glsl.c
-          datatoc_gpu_shader_vertex_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_sep_gaussian_blur_frag.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_sep_gaussian_blur_frag.glsl.c
-          datatoc_gpu_shader_sep_gaussian_blur_frag_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_sep_gaussian_blur_vert.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_sep_gaussian_blur_vert.glsl.c
-          datatoc_gpu_shader_sep_gaussian_blur_vert_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_material.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_material.glsl.c
-          datatoc_gpu_shader_material_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_vsm_store_frag.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_vsm_store_frag.glsl.c
-          datatoc_gpu_shader_vsm_store_frag_glsl SRC)
-data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/shaders/gpu_shader_vsm_store_vert.glsl
-          ${CMAKE_CURRENT_BINARY_DIR}/shaders/gpu_shader_vsm_store_vert.glsl.c
-          datatoc_gpu_shader_vsm_store_vert_glsl SRC)
+data_to_c_simple(shaders/gpu_shader_material.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_vertex.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_sep_gaussian_blur_frag.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_sep_gaussian_blur_vert.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_vsm_store_frag.glsl SRC)
+data_to_c_simple(shaders/gpu_shader_vsm_store_vert.glsl SRC)
 
 if(WITH_MOD_SMOKE)
        add_definitions(-DWITH_SMOKE)