-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (86 loc) · 2.22 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
cmake_minimum_required(VERSION 3.27)
include(${CMAKE_SOURCE_DIR}/cmake/baking.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/compile_flags.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/dependencies.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/tidy.cmake)
include(FetchContent)
project(haru VERSION 0.4.1 LANGUAGES CXX)
set(NINJA_MULTICONFIG (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config"))
fetch_project_dependencies()
set(PROJECT_SOURCES
src/args_parser.cpp
src/cmake.cpp
src/cmake_lists_generator.cpp
src/command.cpp
src/config.cpp
src/error.cpp
src/file_operations.cpp
src/log.cpp
src/main.cpp
src/post_ops.cpp
src/project_info.cpp
src/utils.cpp
)
add_bake_in_files()
add_executable(
${PROJECT_NAME}
${PROJECT_SOURCES}
${BAKE_IN}
)
target_compile_definitions(
${PROJECT_NAME}
PRIVATE
HARU_PRG_NAME="${PROJECT_NAME}"
)
target_compile_definitions(
${PROJECT_NAME}
PRIVATE
HARU_VERSION="${PROJECT_VERSION}"
)
set_target_properties(
${PROJECT_NAME}
PROPERTIES
CXX_STANDARD
23
CXX_STANDARD_REQUIRED
TRUE
)
add_project_compile_flags(${PROJECT_NAME})
link_project_dependencies(${PROJECT_NAME})
add_clang_tidy(${PROJECT_NAME} ${CMAKE_CURRENT_BINARY_DIR})
if(NINJA_MULTICONFIG)
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOLOWER ${CONFIG} BUILD_NAME)
add_custom_target(
"run-${BUILD_NAME}"
COMMAND
${CMAKE_COMMAND} -E env
"${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${PROJECT_NAME}"
USES_TERMINAL
VERBATIM
DEPENDS
${PROJECT_NAME}:$<CONFIG>
)
endforeach()
endif()
add_custom_target(
run
COMMAND
${CMAKE_COMMAND} -E env "$<TARGET_FILE:${PROJECT_NAME}>"
USES_TERMINAL
VERBATIM
DEPENDS
${PROJECT_NAME}:$<CONFIG>
)
if(NINJA_MULTICONFIG)
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOLOWER ${CONFIG} CONFIG)
add_custom_target(
${CONFIG}
COMMAND
${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}"
"--config" "${CONFIG}"
USES_TERMINAL
)
endforeach()
endif()