Commit d3a682b8 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #183] cmake now properly handles the cases where shader linking is turned on after first copy.

parent 893107d8
......@@ -188,8 +188,6 @@ BUILD_SYSTEM_COMPILER()
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# OpenWalnut specific options
# other options
OPTION( OW_HANDLE_SHADERS "This ensures that shaders are available in build directory after build." ON )
# sorry, linking not available properly on windows, Cygwin supports this but we do not want special rules for thousands of environments.
# ==> keep it clean
......
......@@ -195,32 +195,41 @@ ENDFUNCTION( SETUP_TESTS )
# break the install targets
# _Component the name of the install component
FUNCTION( SETUP_SHADERS _Shaders _TargetDir _Component )
# only if we are allowed to
IF( OW_HANDLE_SHADERS )
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory ${_TargetDir} )
# should we copy or link them?
SET( ShaderOperation "copy_if_different" )
IF ( OW_LINK_SHADERS ) # link
SET( ShaderOperation "create_symlink" )
ENDIF( OW_LINK_SHADERS )
# now do the operation for each shader into build dir
FOREACH( fname ${_Shaders} )
# We need the plain filename (create_symlink needs it)
STRING( REGEX REPLACE "^.*/" "" StrippedFileName "${fname}" )
# let cmake do it
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E ${ShaderOperation} ${fname} "${PROJECT_BINARY_DIR}/${_TargetDir}/${StrippedFileName}" )
ENDFOREACH( fname )
# now add install targets for each shader. All paths are relative to the current source dir.
FOREACH( fname ${_Shaders} )
INSTALL( FILES ${fname} DESTINATION ${_TargetDir}
COMPONENT ${_Component}
)
ENDFOREACH( fname )
ENDIF( OW_HANDLE_SHADERS )
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory ${_TargetDir} )
# should we copy or link them?
SET( ShaderOperation "copy_if_different" )
IF ( OW_LINK_SHADERS ) # link
SET( ShaderOperation "create_symlink" )
ENDIF( OW_LINK_SHADERS )
# now do the operation for each shader into build dir
FOREACH( fname ${_Shaders} )
# We need the plain filename (create_symlink needs it)
STRING( REGEX REPLACE "^.*/" "" StrippedFileName "${fname}" )
# construct final filename
SET( targetFile "${PROJECT_BINARY_DIR}/${_TargetDir}/${StrippedFileName}" )
# if the file already exists as non-symlink and we use the "create_symlink" command, we first need to remove the files
IF( NOT IS_SYMLINK ${targetFile} AND OW_LINK_SHADERS )
# before creating the symlink, remove the old files or cmake will not create the symlinks (as intended)
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove -f ${targetFile} )
ELSEIF( IS_SYMLINK ${targetFile} AND NOT OW_LINK_SHADERS )
# also handle the inverse case. The files exist as symlinks but copies should be used. Remove symlinks!
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove -f ${targetFile} )
ENDIF()
# let cmake do it
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E ${ShaderOperation} ${fname} ${targetFile} )
ENDFOREACH( fname )
# now add install targets for each shader. All paths are relative to the current source dir.
FOREACH( fname ${_Shaders} )
INSTALL( FILES ${fname} DESTINATION ${_TargetDir}
COMPONENT ${_Component}
)
ENDFOREACH( fname )
ENDFUNCTION( SETUP_SHADERS )
# Sets up the stylecheck mechanism. Use this to add your codes to the stylecheck mechanism.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment