-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMAKE_package.cmake
50 lines (43 loc) · 1.81 KB
/
CMAKE_package.cmake
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
# architecture
if(WIN32)
EXECUTE_PROCESS(COMMAND wmic os get osarchitecture OUTPUT_VARIABLE ARCHITECTURE_CMD_RAW)
string(REPLACE "\r" "" ARCHITECTURE_CMD_CLEANR ${ARCHITECTURE_CMD_RAW})
string(REPLACE " " "" ARCHITECTURE_CMD_NOSPACE ${ARCHITECTURE_CMD_CLEANR})
string(REPLACE "\n" "_" ARCHITECTURE_CMD_NON ${ARCHITECTURE_CMD_NOSPACE})
string(REPLACE "__" ";" ARCHITECTURE_LIST_1 ${ARCHITECTURE_CMD_NON})
string(REPLACE "_" ";" ARCHITECTURE_LIST ${ARCHITECTURE_LIST_1})
list(GET ARCHITECTURE_LIST 1 ARCHITECTURE)
else()
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
endif()
# get current git commit hash
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# replace "." to "_" to fix executable name
string(REPLACE "." "_" FileVersion ${CMAKE_PROJECT_VERSION})
set(EXE_NAME "qube_puzzle_${CMAKE_SYSTEM_NAME}_${ARCHITECTURE}_${GIT_HASH}")
# create zip archive
file(MAKE_DIRECTORY packaged)
file(REMOVE_RECURSE prepared)
file(MAKE_DIRECTORY prepared/qube_game)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/bin/ DESTINATION prepared/qube_game/)
file(COPY ../asset DESTINATION prepared/qube_game/)
file(COPY ../README.md ../LICENSE ../CONTRIBUTORS ../INSTALL.md DESTINATION prepared/qube_game/)
if(WIN32)
file(COPY ../package_lib/win/ DESTINATION prepared/qube_game/.)
endif()
if(WIN32)
set(ARCHIVE_FILE_TYPE zip)
else()
set(ARCHIVE_FILE_TYPE zip)
set(ARCHIVE_ARGS FORMAT zip)
endif()
#file(ARCHIVE_CREATE OUTPUT packaged/${EXE_NAME}.${ARCHIVE_FILE_TYPE}
# PATHS prepared/qube_game/
# ${ARCHIVE_ARGS})
execute_process(COMMAND tar -acf ../packaged/${EXE_NAME}.${ARCHIVE_FILE_TYPE} qube_game
WORKING_DIRECTORY prepared)