-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
188 lines (153 loc) · 7.87 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
cmake_minimum_required(VERSION 3.10)
# For Clang to do parsing
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(runcpp2)
set(CMAKE_CXX_STANDARD 11)
option(RUNCPP2_UPDATE_DEFAULT_YAMLS "Update default yaml files" OFF)
option(RUNCPP2_BUILD_TESTS "Build runcpp2 tests" OFF)
# =========================================================================
# Retrieving Version String
# =========================================================================
function(get_version_from_git OUTPUT_VARIABLE)
# Get the latest tag
execute_process(
COMMAND git describe --tags --abbrev=0
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE GIT_TAG_RESULT
ERROR_QUIET
)
# Get the current commit hash
execute_process(
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if(GIT_TAG_RESULT EQUAL 0)
# Check if the tag is on the current commit
execute_process(
COMMAND git describe --tags --exact-match
RESULT_VARIABLE TAG_ON_COMMIT
OUTPUT_QUIET
ERROR_QUIET
)
if(TAG_ON_COMMIT EQUAL 0)
set(VERSION ${GIT_TAG})
else()
set(VERSION "${GIT_TAG}-${GIT_COMMIT_HASH}")
endif()
else()
# No tags found, use v0.0.0 with commit hash
set(VERSION "v0.0.0-${GIT_COMMIT_HASH}")
endif()
set(${OUTPUT_VARIABLE} ${VERSION} PARENT_SCOPE)
endfunction()
# Call the function and store the result
get_version_from_git(RUNCPP2_PROJECT_VERSION)
message("RUNCPP2_PROJECT_VERSION: ${RUNCPP2_PROJECT_VERSION}")
# =========================================================================
# External Dependencies
# =========================================================================
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/ssLogger")
set(RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS ON CACHE BOOL "" FORCE)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/rapidyaml")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/filesystem")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/System2")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/dylib")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/variant")
# Copy cfgpath.h
configure_file( "${CMAKE_CURRENT_LIST_DIR}/External/cfgpath/cfgpath.h"
"${CMAKE_CURRENT_LIST_DIR}/Include/cfgpath.h" COPYONLY)
if(RUNCPP2_BUILD_TESTS)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/ssTest")
endif()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/CppOverride")
# =========================================================================
# Generate yaml files as c
# =========================================================================
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c")
set(EMBEDDED_FILE_SIZE 0)
else()
file(SIZE "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c" EMBEDDED_FILE_SIZE)
endif()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C")
if(RUNCPP2_UPDATE_DEFAULT_YAMLS OR EMBEDDED_FILE_SIZE LESS 1024)
include("${CMAKE_CURRENT_LIST_DIR}/External/Embed2C/embedFile.cmake")
set(EMBED_EXEC_PATH "")
GET_EXEC_PATH(EMBED_EXEC_PATH)
if("${EMBED_EXEC_PATH}" STREQUAL "")
message(WARNING "Please build Embed2C first")
return()
else()
set(FILES_TO_EMBED "${CMAKE_CURRENT_LIST_DIR}/DefaultYAMLs/DefaultUserConfig.yaml"
"DefaultUserConfig"
"${CMAKE_CURRENT_LIST_DIR}/DefaultYAMLs/DefaultScriptInfo.yaml"
"DefaultScriptInfo"
)
EMBED_FILES("${EMBED_EXEC_PATH}"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c"
"${FILES_TO_EMBED}")
endif()
endif()
# =========================================================================
# runcpp2
# =========================================================================
add_library(runcpp2 STATIC
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/Profile.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencyInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencyLinkProperty.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/DependencySource.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/GitSource.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/LocalSource.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FileProperties.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FlagsOverrideInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCommands.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesFlagsOverride.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ScriptInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesProcessPaths.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesTypesInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesDefines.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesToCopyInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ProfileHelper.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/CompilingLinking.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ConfigParsing.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DefaultYAMLs.c"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/DependenciesHelper.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ParseUtil.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PlatformUtil.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/StringUtil.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/runcpp2.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/BuildsManager.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/PipelineSteps.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/IncludeManager.cpp"
)
target_include_directories(runcpp2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}/Include")
target_link_libraries(runcpp2 PRIVATE ssLogger System2 CppOverride dylib)
target_link_libraries(runcpp2 PUBLIC ghc_filesystem ryml::ryml mpark_variant)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(STANDARD_COMPILE_FLAGS "/utf-8;/W1;/DGHC_WIN_DISABLE_WSTRING_STORAGE_TYPE=1")
else()
set(STANDARD_COMPILE_FLAGS "-Wall"
"-Wno-return-local-addr"
"-Wno-sign-compare"
#"-Wno-unused-variable"
#"-Wno-unused-but-set-variable"
"-Wno-unused-parameter"
"-Wno-switch"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wextra"
"-pedantic"
"-Werror")
endif()
target_compile_options(runcpp2 PRIVATE "${STANDARD_COMPILE_FLAGS}")
# Define the version macro
target_compile_definitions(runcpp2 PUBLIC RUNCPP2_VERSION="${RUNCPP2_PROJECT_VERSION}")
add_executable(runcpp2_main "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/main.cpp")
target_compile_options(runcpp2_main PRIVATE "${STANDARD_COMPILE_FLAGS}")
target_link_libraries(runcpp2_main PRIVATE runcpp2 ssLogger ghc_filesystem)
set_target_properties(runcpp2_main PROPERTIES OUTPUT_NAME "runcpp2")
if(RUNCPP2_BUILD_TESTS)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Src/Tests")
endif()