This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
macros.cmake
76 lines (65 loc) · 1.97 KB
/
macros.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
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
if ((CMAKE_HOST_UNIX) AND (${CMAKE_HOST_SYSTEM_NAME} MATCHES "CYGWIN*"))
set(CYGWIN 1)
set(WIN 1)
# specify the cross compiler
set(CMAKE_TOOLCHAIN_PREFIX x86_64-w64-mingw32)
SET(CMAKE_C_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-clang)
SET(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-clang++)
SET(CMAKE_RC_COMPILER ${CMAKE_TOOLCHAIN_PREFIX}-windres)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)
endif()
macro(addLibraryWithRPATH NAME)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@executable_path/Plugins")
add_library(${NAME} SHARED ${ARGN})
set_target_properties(${NAME} PROPERTIES MACOSX_RPATH ON)
set_target_properties(${NAME} PROPERTIES INSTALL_NAME_DIR "@executable_path/Plugins")
endmacro()
macro(get_commit_hash VARNAME)
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ${VARNAME}
OUTPUT_STRIP_TRAILING_WHITESPACE)
endmacro()
macro(get_git_describe VARNAME)
execute_process(
COMMAND git describe --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ${VARNAME}
OUTPUT_STRIP_TRAILING_WHITESPACE)
endmacro()
macro(get_git_date VARNAME)
execute_process(
COMMAND git log -1 --format=%ai
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ${VARNAME}
OUTPUT_STRIP_TRAILING_WHITESPACE)
endmacro()
macro(get_platform_name VARNAME)
if(WIN)
set(${VARNAME} "win")
else()
if(OSX)
set(${VARNAME} "osx")
else()
set(${VARNAME} "linux")
endif()
endif()
endmacro()
macro(get_full_platform_name VARNAME)
if(SIZEOF_VOID_P EQUAL 8)
set(ARCH 64)
else()
set(ARCH 32)
endif()
if(WIN)
set(${VARNAME} "win${ARCH}")
else()
if(OSX)
set(${VARNAME} "osx${ARCH}")
else()
set(${VARNAME} "linux${ARCH}")
endif()
endif()
endmacro()