-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
69 lines (59 loc) · 2.13 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
cmake_minimum_required(VERSION 2.8.12)
project(mxtk)
include(CompilerRuntime)
file(GLOB SOURCES_COMMON "src/common/*.cpp")
if(MSVC)
file(GLOB SOURCES_PLATFORM "src/win32/*.cpp")
else()
file(GLOB SOURCES_PLATFORM "src/qt/*.cpp")
endif()
list(APPEND SOURCES_COMMON ${SOURCES_PLATFORM})
add_library(${PROJECT_NAME} STATIC ${SOURCES_COMMON})
target_include_directories(${PROJECT_NAME} PRIVATE
"include"
)
if(NOT MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE -fno-exceptions) # GCC/Clang flag
target_compile_options(${PROJECT_NAME} PRIVATE -Wno-write-strings) # GCC/Clang flag
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden) # GCC/Clang flag
target_compile_definitions(${PROJECT_NAME} PRIVATE _LINUX=1 LINUX=1) # It seems enough for all non-Win32 systems
target_compile_definitions(${PROJECT_NAME} PRIVATE stricmp=strcasecmp strnicmp=strncasecmp)
if(NOT MINGW)
target_compile_definitions(${PROJECT_NAME} PRIVATE _snprintf=snprintf _vsnprintf=vsnprintf)
endif()
else()
# disable annoying CRT warnings
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS=1 _CRT_NONSTDC_NO_DEPRECATE=1)
endif()
if(MSVC)
# debug mode compiler flags
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:/Od>) # disable optimizing at all
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:/ZI>) # enable "Edit and Continue" MSVC feature
target_link_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:
/INCREMENTAL
/SAFESEH:NO
>)
# release mode compiler flags
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Release>:/Ob1>) # disable force function inlining, to prevent segfault in release mode
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:Release>:/O1>) # enable optimizing to minimize size
endif()
if(MSVC)
target_link_libraries(${PROJECT_NAME} PRIVATE
"shlwapi"
"comctl32"
"comdlg32"
"glu32"
"gdi32"
"opengl32"
"winmm"
)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE
"Qt5OpenGL"
"gl"
)
endif()
# set static compiler runtime
set_compiler_runtime(${PROJECT_NAME} STATIC)
set_target_properties(${PROJECT_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE 1)