From 23b8f25dae22996b1cca2cab17d3d427879f7935 Mon Sep 17 00:00:00 2001 From: Jhett Black <10942655+jhett12321@users.noreply.github.com> Date: Thu, 20 Jul 2023 02:17:08 +0200 Subject: [PATCH] Add nwserver.lib generation. --- Core/CMakeLists.txt | 20 ++++++++++++++++---- Core/create_lib.bat | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index b49a1951532..0b22066bfd3 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -8,10 +8,22 @@ target_compile_definitions(Core PRIVATE "-DPLUGIN_NAME=\"${PLUGIN_PREFIX}Core\"" target_link_libraries(Core NWNXLib) if(MSVC) -set_target_properties(Core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -set_target_properties(Core PROPERTIES BUILD_SHARED_LIBS TRUE) -set_target_properties(Core PROPERTIES ENABLE_EXPORTS TRUE) -target_link_libraries(Core ${CMAKE_CURRENT_SOURCE_DIR}/nwserver.lib) + file(DOWNLOAD https://nwn.beamdog.net/downloads/nwnee-dedicated-8193.35-40.zip nwserver.zip) + file(ARCHIVE_EXTRACT INPUT nwserver.zip DESTINATION "." PATTERNS "bin/win32/nwserver.exe") + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/create_lib.bat + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create_lib.bat ARGS "bin/win32/nwserver.exe" + ) + + add_custom_target(NWServerLib DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib") + + add_dependencies(Core NWServerLib) + set_target_properties(Core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + set_target_properties(Core PROPERTIES BUILD_SHARED_LIBS TRUE) + set_target_properties(Core PROPERTIES ENABLE_EXPORTS TRUE) + target_link_libraries(Core "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib") endif () # The name defined here will be ignored when loading plugins. diff --git a/Core/create_lib.bat b/Core/create_lib.bat index fde6e07714b..d5e614948db 100644 --- a/Core/create_lib.bat +++ b/Core/create_lib.bat @@ -1,6 +1,6 @@ @echo off -dumpbin /exports nwserver.exe > nwserver.exports +dumpbin /exports %1 > nwserver.exports echo LIBRARY nwserver.exe > nwserver.def echo EXPORTS >> nwserver.def