CMAKE: use system wide installation of glslangValidator if found
parent
146a0155f2
commit
9f6a03ae4d
|
@ -6,7 +6,6 @@ include(CheckCCompilerFlag)
|
|||
set(DEFAULT_LUA_EXECUTABLE lua lua5.2 lua5.3)
|
||||
set(DEFAULT_LUAC_EXECUTABLE luac luac5.2 luac5.3)
|
||||
set(DATA_DIR ${ROOT_DIR}/data CACHE STRING "" FORCE)
|
||||
set(NATIVE_BUILD_DIR ${ROOT_DIR}/build CACHE PATH "The directory where the initial native tool were built")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED on)
|
||||
|
|
|
@ -2,25 +2,13 @@ function(generate_db_models TARGET INPUT OUTPUT)
|
|||
set(GEN_DIR ${GENERATE_DIR}/dbmodels/${TARGET}/)
|
||||
file(MAKE_DIRECTORY ${GEN_DIR})
|
||||
target_include_directories(${TARGET} PUBLIC ${GEN_DIR})
|
||||
if (CMAKE_CROSS_COMPILING)
|
||||
message(STATUS "Looking for native tool in ${NATIVE_BUILD_DIR}")
|
||||
find_program(DATABASETOOL_EXECUTABLE NAMES vengi-databasetool PATHS ${NATIVE_BUILD_DIR}/databasetool)
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${OUTPUT}
|
||||
COMMENT "Generate ${OUTPUT}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" ${DATABASETOOL_EXECUTABLE} --tablefile ${INPUT} --outfile ${GEN_DIR}${OUTPUT}
|
||||
DEPENDS ${INPUT}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${OUTPUT}
|
||||
COMMENT "Generate ${OUTPUT}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" $<TARGET_FILE:databasetool> --tablefile ${INPUT} --outfile ${GEN_DIR}${OUTPUT}
|
||||
DEPENDS databasetool ${INPUT}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${OUTPUT}
|
||||
COMMENT "Generate ${OUTPUT}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" $<TARGET_FILE:databasetool> --tablefile ${INPUT} --outfile ${GEN_DIR}${OUTPUT}
|
||||
DEPENDS databasetool ${INPUT}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
add_custom_target(GenerateDatabaseModelBindings${TARGET}
|
||||
DEPENDS ${GEN_DIR}${OUTPUT}
|
||||
COMMENT "Generate database model bindings for ${TARGET} in ${GEN_DIR}"
|
||||
|
|
|
@ -15,25 +15,13 @@ function(generate_protocol TARGET)
|
|||
set(HEADER "${_basefilename}_generated.h")
|
||||
set(DEFINITION ${_file})
|
||||
list(APPEND _headers ${GEN_DIR}${HEADER})
|
||||
if (CMAKE_CROSS_COMPILING)
|
||||
message(STATUS "Looking for native tool in ${NATIVE_BUILD_DIR}")
|
||||
find_program(FLATC_EXECUTABLE NAMES vengi-flatc PATHS ${NATIVE_BUILD_DIR}/flatc)
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${HEADER}
|
||||
COMMAND ${FLATC_EXECUTABLE} -c --scoped-enums -o ${GEN_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/protocolq/${DEFINITION}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/protocol/${DEFINITION}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating source code for ${DEFINITION}"
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${HEADER}
|
||||
COMMAND flatc -c --scoped-enums -o ${GEN_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/protocol/${DEFINITION}
|
||||
DEPENDS flatc ${CMAKE_CURRENT_SOURCE_DIR}/protocol/${DEFINITION}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating source code for ${DEFINITION}"
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${GEN_DIR}${HEADER}
|
||||
COMMAND flatc -c --scoped-enums -o ${GEN_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/protocol/${DEFINITION}
|
||||
DEPENDS flatc ${CMAKE_CURRENT_SOURCE_DIR}/protocol/${DEFINITION}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating source code for ${DEFINITION}"
|
||||
)
|
||||
engine_mark_as_generated(${GEN_DIR}/${HEADER})
|
||||
endforeach()
|
||||
|
||||
|
|
|
@ -81,26 +81,13 @@ function(generate_shaders TARGET)
|
|||
set(_shadersourcepath "${GEN_DIR}${_f}Shader.cpp")
|
||||
set(_shaderconstantheaderpath "${GEN_DIR}${_f}ShaderConstants.h")
|
||||
# TODO We have to add the shader/ dirs of all dependencies to the include path
|
||||
if (CMAKE_CROSS_COMPILING)
|
||||
message(STATUS "Looking for native tool in ${NATIVE_BUILD_DIR}")
|
||||
find_program(SHADERTOOL_EXECUTABLE NAMES vengi-shadertool PATHS ${NATIVE_BUILD_DIR}/shadertool)
|
||||
find_program(GLSLANGVALIDATOR_EXECUTABLE NAMES glslangValidator PATHS ${NATIVE_BUILD_DIR})
|
||||
add_custom_command(
|
||||
OUTPUT ${_shaderheaderpath}.in ${_shadersourcepath}.in ${_shaderconstantheaderpath}.in
|
||||
IMPLICIT_DEPENDS C ${_shaders}
|
||||
COMMENT "Validate ${_file}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" ${SHADERTOOL_EXECUTABLE} --glslang ${GLSLANGVALIDATOR_EXECUTABLE} ${SHADERTOOL_INCLUDE_DIRS_PARAM} --postfix .in --shader ${_dir}/${_file} --constantstemplate ${_template_constants_header} --headertemplate ${_template_header} --sourcetemplate ${_template_cpp} --buffertemplate ${_template_ub} --sourcedir ${GEN_DIR}
|
||||
DEPENDS ${_shaders} ${_shadersdeps} ${_template_header} ${_template_cpp} ${_template_ub} ${_template_constants_header}
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT ${_shaderheaderpath}.in ${_shadersourcepath}.in ${_shaderconstantheaderpath}.in
|
||||
IMPLICIT_DEPENDS C ${_shaders}
|
||||
COMMENT "Validate ${_file}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" $<TARGET_FILE:shadertool> --glslang $<TARGET_FILE:glslangValidator> ${SHADERTOOL_INCLUDE_DIRS_PARAM} --postfix .in --shader ${_dir}/${_file} --constantstemplate ${_template_constants_header} --headertemplate ${_template_header} --sourcetemplate ${_template_cpp} --buffertemplate ${_template_ub} --sourcedir ${GEN_DIR}
|
||||
DEPENDS shadertool ${_shaders} ${_shadersdeps} ${_template_header} ${_template_cpp} ${_template_ub} ${_template_constants_header}
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${_shaderheaderpath}.in ${_shadersourcepath}.in ${_shaderconstantheaderpath}.in
|
||||
IMPLICIT_DEPENDS C ${_shaders}
|
||||
COMMENT "Validate ${_file}"
|
||||
COMMAND ${CMAKE_COMMAND} -E env "APP_HOMEPATH=${CMAKE_CURRENT_BINARY_DIR}/" $<TARGET_FILE:shadertool> --glslang $<TARGET_FILE:glslangValidator> ${SHADERTOOL_INCLUDE_DIRS_PARAM} --postfix .in --shader ${_dir}/${_file} --constantstemplate ${_template_constants_header} --headertemplate ${_template_header} --sourcetemplate ${_template_cpp} --buffertemplate ${_template_ub} --sourcedir ${GEN_DIR}
|
||||
DEPENDS shadertool ${_shaders} ${_shadersdeps} ${_template_header} ${_template_cpp} ${_template_ub} ${_template_constants_header}
|
||||
)
|
||||
list(APPEND _headers ${_shaderheaderpath})
|
||||
list(APPEND _sources ${_shadersourcepath})
|
||||
add_custom_command(
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
add_subdirectory(binary_to_compressed_c)
|
||||
add_subdirectory(glslang)
|
||||
find_program(GLSLANG_EXECUTABLE NAMES glslangValidator)
|
||||
if (NOT GLSLANG_EXECUTABLE)
|
||||
add_subdirectory(glslang)
|
||||
else()
|
||||
add_executable(glslangValidator IMPORTED GLOBAL)
|
||||
set_property(TARGET glslangValidator PROPERTY IMPORTED_LOCATION ${GLSLANG_EXECUTABLE})
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue