25 lines
No EOL
870 B
CMake
25 lines
No EOL
870 B
CMake
cmake_minimum_required(VERSION 3.10) # Or a newer version if you prefer
|
|
|
|
# Get the full path to the project source directory
|
|
string(REPLACE "\\" "/" PROJECT_PATH "${CMAKE_SOURCE_DIR}") # Normalize slashes for cross-platform compatibility
|
|
|
|
# Extract the last component of the path
|
|
get_filename_component(PROJECT_NAME "${PROJECT_PATH}" NAME)
|
|
|
|
# Use the extracted name as the project name
|
|
project(${PROJECT_NAME} CXX)
|
|
|
|
# Specify the C++ standard to use (e.g., C++17)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Add your executable
|
|
add_executable(${PROJECT_NAME} main.cpp)
|
|
|
|
# Add include directories for your header files
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# Add debugging flags (important for debugging)
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
target_compile_options(${PROJECT_NAME} PRIVATE -g)
|
|
endif() |