mirror of https://github.com/axmolengine/axmol.git
Improve AXGLSLCC.cmake
By default, output compiled shader to `${CMAKE_BINARY_DIR}/runtime/axslc`, then link it to `$<TARGET_FILE_DIR::target_name>/axslc`
This commit is contained in:
parent
e47627b6cf
commit
a171f90848
|
@ -384,6 +384,13 @@ function(ax_setup_app_config app_name)
|
||||||
XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON
|
XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY ON
|
||||||
)
|
)
|
||||||
endif()
|
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()
|
endfunction()
|
||||||
|
|
||||||
# if cc_variable not set, then set it cc_value
|
# if cc_variable not set, then set it cc_value
|
||||||
|
|
|
@ -12,14 +12,23 @@ if (NOT GLSLCC_EXE)
|
||||||
message(FATAL_ERROR "Please run setup.ps1 again to download glslcc, and run CMake again.")
|
message(FATAL_ERROR "Please run setup.ps1 again to download glslcc, and run CMake again.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS .frag;.fsh)
|
macro(glslcc_option variable value)
|
||||||
set(GLSLCC_VERT_SOURCE_FILE_EXTENSIONS .vert;.vsh)
|
if(NOT DEFINED ${variable})
|
||||||
set(GLSLCC_OUT_SUFFIX "")
|
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)
|
# PROPERTY: include direcotries (optional)
|
||||||
define_property(SOURCE PROPERTY GLSLCC_INCLUDE_DIRS
|
define_property(SOURCE PROPERTY GLSLCC_INCLUDE_DIRS
|
||||||
BRIEF_DOCS "Compiled shader include directories"
|
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 INC_DIRS "${_AX_ROOT}/core/renderer/shaders")
|
||||||
list(APPEND SC_FLAGS "--include-dirs=${INC_DIRS}")
|
list(APPEND SC_FLAGS "--include-dirs=${INC_DIRS}")
|
||||||
|
|
||||||
|
# flat-ubs
|
||||||
|
if(${GLSLCC_FLAT_UBOS})
|
||||||
|
list(APPEND SC_FLAGS "--flatten-ubos")
|
||||||
|
endif()
|
||||||
|
|
||||||
# input
|
# input
|
||||||
if (${FILE_EXT} IN_LIST GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS)
|
if (${FILE_EXT} IN_LIST GLSLCC_FRAG_SOURCE_FILE_EXTENSIONS)
|
||||||
list(APPEND SC_FLAGS "--frag=${SC_FILE}")
|
list(APPEND SC_FLAGS "--frag=${SC_FILE}")
|
||||||
|
@ -108,11 +122,10 @@ function (ax_target_compile_shaders target_name)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
get_source_file_property(OUT_DIR ${SC_FILE} GLSLCC_OUTPUT_DIRECTORY)
|
set(OUT_DIR ${GLSLCC_OUT_DIR})
|
||||||
if (OUT_DIR STREQUAL "NOTFOUND")
|
if (NOT (IS_DIRECTORY ${OUT_DIR}))
|
||||||
set(OUT_DIR "${CMAKE_BINARY_DIR}/shaders")
|
file(MAKE_DIRECTORY ${OUT_DIR})
|
||||||
endif()
|
endif()
|
||||||
file(MAKE_DIRECTORY ${OUT_DIR})
|
|
||||||
if (NOT opt_CVAR)
|
if (NOT opt_CVAR)
|
||||||
list(APPEND SC_FLAGS "--output=${OUT_DIR}/${FILE_NAME}${GLSLCC_OUT_SUFFIX}" )
|
list(APPEND SC_FLAGS "--output=${OUT_DIR}/${FILE_NAME}${GLSLCC_OUT_SUFFIX}" )
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue