Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
56 lines (44 loc) · 1.51 KB
/
Copy pathCMakeLists.txt
File metadata and controls
56 lines (44 loc) · 1.51 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
cmake_minimum_required(VERSION 3.16)
project(METLKR LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(METLKR main.cpp)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(METLKR PRIVATE
-Os
-fno-ident
-fno-exceptions
-fno-rtti
-ffunction-sections
-fdata-sections
-flto
)
target_link_options(METLKR PRIVATE
-s
-Wl,--gc-sections
-flto
)
if(WIN32)
target_link_options(METLKR PRIVATE -static-libgcc)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(METLKR PRIVATE -Wl,--subsystem,console:5.01)
set_target_properties(METLKR PROPERTIES OUTPUT_NAME "METLKR_Win_i686")
else()
target_link_options(METLKR PRIVATE -Wl,--subsystem,console:5.02)
set_target_properties(METLKR PROPERTIES OUTPUT_NAME "METLKR_Win_x86-64")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(METLKR PRIVATE -static-libstdc++)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set_target_properties(METLKR PROPERTIES OUTPUT_NAME "METLKR_Linux_i686")
else()
set_target_properties(METLKR PROPERTIES OUTPUT_NAME "METLKR_Linux_x86-64")
endif()
endif()
endif()
include(GNUInstallDirs)
install(TARGETS METLKR
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)