Skip to content

Commit

Permalink
Add nwserver.lib generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhett12321 committed Jul 20, 2023
1 parent 7585d31 commit 23b8f25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Core/create_lib.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 23b8f25

Please sign in to comment.