summaryrefslogtreecommitdiffstats
path: root/Graphics/HLSL2GLSLConverterLib
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-01-30 06:02:31 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-01-30 06:02:31 +0000
commit17360e2c12fca7c2da25586751350512419d30f4 (patch)
tree0a3193df2d11bfd822e5e98da3639f7e6c5af006 /Graphics/HLSL2GLSLConverterLib
parentFixed typo (diff)
downloadDiligentCore-17360e2c12fca7c2da25586751350512419d30f4.tar.gz
DiligentCore-17360e2c12fca7c2da25586751350512419d30f4.zip
Improved shader conversion custom CMake commands to properly detect changes and not run every build
Diffstat (limited to 'Graphics/HLSL2GLSLConverterLib')
-rw-r--r--Graphics/HLSL2GLSLConverterLib/CMakeLists.txt37
1 files changed, 16 insertions, 21 deletions
diff --git a/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt b/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt
index 109687df..839d9c20 100644
--- a/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt
+++ b/Graphics/HLSL2GLSLConverterLib/CMakeLists.txt
@@ -18,13 +18,21 @@ set(SOURCE
src/HLSL2GLSLConverterObject.cpp
)
-add_library(Diligent-HLSL2GLSLConverterLib STATIC ${SOURCE} ${INTERFACE} ${INCLUDE} include/GLSLDefinitions_inc.h)
-set_common_target_properties(Diligent-HLSL2GLSLConverterLib)
+set(GLSL_DEFINITIONS include/GLSLDefinitions.h)
+
+# We must use the full path, otherwise the build system will not be able to properly detect
+# changes and shader conversion custom command will run every time
+set(GLSL_DEFINITIONS_INC ${CMAKE_CURRENT_SOURCE_DIR}/include/GLSLDefinitions_inc.h)
+set_source_files_properties(${GLSL_DEFINITIONS_INC} PROPERTIES GENERATED TRUE)
-set_source_files_properties(
- ${CMAKE_CURRENT_SOURCE_DIR}/include/GLSLDefinitions_inc.h
- PROPERTIES GENERATED TRUE
+add_library(Diligent-HLSL2GLSLConverterLib STATIC
+ ${SOURCE} ${INTERFACE} ${INCLUDE}
+
+ # A target created in the same directory (CMakeLists.txt file) that specifies any output of the
+ # custom command as a source file is given a rule to generate the file using the command at build time.
+ ${GLSL_DEFINITIONS_INC}
)
+set_common_target_properties(Diligent-HLSL2GLSLConverterLib)
target_include_directories(Diligent-HLSL2GLSLConverterLib
PUBLIC
@@ -44,26 +52,13 @@ PUBLIC
)
if(NOT FILE2STRING_PATH STREQUAL "")
- # Create custom target to convert GLSLDefinitions.h to GLSLDefinitions_inc.h
- add_custom_target(Diligent-ProcessGLSLDefinitions
- SOURCES
- include/GLSLDefinitions.h
- )
-
- add_custom_command(TARGET Diligent-ProcessGLSLDefinitions
- # Unfortunately it is not possible to set TARGET directly to HLSL2GLSLConverterLib
- # because PRE_BUILD is only supported on Visual Studio 8 or later. For all other generators
- # PRE_BUILD is treated as PRE_LINK.
- COMMAND ${FILE2STRING_PATH} include/GLSLDefinitions.h include/GLSLDefinitions_inc.h
+ add_custom_command(OUTPUT ${GLSL_DEFINITIONS_INC} # We must use full path here!
+ COMMAND ${FILE2STRING_PATH} ${GLSL_DEFINITIONS} include/GLSLDefinitions_inc.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ MAIN_DEPENDENCY ${GLSL_DEFINITIONS}
COMMENT "Processing GLSLDefinitions.h"
VERBATIM
)
-
- add_dependencies(Diligent-HLSL2GLSLConverterLib Diligent-ProcessGLSLDefinitions)
- set_target_properties(Diligent-ProcessGLSLDefinitions PROPERTIES
- FOLDER DiligentCore/Graphics/Helper
- )
else()
message(WARNING "File2String utility is currently unavailable on this host system. This is not an issues unless you modify GLSLDefinitions.h file")
endif()