Skip to content

Commit

Permalink
Use STATIC libraries instead of OBJECT for MSVC
Browse files Browse the repository at this point in the history
There isn't a practical need to use an object library and only causes
complications when linking into the main vulkan-1.dll.
  • Loading branch information
charles-lunarg committed Jan 9, 2024
1 parent 0b1eead commit bfa1561
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ end
add_custom_target(loader_asm_gen_files DEPENDS gen_defines.asm)
set_target_properties(loader_asm_gen_files PROPERTIES FOLDER ${LOADER_HELPER_FOLDER})

add_library(loader-unknown-chain OBJECT unknown_ext_chain_masm.asm)
add_library(loader-unknown-chain STATIC unknown_ext_chain_masm.asm)
target_link_libraries(loader-unknown-chain Vulkan::Headers)
target_include_directories(loader-unknown-chain PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
add_dependencies(loader-unknown-chain loader_asm_gen_files)

# Work around bug in CMake + Ninja, see https://discourse.cmake.org/t/building-lib-file-from-asm-cmake-bug/1959
set(CMAKE_ASM_MASM_CREATE_STATIC_LIBRARY "<CMAKE_AR> /OUT:<TARGET> <LINK_FLAGS> <OBJECTS>")
else()
set(USE_ASSEMBLY_FALLBACK ON)
message(WARNING "Could not find working MASM assembler\n${ASM_FAILURE_MSG}")
Expand Down Expand Up @@ -302,7 +305,7 @@ endif()
if(USE_ASSEMBLY_FALLBACK)
add_custom_target(loader_asm_gen_files)
if (MSVC)
add_library(loader-unknown-chain OBJECT unknown_ext_chain.c)
add_library(loader-unknown-chain STATIC unknown_ext_chain.c)
target_link_libraries(loader-unknown-chain loader_specific_options)
set_target_properties(loader-unknown-chain PROPERTIES CMAKE_C_FLAGS_DEBUG "${MODIFIED_C_FLAGS_DEBUG}")
else()
Expand All @@ -323,16 +326,13 @@ if(WIN32)
set(RC_FILE_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/loader.rc)
endif()

set(LOADER_UNKNOWN_CHAIN_LIBRARY $<$<TARGET_EXISTS:loader-unknown-chain>:$<TARGET_OBJECTS:loader-unknown-chain>>)

add_library(vulkan
SHARED
${NORMAL_LOADER_SRCS}
${LOADER_UNKNOWN_CHAIN_LIBRARY}
${CMAKE_CURRENT_SOURCE_DIR}/${API_TYPE}-1.def
${RC_FILE_LOCATION})

target_link_libraries(vulkan PRIVATE loader_specific_options loader-opt)
target_link_libraries(vulkan PRIVATE loader_specific_options loader-opt loader-unknown-chain)

# when adding the suffix the import and runtime library names must be consistent
# mingw: libvulkan-1.dll.a / vulkan-1.dll
Expand Down

0 comments on commit bfa1561

Please sign in to comment.