Last active
October 30, 2020 22:27
-
-
Save pjako/c4b0577edf8987b6f258e1440c167f60 to your computer and use it in GitHub Desktop.
app func & shader generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
#=== EXECUTABLE func | |
function(app app_name) | |
if(APPLE) | |
add_executable(${app_name} MACOSX_BUNDLE ${ARGN} ) | |
elseif(WIN32) | |
add_executable(${app_name} WIN32 ${ARGN}) | |
else() | |
add_executable(${app_name} ${ARGN}) | |
endif() | |
endfunction() | |
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") | |
set(TOOLS_DIR "${PROJECT_SOURCE_DIR}/tools/win32") | |
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") | |
set(TOOLS_DIR "${PROJECT_SOURCE_DIR}/tools/osx") | |
elseif(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") | |
set(TOOLS_DIR "${PROJECT_SOURCE_DIR}/tools/linux") | |
endif() | |
function(shd_shader target_name) | |
message(STATUS "Found shd: ${SHD_BIN_PATH}") | |
foreach(source_file ${ARGN}) | |
set (shd_output_file "${source_file}.h") | |
add_custom_command( | |
OUTPUT ${shd_output_file} | |
COMMAND ${SHD_BIN_PATH} | |
ARGS --input ${source_file} --slang ${slang} --output ${shd_output_file} | |
DEPENDS ${source_file} | |
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
COMMENT "Compiling ${slang}: ${shd_output_file}" | |
VERBATIM | |
) | |
if(APPLE) | |
target_sources(${target_name} PRIVATE ${shd_output_file}) | |
else() | |
target_sources(${target_name} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/${shd_output_file}" "${CMAKE_CURRENT_SOURCE_DIR}/${source_file}") | |
endif() | |
endforeach() | |
endfunction() | |
app(demo demo.c) | |
target_link_libraries(demo sokol) | |
shd_shader(demo shaders.glsl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment