10
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
- # limitations under the License.
13
+ # limitations under the License
14
14
15
15
include (ProcessorCount )
16
16
set (_NBL_CPACK_PACKAGE_RELATIVE_ENTRY_ "$<$<NOT:$<STREQUAL:$<CONFIG>,Release>>:$<LOWER_CASE:$<CONFIG>>>" CACHE INTERNAL "" )
17
17
18
- # TODO: REDO THIS WHOLE THING AS FUNCTIONS
19
- # https://github.com/buildaworldnet/IrrlichtBAW/issues/311 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
18
+ function (nbl_handle_dll_definitions _TARGET_ _SCOPE_ )
19
+ if (NOT TARGET Nabla )
20
+ message (FATAL_ERROR "Internal error, Nabla target must be defined!" )
21
+ endif ()
22
+
23
+ if (NOT TARGET ${_TARGET_} )
24
+ message (FATAL_ERROR "Internal error, requsted \" ${_TARGET_} \" is not defined!" )
25
+ endif ()
26
+
27
+ if (NBL_DYNAMIC_MSVC_RUNTIME )
28
+ set (_NABLA_OUTPUT_DIR_ "${NBL_ROOT_PATH_BINARY} /src/nbl/$<CONFIG>/devshgraphicsprogramming.nabla" )
29
+
30
+ target_compile_definitions (${_TARGET_} ${_SCOPE_}
31
+ _NABLA_DLL_NAME_= "$<TARGET_FILE_NAME:Nabla>" ;_NABLA_OUTPUT_DIR_= "${_NABLA_OUTPUT_DIR_} " ;_NABLA_INSTALL_DIR_= "${CMAKE_INSTALL_PREFIX} "
32
+ )
33
+ endif ()
34
+
35
+ target_compile_definitions (${_TARGET_} ${_SCOPE_}
36
+ _DXC_DLL_= "${DXC_DLL} "
37
+ )
38
+ endfunction ()
39
+
40
+ function (nbl_handle_runtime_lib_properties _TARGET_ )
41
+ if (NOT TARGET ${_TARGET_} )
42
+ message (FATAL_ERROR "Internal error, requsted \" ${_TARGET_} \" is not defined!" )
43
+ endif ()
44
+
45
+ if (NBL_DYNAMIC_MSVC_RUNTIME )
46
+ set_target_properties (${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
47
+ else ()
48
+ set_target_properties (${_TARGET_} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
49
+ endif ()
50
+ endfunction ()
20
51
21
52
# Macro creating project for an executable
22
53
# Project and target get its name from directory when this macro gets executed (truncating number in the beginning of the name and making all lower case)
@@ -40,27 +71,18 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
40
71
)
41
72
42
73
add_executable (${EXECUTABLE_NAME} ${NBL_EXECUTABLE_SOURCES} )
74
+ nbl_handle_runtime_lib_properties (${EXECUTABLE_NAME} )
43
75
44
- if (NBL_DYNAMIC_MSVC_RUNTIME )
45
- set_property (TARGET ${EXECUTABLE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
46
-
47
- if (WIN32 AND MSVC )
76
+ if (WIN32 AND MSVC )
77
+ if (NBL_DYNAMIC_MSVC_RUNTIME )
48
78
target_link_options (${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:$<TARGET_FILE_NAME:Nabla>" )
49
79
endif ()
50
- else ()
51
- set_property (TARGET ${EXECUTABLE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
52
- endif ()
53
-
54
- if (WIN32 AND MSVC )
80
+
55
81
target_link_options (${EXECUTABLE_NAME} PUBLIC "/DELAYLOAD:dxcompiler.dll" )
56
82
endif ()
57
83
endif ()
58
84
59
- if (WIN32 AND MSVC )
60
- target_compile_definitions (${EXECUTABLE_NAME} PUBLIC
61
- _DXC_DLL_= "${DXC_DLL} "
62
- )
63
- endif ()
85
+ nbl_handle_dll_definitions (${EXECUTABLE_NAME} PUBLIC )
64
86
65
87
target_compile_definitions (${EXECUTABLE_NAME} PUBLIC _NBL_APP_NAME_= "${EXECUTABLE_NAME} " )
66
88
@@ -255,31 +277,13 @@ macro(nbl_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUD
255
277
)
256
278
endif ()
257
279
258
- if (NBL_DYNAMIC_MSVC_RUNTIME )
259
- if (WIN32 AND MSVC )
260
- set (_NABLA_OUTPUT_DIR_ "${NBL_ROOT_PATH_BINARY} /src/nbl/$<CONFIG>/devshgraphicsprogramming.nabla" )
261
-
262
- target_compile_definitions (${LIB_NAME} PUBLIC
263
- _NABLA_DLL_NAME_= "$<TARGET_FILE_NAME:Nabla>" ;_NABLA_OUTPUT_DIR_= "${_NABLA_OUTPUT_DIR_} " ;_NABLA_INSTALL_DIR_= "${CMAKE_INSTALL_PREFIX} "
264
- )
265
- endif ()
266
- endif ()
267
-
268
- if (WIN32 AND MSVC )
269
- target_compile_definitions (${LIB_NAME} PUBLIC
270
- _DXC_DLL_= "${DXC_DLL} "
271
- )
272
- endif ()
273
-
274
280
add_dependencies (${LIB_NAME} Nabla )
275
281
target_link_libraries (${LIB_NAME} PUBLIC Nabla )
276
282
target_compile_options (${LIB_NAME} PUBLIC ${LIB_OPTIONS} )
277
283
target_compile_definitions (${LIB_NAME} PUBLIC ${DEF_OPTIONS} )
278
- if (NBL_DYNAMIC_MSVC_RUNTIME )
279
- set_target_properties (${LIB_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
280
- else ()
281
- set_target_properties (${LIB_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
282
- endif ()
284
+
285
+ nbl_handle_dll_definitions (${LIB_NAME} PUBLIC )
286
+ nbl_handle_runtime_lib_properties (${LIB_NAME} )
283
287
284
288
if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "GNU" )
285
289
add_compile_options (
0 commit comments