Skip to content

Commit a18bb57

Browse files
committed
add assembly manifest generation for msvc toolset, I have no clue why it doesn't find my assembly for a while (therefore doesn't find DLL)
1 parent f947878 commit a18bb57

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

cmake/common.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ macro(nbl_create_executable_project _EXTRA_SOURCES _EXTRA_OPTIONS _EXTRA_INCLUDE
3939
if(ANDROID)
4040
add_library(${EXECUTABLE_NAME} SHARED main.cpp ${_EXTRA_SOURCES})
4141
else()
42-
add_executable(${EXECUTABLE_NAME} main.cpp ${_EXTRA_SOURCES})
42+
set(NBL_EXAMPLE_SOURCES
43+
main.cpp
44+
${NBL_ASSEMBLIES_MANIFEST_FILEPATH}
45+
${_EXTRA_SOURCES}
46+
)
47+
48+
add_executable(${EXECUTABLE_NAME} ${NBL_EXAMPLE_SOURCES})
49+
add_dependencies(${EXECUTABLE_NAME} Nabla_manifest)
4350

4451
if(NBL_DYNAMIC_MSVC_RUNTIME)
4552
set_property(TARGET ${EXECUTABLE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<assembly manifestVersion="1.0">
2+
<assemblyIdentity type="Win32" name="DevshGraphicsProgramming.Windows.Nabla" version="1.0.0.0" publicKeyToken="0000000000000000" />
3+
<file name="@NABLA_DLL@"/>
4+
</assembly>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (c) 2022 DevSH Graphics Programming Sp. z O.O.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# CMake script for generating msvc manifest during build time
16+
17+
if(DEFINED NBL_ROOT_PATH)
18+
if(NOT EXISTS ${NBL_ROOT_PATH})
19+
message(FATAL_ERROR "NBL_ROOT_PATH as '${NBL_ROOT_PATH}' is invalid!")
20+
endif()
21+
else()
22+
message(FATAL_ERROR "NBL_ROOT_PATH variable must be specified for this script!")
23+
endif()
24+
25+
if(NOT DEFINED NBL_GEN_DIRECTORY)
26+
message(FATAL_ERROR "NBL_GEN_DIRECTORY variable must be specified for this script!")
27+
endif()
28+
29+
if(NOT DEFINED NABLA_DLL_PATH)
30+
message(FATAL_ERROR "NABLA_DLL_PATH variable must be specified for this script!")
31+
endif()
32+
33+
cmake_path(GET NABLA_DLL_PATH FILENAME NABLA_DLL)
34+
35+
set(NBL_INPUT_MSVC_MANIFEST_FILE ${NBL_ROOT_PATH}/cmake/manifest/msvc/cmake.nabla.manifest)
36+
set(NBL_OUTPUT_MSVC_MANIFEST_FILE ${NBL_GEN_DIRECTORY}/nabla.manifest)
37+
38+
message(STATUS "Generating ${NBL_OUTPUT_MSVC_MANIFEST_FILE}")
39+
configure_file("${NBL_INPUT_MSVC_MANIFEST_FILE}" "${NBL_OUTPUT_MSVC_MANIFEST_FILE}")

src/nbl/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,18 @@ if (ANDROID)
455455
)
456456
endif()
457457

458+
if(NOT NBL_STATIC_BUILD)
459+
set(NBL_ASSEMBLIES_MANIFEST_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/nabla.manifest)
460+
set(NBL_ASSEMBLIES_MANIFEST_FILEPATH ${NBL_ASSEMBLIES_MANIFEST_DIRECTORY}/nabla.manifest CACHE INTERNAL "" FORCE)
461+
add_custom_command(OUTPUT "${NBL_ASSEMBLIES_MANIFEST_FILEPATH}"
462+
COMMAND ${CMAKE_COMMAND} -DNBL_ROOT_PATH:PATH=${NBL_ROOT_PATH} -DNBL_GEN_DIRECTORY:PATH=${NBL_ASSEMBLIES_MANIFEST_DIRECTORY} -DNABLA_DLL_PATH:FILEPATH=$<TARGET_FILE:Nabla> -P ${NBL_ROOT_PATH}/cmake/scripts/nbl/nablaMSVCManifest.cmake
463+
COMMENT "Launching nabla.manifest generation script!"
464+
VERBATIM
465+
)
466+
467+
add_custom_target(Nabla_manifest ALL DEPENDS ${NBL_ASSEMBLIES_MANIFEST_FILEPATH} ${NBL_ROOT_PATH}/cmake/scripts/nbl/nablaMSVCManifest.cmake)
468+
endif()
469+
458470
## Set up 3rdparty deps
459471
# Parallel Hashmap
460472
target_include_directories(Nabla PUBLIC ${THIRD_PARTY_SOURCE_DIR}/parallel-hashmap/parallel_hashmap)

0 commit comments

Comments
 (0)