-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
90 lines (84 loc) · 2.66 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
cmake_minimum_required(VERSION 3.12)
project(TileViewer)
function(config_platform TARGET_NAME)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(${TARGET_NAME} PRIVATE
X11 # must below wxWidgets
-static-libstdc++
-static-libgcc
)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") # currently only support mingw on windows
target_sources(${TARGET_NAME} PRIVATE
asset/icon/icon.rc
)
target_compile_definitions(${TARGET_NAME} PRIVATE
-D_WIN32_WINNT=0X0400
)
target_link_libraries(${TARGET_NAME} PRIVATE
-Wl,--subsystem,windows:4.0
-static-libstdc++
-static-libgcc
)
else()
message("${CMAKE_SYSTEM_NAME} enviroment for ${TARGET_NAME} not supported!")
endif()
endfunction()
# global config
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_C_COMPILER MATCHES i686 OR CMAKE_C_COMPILER MATCHES i386) # multi arch for x86
set(CMAKE_SYSTEM_LIBRARY_PATH /usr/lib/i386-linux-gnu) # this is very important
set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
set(CMAKE_IGNORE_PATH /lib /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu)
set(wxUSE_LIBJPEG OFF)
endif()
endif()
# add lua
set(LUA_CODE_DIR depend/lua-5.4.7)
add_subdirectory(${LUA_CODE_DIR})
# add wxwidgets
set(WXWIDGETS_CODE_DIR depend/wxWidgets-3.2.6)
set(wxBUILD_SHARED OFF)
set(INGORED_WARNINGS "-Wno-unused-command-line-argument -Wno-deprecated-declarations -Wno-inconsistent-missing-override -Wno-cast-calling-convention -Wno-format"
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INGORED_WARNINGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${INGORED_WARNINGS}")
add_subdirectory(${WXWIDGETS_CODE_DIR})
# define wxwidgets xrc
set(wxrc $<TARGET_FILE:wxrc>)
set(TILEVIEWER_UI_XRC
${CMAKE_SOURCE_DIR}/asset/ui/ui_main.xrc
)
set(TILEVIEWER_UI_CODE
${CMAKE_CURRENT_BINARY_DIR}/ui_resource.cpp
)
add_custom_command(
OUTPUT ${TILEVIEWER_UI_CODE}
COMMAND ${wxrc} -c -o ${TILEVIEWER_UI_CODE} ${TILEVIEWER_UI_XRC}
DEPENDS ${TILEVIEWER_UI_XRC}
DEPENDS wxrc # Not needed with the installed version.
COMMENT "Compiling XRC resources"
)
# define tileviewer
set(CMAKE_CXX_STANDARD 11)
set(TILEVIEWER_CODE
src/ui_top.cpp
src/ui_menu.cpp
src/ui_config.cpp
src/ui_tile.cpp
src/core_app.cpp
src/core_decode.c
src/core_plugin.c
)
add_executable(${PROJECT_NAME}
${TILEVIEWER_CODE}
)
target_include_directories(${PROJECT_NAME} PRIVATE
${LUA_CODE_DIR}/src
)
target_link_libraries(${PROJECT_NAME} PRIVATE
lua
wx::core
wx::base
wx::propgrid
)
config_platform(${PROJECT_NAME})