Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CPack config to package project #8

Merged
merged 6 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,51 @@ add_custom_command(
$<TARGET_FILE:${PROJECT_NAME}>
${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.exe
)

# CPack

if(NOT DEFINED APP_PACKAGE)
set(APP_PACKAGE false)
endif()

if (APP_PACKAGE)

include(InstallRequiredSystemLibraries)

install(TARGETS ${PROJECT_NAME}
DESTINATION bin
)

install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets/"
DESTINATION "bin/assets"
)

# CPack configuration
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION "1.0.0")
set(CPACK_PACKAGE_VENDOR "Xash")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A cpp mono injector")
set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} ${PROJECT_NAME})
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${CPACK_PACKAGE_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME})
set(CPACK_CREATE_DESKTOP_LINKS ${PROJECT_NAME})

# NSIS
set(CPACK_GENERATOR NSIS)
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon.ico")
set(CPACK_NSIS_PACKAGE_NAME "XashInjector")
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon.ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")

list(APPEND CPACK_SOURCE_IGNORE_FILES "/\.github/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/\.git/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/build/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/dllTest/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/external/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/scripts/")

include(CPack)

endif()
13 changes: 13 additions & 0 deletions scripts/BuildAndPackage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if (Test-Path build) {
Remove-Item build -Recurse -Force
}
cmake -S . -B build -DAPP_PACKAGE=ON
cmake --build build --config Release -- /m
cd build
cpack --config CPackConfig.cmake -G NSIS
cd ..

if (Test-Path build\_CPack_Packages\win64\NSIS\Xash*win64.exe) {
Remove-Item Xash*win64.exe
Move-Item build\_CPack_Packages\win64\NSIS\Xash*win64.exe .
}