-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
104 lines (89 loc) · 2.89 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 3.15.0)
#set(CMAKE_GENERATOR_PLATFORM Win32)
project(NewInstallerTemplateMSI)
# Enable Unicode Character Set
add_compile_definitions(UNICODE _UNICODE)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set static runtime before any targets are defined
if(MSVC)
# Force only Release and Debug configurations
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
# Add global compiler definitions for Debug and Release configurations
add_compile_definitions(
$<$<CONFIG:Debug>:_DEBUG>
$<$<CONFIG:Release>:NDEBUG>
)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
# Define the Release and Debug configurations
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
# Set output directories based on build configuration
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>)
# Set the NDEBUG and _DEBUG macros for Release and Debug configurations
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_definitions(NDEBUG)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG)
endif()
add_link_options(
"-static-libgcc"
"-static-libstdc++"
)
endif()
add_library(UnRAR0 SHARED
msi_log.c
dll.rc
)
target_link_libraries(UnRAR0
PRIVATE
msi
)
if(MSVC)
target_link_options(UnRAR0 PRIVATE
"/SUBSYSTEM:WINDOWS"
"/MANIFEST:NO"
)
else()
target_link_options(UnRAR0 PRIVATE
"-Wl,--subsystem,windows"
)
endif()
add_executable(test_UnRAR0
test_msi.c
)
target_link_libraries(test_UnRAR0
PRIVATE
msi
)
if(MSVC)
target_link_options(test_UnRAR0 PRIVATE
"/SUBSYSTEM:CONSOLE"
"/MANIFEST:NO"
)
else()
target_link_options(test_UnRAR0 PRIVATE
"-Wl,--subsystem,windows"
)
endif()
add_dependencies(test_UnRAR0 UnRAR0)
# Set up the MSI Package project
set(MSI_OUTPUT_DIR "${CMAKE_SOURCE_DIR}/Installer")
# Configure the heatwave.wxs.in file
#configure_file(heatwave.wxs.in heatwave.wxs @ONLY)
# Add a custom target to build the MSI
add_custom_target(Installer_TFMCfW ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${MSI_OUTPUT_DIR}"
COMMAND "C:/Program Files/WiX Toolset v5.0/bin/wix.exe" build "${CMAKE_SOURCE_DIR}/heatwave.wxs" -out "${MSI_OUTPUT_DIR}/Installer_TFMCfW.msi" -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# Make Installer depending on UnRAR0
add_dependencies(Installer_TFMCfW UnRAR0)
# Ensure the output of candle.exe and light.exe is visible in the MSVC build log
set_property(TARGET Installer_TFMCfW PROPERTY ENABLE_EXPORTS TRUE)