-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
103 lines (82 loc) · 3.32 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
101
102
103
cmake_minimum_required(VERSION 3.16)
project(sqfvm)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MACOSX_RPATH 1)
# Enable multithreaded compilation in MSVC
if (MSVC)
add_definitions(/MP /W4 /wd4100)
else()
add_definitions(-Wall -Wno-unknown-pragmas)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_link_options(-static-libstdc++ -static-libgcc)
endif()
endif()
# Add the filesystem library if we are building on Clang or GCC
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(ST_CXXFS_LIBS stdc++fs)
endif()
set(ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output)
set(LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output)
set(RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/output)
include_directories("${PROJECT_SOURCE_DIR}/include/tclap-1.2.2/include")
option(SQFVM_ENABLE_SQC_SUPPORT "ENABLE SQC SUPPORT IN BUILD" OFF)
option(SQFVM_ENABLE_FULL_DIAGNOSE "ENABLE FULL DIAGNOSTICS" OFF)
option(SQFVM_ENABLE_ARMA2_LOCALKEYWORD "ENABLE ARMA2 LOCALKEYWORD" OFF)
#####################
## ##
## FILES SECTION ##
## ##
#####################
file(GLOB_RECURSE sqfvm_SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.hpp src/*.h src/*.hh src/*.c src/*.cc)
list(FILTER sqfvm_SOURCES EXCLUDE REGEX ".*src/unused/.*")
if (NOT SQFVM_ENABLE_SQC_SUPPORT)
list(FILTER sqfvm_SOURCES EXCLUDE REGEX ".*src/sqc/.*")
endif()
# Get the local git revision hash and put it into a header we can use
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
configure_file("${PROJECT_SOURCE_DIR}/cmake/git_sha1.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/git_sha1.cpp" @ONLY)
list(APPEND sqfvm_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/git_sha1.cpp")
############################
## ##
## DEPENDENCIES SECTION ##
## ##
############################
find_package(Threads)
add_executable(sqfvm ${sqfvm_SOURCES})
target_link_libraries(sqfvm ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${ST_CXXFS_LIBS})
target_include_directories(sqfvm PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_compile_definitions(sqfvm PRIVATE SQFVM_BUILD)
add_library(libsqfvm SHARED ${sqfvm_SOURCES})
target_include_directories(libsqfvm PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_compile_definitions(libsqfvm
PUBLIC DISABLE_CLIPBOARD
PRIVATE SQFVM_BUILD # this is a define visible only to the library itself
)
set_target_properties(libsqfvm PROPERTIES PREFIX "")
if (SQFVM_ENABLE_SQC_SUPPORT)
target_compile_definitions(sqfvm PUBLIC SQF_SQC_SUPPORT)
target_compile_definitions(libsqfvm PUBLIC SQF_SQC_SUPPORT)
endif()
if (SQFVM_ENABLE_ARMA2_LOCALKEYWORD)
target_compile_definitions(sqfvm PUBLIC SQFVM_ARMA2_SYNTAX)
target_compile_definitions(libsqfvm PUBLIC SQFVM_ARMA2_SYNTAX)
endif ()
if (SQFVM_ENABLE_FULL_DIAGNOSE)
target_compile_definitions(sqfvm PUBLIC
DF__SQF_RUNTIME__ASSEMBLY_DEBUG_ON_EXECUTE
DF__SQF_FILEIO__ALL_FILES
DF__SQF_FILEIO__TRACE_REESOLVE
DF__SQF_PREPROC__TRACE_MACRO_RESOLVE
DF__SQF_PREPROC__TRACE_MACRO_PARSE
DF__SQF_CONFIG__REPORT_PROGRESS_BY_LINE
DF__SQF_RUNTIME__VALUE_SCOPE_DEBUG
DF__CLI_PRINT_INPUT_ARGS
DF__CLI_PRINT_TCLAP_ARGUMENTS
)
endif ()
enable_testing()
add_subdirectory(tests)