Skip to content

Commit

Permalink
(#43) Add .msi support for easy windows install
Browse files Browse the repository at this point in the history
  • Loading branch information
mario4tier committed Dec 6, 2024
1 parent 12c70f3 commit 6f00c3d
Show file tree
Hide file tree
Showing 6 changed files with 444 additions and 165 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@ autom4te.cache
ar-lib
**/.history/

# TA-Lib specific tools (must be built for each platform)
# TA-Lib tools (must be built by devs on its own platform)
src/tools/gen_code/gen_code
src/tools/ta_regtest/ta_regtest
bin/*.class
bin/gen_code*
bin/ta_*
!bin/HOLDER

## More TA-Lib artifacts
## TA-Lib misc. build and packaging artifacts
msbuild_path.txt
lib/ta_*
lib/ta-*
ta-lib-git.tar.gz
LICENSE.rtf

## File system
.DS_Store
Expand Down
35 changes: 25 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.30)

project(ta-lib)

Expand All @@ -10,15 +10,18 @@ set(PROJECT_VERSION "${TA_LIB_VERSION_MAJOR}.${TA_LIB_VERSION_MINOR}.${TA_LIB_VE

set(CMAKE_C_STANDARD 99)

# Option to build development tools (enabled by default)
option(BUILD_DEV_TOOLS "Build development tools (gen_code, ta_regtest)" ON)
message(STATUS "BUILD_DEV_TOOLS: ${BUILD_DEV_TOOLS}")

# Default to Release config
if(NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

# Option to build development tools (enabled by default)
option(BUILD_DEV_TOOLS "Build development tools (gen_code, ta_regtest)" ON)
message(STATUS "BUILD_DEV_TOOLS: ${BUILD_DEV_TOOLS}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
message(STATUS "CPACK_GENERATOR: ${CPACK_GENERATOR}")

# TA-Lib public API headers (will be installed by this script)
set(LIB_HEADERS
Expand Down Expand Up @@ -503,6 +506,9 @@ endif()
# Packaging #
#############

# Example of good assets naming:
# https://cmake.org/download/

# Set variables controling the package creation.
set(CPACK_BUILD_CONFIG "${CMAKE_BUILD_TYPE}")

Expand All @@ -529,14 +535,15 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

# Detect host architecture and set DEB and RPM specific architecture variables
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
set(DEB_HOST_ARCH "amd64")
set(RPM_HOST_ARCH "x86_64")
set(MSI_HOST_ARCH "x64")
set(MSI_HOST_ARCH "x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686")
set(DEB_HOST_ARCH "i386")
set(RPM_HOST_ARCH "i386")
set(MSI_HOST_ARCH "x86")
set(MSI_HOST_ARCH "i386")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
set(DEB_HOST_ARCH "armhf")
set(RPM_HOST_ARCH "armv7hl")
Expand All @@ -561,6 +568,8 @@ endif()

# Debian package created by TA-LIb CI only if host is ubuntu.
# The package should work on any debian-based Linux.
#
# More info: https://www.debian.org/doc/debian-policy/ch-controlfields.html#source
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${DEB_HOST_ARCH}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
Expand All @@ -574,6 +583,12 @@ set(CPACK_RPM_PACKAGE_LICENSE "BSD")
set(CPACK_RPM_PACKAGE_REQUIRES "glibc")

# MSI package created only if host is windows.

# CPACK_WIX_VERSION "4" is for ""4 and later" and is the one to use for Wix 5
# References:
# https://cmake.org/cmake/help/latest/cpack_gen/wix.html#variable:CPACK_WIX_VERSION
# https://stackoverflow.com/questions/77584815/how-to-use-wix-v4-within-cmake-to-build-an-installation-package-for-windows
set(CPACK_WIX_VERSION "4")
set(CPACK_WIX_LICENSE_RTF "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.rtf")
#set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/banner.bmp")
#set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/dialog.bmp")
Expand All @@ -599,7 +614,7 @@ if(CPACK_GENERATOR STREQUAL "DEB")
elseif(CPACK_GENERATOR STREQUAL "RPM")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${RPM_HOST_ARCH}")
elseif(CPACK_GENERATOR STREQUAL "WIX")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${RPM_HOST_ARCH}" )
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-windows-${MSI_HOST_ARCH}")
endif()

# Allow the caller at the "cmake" configuration phase to see the filename.
Expand Down
Binary file added dist/ta-lib-0.6.0-windows-x86_64.msi
Binary file not shown.
Loading

0 comments on commit 6f00c3d

Please sign in to comment.