-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
CMakeLists.txt
100 lines (81 loc) · 2.36 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(mcmap LANGUAGES CXX VERSION 3.0.1)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
OPTION(DEBUG_BUILD "Debug build" OFF)
IF(STATIC_BUILD)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBS OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
ENDIF()
FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(fmt REQUIRED)
FIND_PACKAGE(spdlog REQUIRED)
FIND_PACKAGE(OpenMP)
FIND_PACKAGE(GTest)
FIND_PACKAGE(Qt6 COMPONENTS Widgets LinguistTools)
FIND_PACKAGE(Git)
IF (Git_FOUND)
# Copy the git index to a random unused file to trigger a reconfigure
# when it changes: this allows to always have an up-to-date string in
# GIT_DESCRIBE set below
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/.git/index"
"${CMAKE_BINARY_DIR}/.git_index"
COPYONLY)
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" describe --always HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE GIT_DESCRIBE
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF()
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
INCLUDE_DIRECTORIES(src/include)
IF (NOT WIN32)
ADD_COMPILE_OPTIONS(-Wall -Wextra -pedantic)
ENDIF()
ADD_DEFINITIONS(
-DSPDLOG_FMT_EXTERNAL=1
-D_FILE_OFFSET_BITS=64
-DCXX_COMPILER_ID="${CMAKE_CXX_COMPILER_ID}"
-DCXX_COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}"
)
IF(DEBUG_BUILD)
ADD_COMPILE_OPTIONS(-O0 -g3)
ADD_DEFINITIONS(-DDEBUG_BUILD)
ELSE()
ADD_COMPILE_OPTIONS(-O3)
ENDIF()
IF(WIN32)
# 100M stack + 3.5G heap on windows
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:104857600 /HEAP:3758096384")
ADD_DEFINITIONS(-D_WINDOWS)
ENDIF()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")
ADD_LINK_OPTIONS(-lstdc++fs)
ENDIF()
ENDIF()
# Get file URL DEST MD5
FUNCTION(GET_FILE)
FILE(
DOWNLOAD
${ARGV0}
${ARGV1}
EXPECTED_HASH ${ARGV2}
STATUS DL_STATUS
)
LIST(GET DL_STATUS 0 _STATUS)
IF(_STATUS)
LIST(GET DL_STATUS 1 _ERROR)
MESSAGE("Error downloading ${ARGV0}: ${_ERROR}")
ELSE()
MESSAGE("-- Successfully downloaded ${ARGV0}")
ENDIF()
ENDFUNCTION()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(scripts)
ADD_SUBDIRECTORY(tests)