-
Notifications
You must be signed in to change notification settings - Fork 52
/
CMakeLists.txt
117 lines (99 loc) · 3.81 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
105
106
107
108
109
110
111
112
113
114
115
116
117
# Privexec cmake
cmake_minimum_required(VERSION 3.27)
project(Privexec)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
message(
FATAL_ERROR
"In-source builds are not allowed.
CMake would overwrite the makefiles distributed with Privexec.
Please create a directory and run cmake from there, passing the path
to this source directory as the last argument.
This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
Please delete them.")
endif()
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(PRIVEXEC_ENABLE_LTO OFF)
include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT error)
if(lto_supported)
message(STATUS "IPO/LTO supported")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(PRIVEXEC_ENABLE_LTO ON)
set(BELA_ENABLE_LTO ON)
message(STATUS "IPO/LTO enabled")
endif()
endif()
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS=1 -utf-8 -W3 -DUNICODE=1 -D_UNICODE=1 -wd26812")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS=1 -utf-8 -W3 -permissive- -Zc:__cplusplus -DUNICODE=1 -D_UNICODE=1 -wd26812"
)
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -c65001")
endif(MSVC)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
# Gen version
include(VersionFromVCS)
get_source_info(${CMAKE_CURRENT_SOURCE_DIR} PRIVEXEC_REVISION PRIVEXEC_REMOTE_URL PRIVEXEC_REFNAME)
string(TIMESTAMP PRIVEXEC_COPYRIGHT_YEAR "%Y")
# PRIVEXEC_REFNAME maybe defined by ci
if("${PRIVEXEC_REFNAME}" STREQUAL "none")
if(DEFINED ENV{PRIVEXEC_REFNAME})
set(PRIVEXEC_REFNAME $ENV{PRIVEXEC_REFNAME})
endif()
endif()
if("${PRIVEXEC_REFNAME}" MATCHES "refs/tags/*")
string(TIMESTAMP PRIVEXEC_BUILD_TIME "%Y-%m-%dT%H:%M:%SZ")
else()
set(PRIVEXEC_BUILD_TIME "none")
endif()
if(DEFINED ENV{GITHUB_RUN_NUMBER})
set(PRIVEXEC_VERSION_BUILD $ENV{GITHUB_RUN_NUMBER})
message(STATUS "Privexec detect GITHUB_RUN_NUMBER: $ENV{GITHUB_RUN_NUMBER}")
else()
set(PRIVEXEC_VERSION_BUILD 261)
endif()
#
set(PRIVEXEC_VERSION_MAJOR 5)
set(PRIVEXEC_VERSION_MINOR 1)
set(PRIVEXEC_VERSION_PATCH 0)
set(PACKAGE_VERSION "${PRIVEXEC_VERSION_MAJOR}.${PRIVEXEC_VERSION_MINOR}.${PRIVEXEC_VERSION_PATCH}")
string(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" COMPILER_ARCH_ID)
set(CPACK_SYSTEM_NAME "win-${COMPILER_ARCH_ID}")
set(CPACK_PACKAGE_NAME "Privexec")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Privexec")
set(CPACK_PACKAGE_VERSION_MAJOR ${PRIVEXEC_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PRIVEXEC_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PRIVEXEC_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_PACKAGE_VENDOR "Privexec")
set(CPACK_PACKAGE_CONTACT "Privexec contributors")
include(CPack)
# Generate version code
configure_file(${CMAKE_SOURCE_DIR}/include/baseversion.h.cmake ${CMAKE_BINARY_DIR}/include/baseversion.h)
include_directories(
"${CMAKE_BINARY_DIR}/include"
./include
./vendor/bela/include
./vendor/pugixml
./lib/exec)
configure_file("config/Privexec.json" "${CMAKE_BINARY_DIR}/bin/Privexec.json" COPYONLY)
install(FILES "config/Privexec.json" DESTINATION .)
# File context menu integration script
install(FILES "script/runassys.bat" DESTINATION script)
install(FILES "script/runassys.ps1" DESTINATION script)
install(FILES "script/runasti.bat" DESTINATION script)
install(FILES "script/runasti.ps1" DESTINATION script)
install(FILES "script/uninstall.bat" DESTINATION script)
add_subdirectory(vendor/bela)
add_subdirectory(lib/exec)
add_subdirectory(AppExec)
add_subdirectory(Privexec)
add_subdirectory(wsudo)
if(NOT PRIVEXEC_ENABLE_LTO)
add_subdirectory(test/apc)
endif()