-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
131 lines (103 loc) · 4.33 KB
/
Copy pathCMakeLists.txt
File metadata and controls
131 lines (103 loc) · 4.33 KB
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
#==============================================================================
# Copyright (c) 2025 Ajeet Singh Yadav. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License")
#
# Author: Ajeet Singh Yadav
# Created: January 2025
#
# Autodoc: yes
#==============================================================================
cmake_minimum_required(VERSION 3.16)
project(vneutils VERSION 1.0.0 LANGUAGES CXX)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
#==============================================================================
# Add custom CMake modules path
#==============================================================================
# VneCMake shared modules (submodule)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/vnecmake/modules")
# Project-specific modules
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
#==============================================================================
# Project Setup
#==============================================================================
include(ProjectSetup)
#==============================================================================
# Build Options
#==============================================================================
option(BUILD_TESTS "Build the test suite" ON)
option(BUILD_EXAMPLES "Build example programs" OFF)
# Enable cache system
option(ENABLE_CACHE "Enable compiler cache if available" OFF)
include(CCache)
# Enable static code analysis tools options
option(ENABLE_CPPCHECK "Enable static analysis with cppcheck" OFF)
include(CppCheck)
option(ENABLE_CLANG_TIDY "Enable static analysis with clang-tidy" OFF)
include(ClangTidy)
# Enable coverage
include(FindCoverage)
#==============================================================================
# Compiler Warnings
#==============================================================================
add_library(UtilsWarnings INTERFACE)
include(ProjectWarnings)
set_project_warnings(UtilsWarnings)
add_library(vne::utils::Warnings ALIAS UtilsWarnings)
#==============================================================================
# Build Settings Interface Library
#==============================================================================
add_library(UtilsBuildSettings INTERFACE)
add_library(vne::utils::BuildSettings ALIAS UtilsBuildSettings)
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(UtilsBuildSettings INTERFACE VNE_BUILD_TYPE_DEBUG VNE_DEVELOPER_BUILD)
elseif(CMAKE_BUILD_TYPE MATCHES Release)
target_compile_definitions(UtilsBuildSettings INTERFACE VNE_BUILD_TYPE_RELEASE)
endif()
#==============================================================================
# Include Directories
#==============================================================================
set(VNE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(VNE_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
#==============================================================================
# Library
#==============================================================================
add_library(vneutils STATIC
src/command_line_parser.cpp
)
add_library(vne::utils ALIAS vneutils)
target_include_directories(vneutils
PUBLIC
$<BUILD_INTERFACE:${VNE_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>
PRIVATE
${VNE_SRC_DIR}
)
target_link_libraries(vneutils
PRIVATE
vne::utils::Warnings
vne::utils::BuildSettings
)
#==============================================================================
# Platform-specific linking
#==============================================================================
# Threads::Threads is portable (pthread on Unix/Android; no separate libpthread on Android NDK).
if(NOT WIN32 AND NOT EMSCRIPTEN)
find_package(Threads REQUIRED)
target_link_libraries(vneutils PRIVATE Threads::Threads)
endif()
#==============================================================================
# Tests
#==============================================================================
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
#==============================================================================
# Examples
#==============================================================================
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()