diff --git a/cmake/Modules/AXBuildHelpers.cmake b/cmake/Modules/AXBuildHelpers.cmake index de4814561f..7d929d8a4f 100644 --- a/cmake/Modules/AXBuildHelpers.cmake +++ b/cmake/Modules/AXBuildHelpers.cmake @@ -384,6 +384,13 @@ function(ax_setup_app_config app_name) XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON ) endif() + + if((WIN32 AND (NOT WINRT)) OR LINUX) + if (IS_DIRECTORY ${GLSLCC_OUT_DIR}) + get_target_property(rt_output ${app_name} RUNTIME_OUTPUT_DIRECTORY) + ax_sync_target_res(${APP_NAME} LINK_TO "${rt_output}/${CMAKE_CFG_INTDIR}/axslc" FOLDERS ${GLSLCC_OUT_DIR} SYM_LINK 1 SYNC_TARGET_ID axslc) + endif() + endif() endfunction() # if cc_variable not set, then set it cc_value diff --git a/cmake/Modules/AXGLSLCC.cmake b/cmake/Modules/AXGLSLCC.cmake index 2d0c5c0289..d71f72230d 100644 --- a/cmake/Modules/AXGLSLCC.cmake +++ b/cmake/Modules/AXGLSLCC.cmake @@ -12,14 +12,23 @@ if (NOT GLSLCC_EXE) message(FATAL_ERROR "Please run setup.ps1 again to download glslcc, and run CMake again.") endif() -set(GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS .frag;.fsh) -set(GLSLCC_VERT_SOURCE_FILE_EXTENSIONS .vert;.vsh) -set(GLSLCC_OUT_SUFFIX "") +macro(glslcc_option variable value) + if(NOT DEFINED ${variable}) + set(${variable} ${value}) + endif() +endmacro() + +glslcc_option(GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS .frag;.fsh) +glslcc_option(GLSLCC_VERT_SOURCE_FILE_EXTENSIONS .vert;.vsh) +glslcc_option(GLSLCC_OUT_DIR ${CMAKE_BINARY_DIR}/runtime/axslc) +glslcc_option(GLSLCC_OUT_SUFFIX "") +glslcc_option(GLSLCC_FLAT_UBOS TRUE) + +message(STATUS "GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS=${GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS}") +message(STATUS "GLSLCC_VERT_SOURCE_FILE_EXTENSIONS=${GLSLCC_VERT_SOURCE_FILE_EXTENSIONS}") +message(STATUS "GLSLCC_OUT_SUFFIX=${GLSLCC_OUT_SUFFIX}") +message(STATUS "GLSLCC_FLAT_UBOS=${GLSLCC_FLAT_UBOS}") -# PROPERTY: output directory (optional) -define_property(SOURCE PROPERTY GLSLCC_OUTPUT_DIRECTORY - BRIEF_DOCS "Compiled shader output directory" - FULL_DOCS "Compiled shader output directory") # PROPERTY: include direcotries (optional) define_property(SOURCE PROPERTY GLSLCC_INCLUDE_DIRS BRIEF_DOCS "Compiled shader include directories" @@ -96,6 +105,11 @@ function (ax_target_compile_shaders target_name) list(APPEND INC_DIRS "${_AX_ROOT}/core/renderer/shaders") list(APPEND SC_FLAGS "--include-dirs=${INC_DIRS}") + # flat-ubs + if(${GLSLCC_FLAT_UBOS}) + list(APPEND SC_FLAGS "--flatten-ubos") + endif() + # input if (${FILE_EXT} IN_LIST GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS) list(APPEND SC_FLAGS "--frag=${SC_FILE}") @@ -108,11 +122,10 @@ function (ax_target_compile_shaders target_name) endif() # output - get_source_file_property(OUT_DIR ${SC_FILE} GLSLCC_OUTPUT_DIRECTORY) - if (OUT_DIR STREQUAL "NOTFOUND") - set(OUT_DIR "${CMAKE_BINARY_DIR}/shaders") + set(OUT_DIR ${GLSLCC_OUT_DIR}) + if (NOT (IS_DIRECTORY ${OUT_DIR})) + file(MAKE_DIRECTORY ${OUT_DIR}) endif() - file(MAKE_DIRECTORY ${OUT_DIR}) if (NOT opt_CVAR) list(APPEND SC_FLAGS "--output=${OUT_DIR}/${FILE_NAME}${GLSLCC_OUT_SUFFIX}" )