-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
117 lines (98 loc) · 4.52 KB
/
CMakeLists.txt
File metadata and controls
117 lines (98 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required (VERSION 3.10)
project(Diligent-RenderStateNotation CXX)
set(REFLECTED
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/BlendState.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/DepthStencilState.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/GraphicsTypes.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/InputLayout.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/PipelineResourceSignature.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/PipelineState.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/RasterizerState.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/RenderPass.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/Shader.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/ShaderResourceVariable.h
${Diligent-GraphicsEngine_SOURCE_DIR}/interface/Sampler.h
${Diligent-GraphicsEngine_SOURCE_DIR}/../Archiver/interface/ArchiverFactory.h
)
set(RSN_PARSER_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/parser_headers CACHE INTERNAL "Render State Notation Parser generated headers directory")
set(RSN_PARSER_GENERATED_HEADERS_DIR ${RSN_PARSER_HEADERS_DIR}/generated)
file(MAKE_DIRECTORY "${RSN_PARSER_GENERATED_HEADERS_DIR}")
# Copy .clang-format to the generated headers directory to make sure that another .clang-format file
# is not accidentally used.
file(COPY ../.clang-format DESTINATION "${RSN_PARSER_GENERATED_HEADERS_DIR}")
find_package(Python3 REQUIRED)
set(LIBCLANG_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install libclang==16.0.6)
set(JINJA2_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install jinja2)
if(${Python3_VERSION} VERSION_GREATER_EQUAL "3.11")
set(LIBCLANG_INSTALL_CMD ${LIBCLANG_INSTALL_CMD} --break-system-packages)
set(JINJA2_INSTALL_CMD ${JINJA2_INSTALL_CMD} --break-system-packages)
endif()
execute_process(COMMAND ${LIBCLANG_INSTALL_CMD}
RESULT_VARIABLE PYTHON_PIP_LIBCLANG_RESULT)
if(NOT PYTHON_PIP_LIBCLANG_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${LIBCLANG_INSTALL_CMD}' failed with error code ${PYTHON_PIP_LIBCLANG_RESULT}")
endif()
execute_process(COMMAND ${JINJA2_INSTALL_CMD}
RESULT_VARIABLE PYTHON_PIP_JINJIA_RESULT)
if(NOT PYTHON_PIP_JINJIA_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${JINJA2_INSTALL_CMD}' failed with error code ${PYTHON_PIP_JINJIA_RESULT}")
endif()
file(GLOB INCLUDE include/*)
file(GLOB INTERFACE interface/*)
file(GLOB SOURCE src/*)
file(GLOB SCRIPTS scripts/*.py)
foreach(REFLECTED_FILE_PATH ${REFLECTED})
get_filename_component(REFLECTED_FILE_NAME ${REFLECTED_FILE_PATH} NAME_WE)
set(GENERATED_FILE_PATH "${RSN_PARSER_GENERATED_HEADERS_DIR}/${REFLECTED_FILE_NAME}Parser.hpp")
list(APPEND GENERATED ${GENERATED_FILE_PATH})
endforeach(REFLECTED_FILE_PATH)
list(APPEND GENERATED "${RSN_PARSER_GENERATED_HEADERS_DIR}/CommonParser.hpp")
set_source_files_properties(${GENERATED} PROPERTIES GENERATED TRUE)
source_group("include" FILES ${INCLUDE})
source_group("interface" FILES ${INTERFACE})
source_group("generated" FILES ${GENERATED})
source_group("source" FILES ${SOURCE})
source_group("scripts" FILES ${SCRIPTS})
if (EXISTS "${CLANG_FORMAT_EXECUTABLE}")
set(FORMATTING_COMMAND "${CLANG_FORMAT_EXECUTABLE}" -i *.hpp --verbose)
else()
set(FORMATTING_COMMAND "${CMAKE_COMMAND}" -E echo "clang-format executable is not found: RSN parser headers will not be formatted")
endif()
add_custom_command(OUTPUT ${GENERATED}
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cxx_generator.py" --dir "." --files ${REFLECTED}
COMMAND ${FORMATTING_COMMAND}
WORKING_DIRECTORY "${RSN_PARSER_GENERATED_HEADERS_DIR}"
DEPENDS ${REFLECTED}
COMMENT "Generating RSN Parser Headers...")
add_library(Diligent-RenderStateNotation STATIC
${INCLUDE}
${INTERFACE}
${SOURCE}
${GENERATED}
${SCRIPTS}
)
target_include_directories(Diligent-RenderStateNotation
PUBLIC
interface
PRIVATE
include
../../DiligentCore/Graphics/Archiver/interface
${RSN_PARSER_HEADERS_DIR}
)
target_link_libraries(Diligent-RenderStateNotation
PRIVATE
Diligent-BuildSettings
Diligent-Common
Diligent-PlatformInterface
Diligent-GraphicsEngineInterface
Diligent-GraphicsAccessories
Diligent-GraphicsTools
Diligent-JSON
)
set_target_properties(Diligent-RenderStateNotation PROPERTIES
FOLDER DiligentTools
)
set_common_target_properties(Diligent-RenderStateNotation)
if(DILIGENT_INSTALL_TOOLS)
install_tools_lib(Diligent-RenderStateNotation)
endif()