Skip to content

Commit 48bdb75

Browse files
CMake: added Diligent-PublicBuildSettings target to properly export required build settings
1 parent eba68b1 commit 48bdb75

File tree

13 files changed

+52
-69
lines changed

13 files changed

+52
-69
lines changed

CMakeLists.txt

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ else()
9494
endif()
9595
endif(WIN32)
9696

97-
add_library(Diligent-BuildSettings INTERFACE)
97+
add_library(Diligent-PublicBuildSettings INTERFACE)
9898

9999
if(PLATFORM_WIN32)
100100
if(MSVC)
@@ -111,21 +111,21 @@ if(PLATFORM_WIN32)
111111

112112
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Win32 platform")
113113
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Win32 platform")
114-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_WIN32=1)
114+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_WIN32=1)
115115
elseif(PLATFORM_UNIVERSAL_WINDOWS)
116116
set(D3D11_SUPPORTED TRUE CACHE INTERNAL "D3D11 is supported on Universal Windows platform")
117117
if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "10.0")
118118
set(D3D12_SUPPORTED TRUE CACHE INTERNAL "D3D12 is supported on Universal Windows platform")
119119
endif()
120-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1)
120+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_UNIVERSAL_WINDOWS=1)
121121
elseif(PLATFORM_ANDROID)
122122
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on Android platform")
123123
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Android platform")
124-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_ANDROID=1)
124+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_ANDROID=1)
125125
elseif(PLATFORM_LINUX)
126126
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on Linux platform")
127127
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is supported on Linux platform")
128-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_LINUX=1)
128+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_LINUX=1)
129129
elseif(PLATFORM_MACOS)
130130
set(GL_SUPPORTED TRUE CACHE INTERNAL "OpenGL is supported on MacOS platform")
131131
if(${DILIGENT_CORE_PRO_EXISTS})
@@ -134,7 +134,7 @@ elseif(PLATFORM_MACOS)
134134
message("DiligentCorePro module is not found. Metal backend will be disabled")
135135
endif()
136136
set(VULKAN_SUPPORTED TRUE CACHE INTERNAL "Vulkan is enabled through MoltenVK on MacOS platform")
137-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_MACOS=1)
137+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_MACOS=1)
138138
elseif(PLATFORM_IOS)
139139
set(GLES_SUPPORTED TRUE CACHE INTERNAL "OpenGLES is supported on iOS platform")
140140
if(${DILIGENT_CORE_PRO_EXISTS})
@@ -156,7 +156,7 @@ elseif(PLATFORM_IOS)
156156
else()
157157
message("VULKAN_SDK or MoltenVK_FRAMEWORK is not defined. Vulkan backend will be disabled.")
158158
endif()
159-
target_compile_definitions(Diligent-BuildSettings INTERFACE PLATFORM_IOS=1)
159+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE PLATFORM_IOS=1)
160160
else()
161161
message(FATAL_ERROR "No PLATFORM_XXX variable defined. Make sure that 'DiligentCore' folder is processed first")
162162
endif()
@@ -207,8 +207,8 @@ message("GLES_SUPPORTED: " ${GLES_SUPPORTED})
207207
message("VULKAN_SUPPORTED: " ${VULKAN_SUPPORTED})
208208
message("METAL_SUPPORTED: " ${METAL_SUPPORTED})
209209

210-
target_compile_definitions(Diligent-BuildSettings
211-
INTERFACE
210+
target_compile_definitions(Diligent-PublicBuildSettings
211+
INTERFACE
212212
D3D11_SUPPORTED=$<BOOL:${D3D11_SUPPORTED}>
213213
D3D12_SUPPORTED=$<BOOL:${D3D12_SUPPORTED}>
214214
GL_SUPPORTED=$<BOOL:${GL_SUPPORTED}>
@@ -217,6 +217,28 @@ INTERFACE
217217
METAL_SUPPORTED=$<BOOL:${METAL_SUPPORTED}>
218218
)
219219

220+
foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS})
221+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE "$<$<CONFIG:${DBG_CONFIG}>:DILIGENT_DEVELOPMENT;DILIGENT_DEBUG>")
222+
endforeach()
223+
224+
if(DILIGENT_DEVELOPMENT)
225+
foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS})
226+
target_compile_definitions(Diligent-PublicBuildSettings INTERFACE "$<$<CONFIG:${REL_CONFIG}>:DILIGENT_DEVELOPMENT>")
227+
endforeach()
228+
endif()
229+
230+
231+
add_library(Diligent-BuildSettings INTERFACE)
232+
target_link_libraries(Diligent-BuildSettings INTERFACE Diligent-PublicBuildSettings)
233+
234+
foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS})
235+
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:${DBG_CONFIG}>:_DEBUG;DEBUG>")
236+
endforeach()
237+
238+
foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS})
239+
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:${REL_CONFIG}>:NDEBUG>")
240+
endforeach()
241+
220242

