-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
44 lines (35 loc) · 1.34 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
cmake_minimum_required(VERSION 3.9.0)
project(Minecraft-server-query VERSION 0.1.0 LANGUAGES C)
link_libraries("-static")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
message(STATUS "GCC")
add_compile_options(-ffunction-sections -fdata-sections)
endif()
add_subdirectory(extern/plibsys)
include_directories(include)
add_library(Minecraft-server-query STATIC src/main.c src/error.c)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(Minecraft-server-query PRIVATE -Wl,--gc-sections)
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output LANGUAGES C)
if(result)
message(STATUS "IPO is supported")
set_property(TARGET Minecraft-server-query PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(WARNING "IPO is not supported: ${output}")
endif()
target_link_libraries(Minecraft-server-query plibsysstatic)
option(BUILD_EXAMPLE_IMPLEMENTATION "Build example" ON)
if (BUILD_EXAMPLE_IMPLEMENTATION)
message(STATUS "Build example")
add_executable(msq_example example/main.c)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_link_options(msq_example PRIVATE -Wl,--gc-sections -s)
endif()
if(result)
set_property(TARGET msq_example PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
target_link_libraries(msq_example Minecraft-server-query)
install(TARGETS msq_example)
endif()