-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
140 lines (118 loc) · 4.44 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
cmake_minimum_required(VERSION 3.9.4)
set(Wololokingdoms_INSTALLER WololoKingdoms)
set(CMAKE_CXX_STANDARD 17)
project(WololoKingdoms)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/libwololokingdoms/cmake/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# Create code from a list of Qt designer ui files
set(CMAKE_AUTOUIC ON)
# Find the QtWidgets library
find_package(Qt5Widgets REQUIRED)
if (CMAKE_BUILD_TYPE EQUAL RELEASE)
include(CheckIPOSupported)
check_ipo_supported(RESULT ENABLE_LTO OUTPUT error)
endif()
set(WK_STATIC_BUILD 1)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libwololokingdoms/)
if (MSVC)
if (CMAKE_BUILD_TYPE EQUAL "Release")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MT")
endif()
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
endif()
add_custom_target(build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if (${CMAKE_SIZEOF_VOID_P} EQUAL "8")
if (WIN32)
set(Steam_API_NAME steam_api64)
set(Steam_API_SO steam_api64.dll)
set(Steam_API_DIR win64/)
else()
set(Steam_API_NAME steam_api)
set(Steam_API_SO libsteam_api.so)
set(Steam_API_DIR linux64/)
endif()
else()
if (WIN32)
set(Steam_API_NAME steam_api)
set(Steam_API_SO steam_api.dll)
set(Steam_API_DIR)
else()
set(Steam_API_NAME steam_api)
set(Steam_API_SO libsteam_api.so)
set(Steam_API_DIR linux32/)
endif()
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/steam_appid.txt COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/third_party/steam_sdk/redistributable_bin/${Steam_API_DIR}${Steam_API_SO} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${Steam_API_SO} COPYONLY)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwololokingdoms/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwololokingdoms/third_party/genieutils/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwololokingdoms/third_party/pcrio/include)
if (WIN32)
add_definitions(-DICONV_SECOND_ARGUMENT_IS_CONST)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libwololokingdoms/third_party/genieutils/extern/win-iconv)
endif()
# check c++17 filesystem support
# (mingw's windows header has a bug and msvc doesn't have it)
include(HasWorkingFilesystem)
if (NOT WORKING_STD_FS)
message(WARNING "builtin filesystem is bad, falling back to gulrak/filesystem")
include_directories(libwololokingdoms/third_party/filesystem/include/)
add_definitions(-DUSE_USERLAND_FS)
endif()
if (WIN32)
add_definitions(-DNOMINMAX)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)
endif()
if(NOT MSVC)
add_definitions(-Wall -Wsign-compare -Wextra -Wpedantic)
else()
add_definitions(/wd4244 /wd4018 /wd4267 /wd4996 /wd4800)
endif()
set(ALL_SRC
main.cpp
dialog.ui
dialog.cpp
mainwindow.ui
mainwindow.cpp
wkinstaller.cpp
paths.cpp
)
if (UNIX)
set(ALL_SRC ${ALL_SRC} paths_linux.cpp)
endif()
link_directories(${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if (WIN32)
# let it know where to find the .lib
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/steam_sdk/redistributable_bin/${Steam_API_DIR})
endif()
add_executable(${Wololokingdoms_INSTALLER} ${ALL_SRC})
if (MSVC) # Check if we are using the Visual Studio compiler
set_target_properties(${Wololokingdoms_INSTALLER} PROPERTIES
WIN32_EXECUTABLE YES
LINK_FLAGS "/ENTRY:mainCRTStartup"
)
endif()
if(ENABLE_LTO)
message(STATUS "Building wololokingdoms installer with link time optimization")
set_property(TARGET ${Wololokingdoms_INSTALLER} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_link_libraries(${Wololokingdoms_INSTALLER} wololokingdoms)
target_link_libraries(${Wololokingdoms_INSTALLER} genieutils)
if (WORKING_STD_FS)
target_link_libraries(${Wololokingdoms_INSTALLER} stdc++fs)
endif()
target_link_libraries(${Wololokingdoms_INSTALLER} ${Steam_API_NAME})
# Use the Widgets module from Qt 5
target_link_libraries(${Wololokingdoms_INSTALLER} Qt5::Widgets)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:${PROJECT_NAME}>/resources)