-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
76 lines (62 loc) · 1.97 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
cmake_minimum_required(VERSION 3.14)
project(Wireless_Systems_Design VERSION 1.0)
# Set C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set optimization flags for different build types
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Debug build flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g") # No optimization, include debug information
message(STATUS "Debug Build")
else() #(CMAKE_BUILD_TYPE STREQUAL "Release")
# Release build flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") # Highest level of optimization
message(STATUS "Release Build")
endif()
# FetchContent is available from CMake 3.11 onwards
include(FetchContent)
# Fetch and build jsoncpp if not found
FetchContent_Declare(
jsoncpp
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp.git
GIT_TAG master
)
FetchContent_GetProperties(jsoncpp)
if(NOT jsoncpp_POPULATED)
FetchContent_Populate(jsoncpp)
add_subdirectory(${jsoncpp_SOURCE_DIR} ${jsoncpp_BINARY_DIR})
endif()
# Fetch and make available argparse
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/morrisfranken/argparse.git
)
FetchContent_MakeAvailable(argparse)
# Add your source files here
set(SOURCES
source/src/project.cpp
# Add other source files here if any
)
# Create executable
add_executable(${PROJECT_NAME} ${SOURCES})
# Link libraries
target_link_libraries(${PROJECT_NAME}
PRIVATE
jsoncpp_lib
argparse
)
# Include directories for header files
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/source/inc
)
# Optionally, set compiler flags
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)
endif()
execute_process(COMMAND date OUTPUT_VARIABLE time)
message(STATUS "-----------------------------------------------")
message(STATUS "\n${CMAKE_BUILD_TYPE} Build Done ${time}")