-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (55 loc) · 2.38 KB
/
CMakeLists.txt
File metadata and controls
75 lines (55 loc) · 2.38 KB
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
cmake_minimum_required(VERSION 3.15)
project(xpmgr CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCES xpmgr.cpp)
set(LIB_SOURCES xpmgr_lib.cpp)
# ==== x86 build ====
# Static library for x86
add_library(xpmgr_static_x86 STATIC ${LIB_SOURCES})
target_compile_options(xpmgr_static_x86 PRIVATE -m32)
target_link_libraries(xpmgr_static_x86 PRIVATE ole32 oleaut32 uuid)
set(RES_X86 ${CMAKE_BINARY_DIR}/icon_x86.res)
# Create a custom target for the x86 resource compilation
add_custom_command(
OUTPUT ${RES_X86}
COMMAND windres -F pe-i386 -O coff ${CMAKE_SOURCE_DIR}/icon.rc -o ${RES_X86}
DEPENDS ${CMAKE_SOURCE_DIR}/icon.rc ${CMAKE_SOURCE_DIR}/icon.ico
COMMENT "Compiling icon.rc for x86"
)
add_custom_target(xpmgr_x86_res ALL DEPENDS ${RES_X86})
# Now define the executable and link dependencies
add_executable(xpmgr_x86 ${SOURCES})
add_dependencies(xpmgr_x86 xpmgr_x86_res)
target_compile_options(xpmgr_x86 PRIVATE -m32)
target_link_options(xpmgr_x86 PRIVATE -m32)
# Link .res file and static library
target_link_libraries(xpmgr_x86 PRIVATE ole32 oleaut32 uuid xpmgr_static_x86)
target_link_options(xpmgr_x86 PRIVATE -Wl,--subsystem,console ${RES_X86})
# ==== x64 build ====
# Static library for x64
add_library(xpmgr_static_x64 STATIC ${LIB_SOURCES})
target_compile_options(xpmgr_static_x64 PRIVATE -m64)
target_link_libraries(xpmgr_static_x64 PRIVATE ole32 oleaut32 uuid)
set(RES_X64 ${CMAKE_BINARY_DIR}/icon_x64.res)
# Create a custom target for the x64 resource compilation
add_custom_command(
OUTPUT ${RES_X64}
COMMAND windres -O coff ${CMAKE_SOURCE_DIR}/icon.rc -o ${RES_X64}
DEPENDS ${CMAKE_SOURCE_DIR}/icon.rc ${CMAKE_SOURCE_DIR}/icon.ico
COMMENT "Compiling icon.rc for x64"
)
add_custom_target(xpmgr_x64_res ALL DEPENDS ${RES_X64})
# Now define the executable and link dependencies
add_executable(xpmgr_x64 ${SOURCES})
add_dependencies(xpmgr_x64 xpmgr_x64_res)
target_compile_options(xpmgr_x64 PRIVATE -m64)
target_link_options(xpmgr_x64 PRIVATE -m64)
# Link .res file and static library
target_link_libraries(xpmgr_x64 PRIVATE ole32 oleaut32 uuid xpmgr_static_x64)
target_link_options(xpmgr_x64 PRIVATE -Wl,--subsystem,console ${RES_X64})
# Install targets
install(TARGETS xpmgr_static_x86 xpmgr_static_x64
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
install(FILES xpmgr.h DESTINATION include)