-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
43 lines (34 loc) · 1.36 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
# Specify the minimum CMake version required
cmake_minimum_required(VERSION 3.10)
# Project name and version
project(Project VERSION 1.0)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Add the executable
# Replace main.cpp with your source files
# Collect all .cpp files in the src directory
file(GLOB SRC_FILES "src/*.cpp" "src/**/*.cpp")
# Collect all .hpp files in the src directory (for include directories, optional)
file(GLOB HEADER_FILES "src/*.hpp" "src/**/*.h")
# Add the executable with the collected source files
add_executable(Project ${SRC_FILES})
# Include directories (if you have header files in an include directory)
target_include_directories(Project PUBLIC include)
# Link libraries (if your project depends on external libraries)
# target_link_libraries(MyProject PRIVATE SomeLibrary)
# Set build type (optional: Debug, Release, RelWithDebInfo, MinSizeRel)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
# Add compiler warnings (optional but recommended)
if (MSVC)
target_compile_options(Project PRIVATE /W4)
else()
target_compile_options(Project PRIVATE -Wall -Wextra -pedantic)
endif()
# Optionally, add tests (if your project has tests)
# enable_testing()
# add_executable(MyTests test/main_test.cpp)
# target_link_libraries(MyTests PRIVATE MyProject)
# add_test(NAME RunTests COMMAND MyTests)