我的着色器代码有一个简单的CMakeLists,目前看起来像这样-
target_sources( JonsEngine
PRIVATE
AmbientPixel.hlsl
AvgLuminance.hlsl
BoxBlurPixel.hlsl
Common.hlsl
Constants.h
DepthReadback.hlsl
DirectionalLightPixel.hlsl
DirectionalLightPCF2X2Pixel.hlsl
DirectionalLightPCF3X3Pixel.hlsl
DirectionalLightPCF5X5Pixel.hlsl
DirectionalLightPCF7X7Pixel.hlsl
FullscreenTriangle.hlsl
FullscreenTriangleTexcoord.hlsl
FXAA.hlsl
FXAAPixel.hlsl
GBufferPixel.hlsl
GBufferVertex.hlsl
GBufferVertexAnimated.hlsl
GBufferVertexStatic.hlsl
OptimizedPCF.hlsl
PointLightPixel.hlsl
SDSMFinalCompute.hlsl
SDSMInitialCompute.hlsl
SimpleColorPixel.hlsl
SimpleTexturePixel.hlsl
SkyboxPixel.hlsl
SkyboxVertex.hlsl
SSAOPixel.hlsl
TerrainDomain.hlsl
TerrainHull.hlsl
TerrainPixel.hlsl
TerrainPixelDebug.hlsl
Tonemapping.hlsl
TransformAnimatedVertex.hlsl
TransformStaticInstancedVertex.hlsl
TransformStaticVertex.hlsl
)
我正尝试使用--p为其中的 some 添加一堆编译标志
set_source_files_properties( AmbientPixel.hlsl PROPERTIES COMPILE_FLAGS "/E\"ps_main\" /ps\"_5_0\"" )
但是,当我通过CMake生成解决方案时,当我查看该源文件的编译选项时,似乎忽略了这一点。我在做什么错了?
编辑:CMake 3.14 +
答案 0 :(得分:0)
CMake将HLSL文件视为源文件,因为它不是CMake中的一流语言。 Others也遇到了您的问题,这促使CMake添加了VS_SHADER_FLAGS选项。
尝试这样的方法:
add_executable(JonsEngine)
# Set HLSL source file properties with VS_SHADER_FLAGS.
set_source_files_properties( AmbientPixel.hlsl PROPERTIES VS_SHADER_FLAGS "/E\"ps_main\" /ps\"_5_0\"")
# Associate these source extras with the executable defined above.
target_sources(JonsEngine PRIVATE
AmbientPixel.hlsl
AvgLuminance.hlsl
#
# ... other code files here ...
#
)
还有其他一些为Visual Studio生成器创建的CMake着色器选项,例如VS_SHADER_TYPE
和VS_SHADER_ENTRYPOINT
,它们为着色器编译器提供了附加的构建信息。