221243
if(MSVC)
222244
# For msvc, enable level 4 warnings and treat warnings as errors, except for
@@ -247,23 +269,9 @@ if(MSVC)
247269
# For instance, this way
248270
# target_compile_options(Diligent-BuildSettings INTERFACE "$<$<CONFIG:RELEASE>:/Ot>")
249271
# does not work as expected
250-
251-
set(DEBUG_MACROS DILIGENT_DEVELOPMENT DILIGENT_DEBUG)
252-
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:DEBUG>:${DEBUG_MACROS}>")
253272
else()
254273
# Todo: use __attribute__((always_inline)), but it needs to be defined in a header file
255274
target_compile_definitions(Diligent-BuildSettings INTERFACE __forceinline=inline)
256-
257-
set(DEBUG_MACROS _DEBUG DEBUG DILIGENT_DEVELOPMENT DILIGENT_DEBUG)
258-
set(RELEASE_MACROS NDEBUG)
259-
260-
foreach(DBG_CONFIG ${DEBUG_CONFIGURATIONS})
261-
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:${DBG_CONFIG}>:${DEBUG_MACROS}>")
262-
endforeach()
263-
264-
foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS})
265-
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:${REL_CONFIG}>:${RELEASE_MACROS}>")
266-
endforeach()
267275
endif(MSVC)
268276

269277

@@ -295,12 +303,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
295303
target_compile_options(Diligent-BuildSettings INTERFACE $<$<NOT:$<CONFIG:Debug>>:${CLANG_RELEASE_OPTIONS}>)
296304
endif()
297305

298-
if(DILIGENT_DEVELOPMENT)
299-
foreach(REL_CONFIG ${RELEASE_CONFIGURATIONS})
300-
target_compile_definitions(Diligent-BuildSettings INTERFACE "$<$<CONFIG:${REL_CONFIG}>:DILIGENT_DEVELOPMENT>")
301-
endforeach()
302-
endif()
303-
304306
if(PLATFORM_MACOS)
305307
find_library(APP_KIT AppKit)
306308
if (NOT APP_KIT)

Graphics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ INTERFACE
1111
target_link_libraries(Diligent-GraphicsEngineInterface
1212
INTERFACE
1313
Diligent-Primitives
14+
Diligent-PublicBuildSettings
1415
)
1516

1617
add_subdirectory(GraphicsAccessories)

Graphics/GraphicsEngine/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ set(INTERFACE
7171
interface/ShaderBindingTable.h
7272
)
7373

