1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Add helper option to copy dependencies to a deps folder.

This commit is contained in:
Sandu Liviu Catalin 2021-01-31 19:36:23 +02:00
parent 6aa5b504dd
commit e043e28529
2 changed files with 27 additions and 3 deletions

View File

@ -6,8 +6,9 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
# Several plugin options # Several plugin options
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
option(ENABLE_API21 "Build for 2.1 API." OFF) option(ENABLE_API21 "Build for 2.1 API." OFF)
option(COPY_DEPENDENCIES "Copy deppendent DLLs into the deps folder." OFF)
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
# C++ standard availability check # C++ standard availability check

View File

@ -144,7 +144,7 @@ if(FORCE_32BIT_BIN)
endif() endif()
# Don't prefix the module binary. # Don't prefix the module binary.
set_target_properties(SqModule PROPERTIES PREFIX "") set_target_properties(SqModule PROPERTIES PREFIX "")
# Custmize module binary name/ # Customize module binary name/
if(WIN32) if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT FORCE_32BIT_BIN) if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT FORCE_32BIT_BIN)
set_target_properties(SqModule PROPERTIES OUTPUT_NAME "mod_squirrel_64") set_target_properties(SqModule PROPERTIES OUTPUT_NAME "mod_squirrel_64")
@ -162,5 +162,28 @@ endif(WIN32)
target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}) target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}/VCMP) target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}/VCMP)
target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Sqrat) target_include_directories(SqModule PRIVATE ${CMAKE_CURRENT_LIST_DIR}/Sqrat)
# Copy module into the plugins folder # Copy module into the plug-ins folder
add_custom_command(TARGET SqModule POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:SqModule> "${PROJECT_SOURCE_DIR}/bin/plugins") add_custom_command(TARGET SqModule POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:SqModule> "${PROJECT_SOURCE_DIR}/bin/plugins")
# Copy several dependent DLLs on windows to make distribution easier (used mainly by people that distribute builds)
if(WIN32 AND MINGW AND COPY_DEPENDENCIES)
get_filename_component(MINGW_BIN_PATH ${CMAKE_C_COMPILER} DIRECTORY REALPATH)
if(NOT IS_DIRECTORY ${MINGW_BIN_PATH})
get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} DIRECTORY REALPATH)
endif()
# Make sure the deps folder exists
file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/bin/deps")
# Copy dependencies into the plug-ins folder (only so it can be distributed with the DLL)
file(COPY "${MINGW_BIN_PATH}/libpq.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
file(COPY "${MINGW_BIN_PATH}/libcurl-4.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
file(COPY "${MINGW_BIN_PATH}/libmariadb.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
if(POCO_UNBUNDLED)
file(COPY "${MINGW_BIN_PATH}/zlib1.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
file(COPY "${MINGW_BIN_PATH}/libexpat-1.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
file(COPY "${MINGW_BIN_PATH}/libsqlite3-0.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
endif()
file(COPY "${MINGW_BIN_PATH}/libstdc++-6.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT FORCE_32BIT_BIN)
file(COPY "${MINGW_BIN_PATH}/libgcc_s_seh-1.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
endif()
file(COPY "${MINGW_BIN_PATH}/libwinpthread-1.dll" DESTINATION "${PROJECT_SOURCE_DIR}/bin/deps")
endif()