forked from paolo-projects/auto-unlocker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
88 lines (67 loc) · 2.38 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
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project (Unlocker)
SET(UNLOCKER_STATIC_LIBS_WIN ON CACHE BOOL "Links statically") # Set to OFF for dynamic linking
IF (MSVC)
# prevent default manifest from being linked
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO")
ENDIF(MSVC)
find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
message (STATUS "ZLib found, version ${ZLIB_VERSION_STRING}")
endif()
include_directories(${ZLIB_INCLUDE_DIRS})
find_package(CURL REQUIRED)
if(CURL_FOUND)
message (STATUS "Curl found, version ${CURL_VERSION_STRING}")
endif()
include_directories(${CURL_INCLUDE_DIRS})
find_package(LibArchive REQUIRED)
if(LibArchive_FOUND)
message (STATUS "LibArchive found, version ${LibArchive_VERSION}")
endif()
include_directories(${LibArchive_INCLUDE_DIRS})
# main include files
include_directories ("${PROJECT_SOURCE_DIR}/include")
# main source files
set (SOURCE_FILES src/unlocker.cpp /
src/versionparser.cpp /
src/buildsparser.cpp /
src/archiveutils.cpp /
src/netutils.cpp /
src/debugutils.cpp /
src/installinfoutils.cpp /
src/servicestoputils.cpp /
src/patchutils.cpp /
)
IF (MSVC)
IF (UNLOCKER_STATIC_LIBS_WIN)
add_compile_definitions( "CURL_STATICLIB" "LIBARCHIVE_STATIC")
ENDIF()
ENDIF (MSVC)
add_executable(Unlocker ${SOURCE_FILES})
set_target_properties(Unlocker PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON)
set_target_properties (Unlocker PROPERTIES COMPILE_DEFINITIONS BUILDER_STATIC_DEFINE)
if(LINUX)
target_link_libraries (Unlocker -lpthread)
endif()
target_link_libraries (Unlocker ${ZLIB_LIBRARIES})
target_link_libraries (Unlocker ${CURL_LIBRARIES})
target_link_libraries (Unlocker ${LibArchive_LIBRARIES})
if(MSVC)
target_link_libraries (Unlocker "ws2_32.lib" "Wldap32.lib")
endif()
# Amend manifest to tell Windows that the app needs admin privileges
IF (MSVC)
IF (CMAKE_MAJOR_VERSION LESS 3)
MESSAGE(WARNING "CMake version 3.0 or newer is required use build variable TARGET_FILE")
ELSE()
ADD_CUSTOM_COMMAND(
TARGET Unlocker
POST_BUILD
COMMAND "mt.exe" -manifest \"${PROJECT_SOURCE_DIR}/Unlocker.exe.manifest\" -outputresource:\"$<TARGET_FILE:Unlocker>\"\;\#1
COMMENT "Embedding manifest..."
)
ENDIF()
ENDIF(MSVC)