Skip to content

Commit

Permalink
Add package target using CPack
Browse files Browse the repository at this point in the history
This enables easy binary distribution for Windows and
might later even be expanded for other platforms and/or installers
  • Loading branch information
TcT2k committed May 17, 2018
1 parent 0a105ff commit 2b9edb6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -73,6 +73,8 @@ add_custom_command(
target_sources(openswe1r PUBLIC ${CMAKE_BINARY_DIR}/app_version.h)
target_include_directories(openswe1r PRIVATE ${CMAKE_BINARY_DIR})

include(package.cmake)

if(USE_VM)
target_compile_definitions(openswe1r PUBLIC -DUC_KVM)
target_sources(openswe1r PUBLIC
Expand Down
46 changes: 46 additions & 0 deletions package.cmake
@@ -0,0 +1,46 @@
# Configure CPack variables before including CPack

set(CPACK_PACKAGE_VENDOR OpenSWE1R)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)

if(NOT CPACK_GENERATOR)
# Set default list of supported CPack generators if not specified by the user
if(WIN32 OR APPLE)
set(CPACK_GENERATOR "ZIP")
else()
set(CPACK_GENERATOR "TGZ")
endif()
endif()

include(cmake/determine_app_version.cmake)
set(CPACK_PACKAGE_VERSION ${APP_VERSION})
set(CPACK_PACKAGE_FILE_NAME OpenSWE1R-${APP_VERSION})

include(CPack)

# Install required files
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".")

# Install main binaries
install(TARGETS openswe1r
RUNTIME DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
)

# Install documentation
install(FILES README.md LICENSE.txt DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION})

# Install additional binary modules
if(MSVC)
# Install required runtime libraries
include(InstallRequiredSystemLibraries)

# vcpkg will automatically move the required binaries to the build folder
foreach(lib OpenAL32 unicorn SDL2)
install(FILES $<TARGET_FILE_DIR:openswe1r>/${lib}.dll
DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
)
endforeach()
install(FILES $<TARGET_FILE_DIR:openswe1r>/glew32$<$<CONFIG:Debug>:d>.dll
DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
)
endif()

0 comments on commit 2b9edb6

Please sign in to comment.