74+
if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS)
75+
list(APPEND INTERFACE interface/LoadEngineDll.h)
76+
endif()
77+
7478
set(SOURCE
7579
src/APIInfo.cpp
7680
src/BottomLevelASBase.cpp

Graphics/GraphicsEngine/interface/LoadEngineDll.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ inline FARPROC LoadEngineDll(const char* EngineName, const char* GetFactoryFuncN
6060
const char* Arch = "_32";
6161
#endif
6262

63-
#ifdef _DEBUG
63+
#ifdef DILIGENT_DEBUG
6464
const char* Conf = "d";
6565
#else
6666
const char* Conf = "r";

Graphics/GraphicsEngineD3D11/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,8 @@ set(SRC
8484
)
8585

8686
add_library(Diligent-GraphicsEngineD3D11Interface INTERFACE)
87-
target_include_directories(Diligent-GraphicsEngineD3D11Interface
88-
INTERFACE
89-
interface
90-
)
91-
target_link_libraries(Diligent-GraphicsEngineD3D11Interface
92-
INTERFACE
93-
Diligent-GraphicsEngineD3DBaseInterface
94-
)
87+
target_link_libraries (Diligent-GraphicsEngineD3D11Interface INTERFACE Diligent-GraphicsEngineD3DBaseInterface)
88+
target_include_directories(Diligent-GraphicsEngineD3D11Interface INTERFACE interface)
9589

9690

9791
add_library(Diligent-GraphicsEngineD3D11-static STATIC

Graphics/GraphicsEngineD3D12/CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,9 @@ set_source_files_properties(${SHADERS} PROPERTIES
136136
)
137137

138138
add_library(Diligent-GraphicsEngineD3D12Interface INTERFACE)
139-
target_include_directories(Diligent-GraphicsEngineD3D12Interface
140-
INTERFACE
141-
interface
142-
)
143-
target_link_libraries(Diligent-GraphicsEngineD3D12Interface
144-
INTERFACE
145-
Diligent-GraphicsEngineD3DBaseInterface
146-
)
139+
target_link_libraries (Diligent-GraphicsEngineD3D12Interface INTERFACE Diligent-GraphicsEngineD3DBaseInterface)
140+
target_include_directories(Diligent-GraphicsEngineD3D12Interface INTERFACE interface)
141+
147142

148143
add_library(Diligent-GraphicsEngineD3D12-static STATIC
149144
${SRC} ${INTERFACE} ${INCLUDE} ${SHADERS}

Graphics/GraphicsEngineD3DBase/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ add_custom_command(OUTPUT ${HLSL_DEFINITIONS_INC} # We must use full path here!
5353
)
5454

5555
add_library(Diligent-GraphicsEngineD3DBaseInterface INTERFACE)
56-
target_link_libraries(Diligent-GraphicsEngineD3DBaseInterface INTERFACE Diligent-GraphicsEngineInterface)
56+
target_link_libraries (Diligent-GraphicsEngineD3DBaseInterface INTERFACE Diligent-GraphicsEngineInterface)
5757
target_include_directories(Diligent-GraphicsEngineD3DBaseInterface INTERFACE interface)
5858

5959
target_include_directories(Diligent-GraphicsEngineD3DBase

Graphics/GraphicsEngineOpenGL/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,8 @@ else()
134134
endif()
135135

136136
add_library(Diligent-GraphicsEngineOpenGLInterface INTERFACE)
137-
target_include_directories(Diligent-GraphicsEngineOpenGLInterface
138-
INTERFACE
139-
interface
140-
)
141-
target_link_libraries(Diligent-GraphicsEngineOpenGLInterface
142-
INTERFACE
143-
Diligent-GraphicsEngineInterface
144-
)
137+
target_link_libraries (Diligent-GraphicsEngineOpenGLInterface INTERFACE Diligent-GraphicsEngineInterface)
138+
target_include_directories(Diligent-GraphicsEngineOpenGLInterface INTERFACE interface)
145139

146140

147141
add_library(Diligent-GraphicsEngineOpenGL-static STATIC

Graphics/GraphicsEngineVulkan/CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,13 @@ add_custom_command(OUTPUT ${GENERATE_MIPS_SHADER_INC} # We must use full path he
148148

149149

150150
add_library(Diligent-GraphicsEngineVkInterface INTERFACE)
151-
target_include_directories(Diligent-GraphicsEngineVkInterface
152-
INTERFACE
153-
interface
154-
)
155-
target_link_libraries(Diligent-GraphicsEngineVkInterface
156-
INTERFACE
157-
Diligent-GraphicsEngineInterface
158-
)
151+
target_link_libraries (Diligent-GraphicsEngineVkInterface INTERFACE Diligent-GraphicsEngineInterface)
152+
target_include_directories(Diligent-GraphicsEngineVkInterface INTERFACE interface)
153+
159154

160155
add_library(Diligent-GraphicsEngineVk-static STATIC
161156
${SRC} ${VULKAN_UTILS_SRC} ${INTERFACE} ${INCLUDE} ${VULKAN_UTILS_INCLUDE} ${GENERATE_MIPS_SHADER}
162-
157+
163158
# A target created in the same directory (CMakeLists.txt file) that specifies any output of the
164159
# custom command as a source file is given a rule to generate the file using the command at build time.
165160
${GENERATE_MIPS_SHADER_INC}

Tests/DiligentCoreAPITest/assets/shaders/ShaderResourceLayout/Samplers.hlsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ SamplerState g_SamArr_Static[STATIC_SAM_ARRAY_SIZE]; // 2
88
SamplerState g_SamArr_Mut [MUTABLE_SAM_ARRAY_SIZE]; // 4
99
SamplerState g_SamArr_Dyn [DYNAMIC_SAM_ARRAY_SIZE]; // 3
1010

11-
SamplerState g_Sampler;
12-
1311
#define TexRefValue float4(1.0, 0.0, 1.0, 0.0)
1412

1513
float4 CheckValue(float4 Val, float4 Expected)

0 commit comments

Comments
 (0)