-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
34 lines (27 loc) · 1.09 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
cmake_minimum_required(VERSION 3.13.4)
project(CMAKE)
# Set C++ standard to C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set build type to Release (this is the optimized build type)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Create an executable target
add_executable(${PROJECT_NAME} main.cpp)
# Add a subdirectory for modules
add_subdirectory(modules)
# Include and link modules to the main target
target_include_directories(${PROJECT_NAME} PRIVATE modules)
target_link_libraries(${PROJECT_NAME} PRIVATE modules)
# Set compiler-specific flags for performance optimization
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# For GCC (G++) compiler
target_compile_options(${PROJECT_NAME} PRIVATE "-O3") # Maximum optimization level
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# For Clang compiler
target_compile_options(${PROJECT_NAME} PRIVATE "-O3") # Maximum optimization level
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# For Visual Studio compiler
target_compile_options(${PROJECT_NAME} PRIVATE "/O2") # Maximum optimization level
endif()