Improve build (CMake)
This commit is contained in:
parent
5ee5c5cb2e
commit
9fc63b3e00
3 changed files with 23 additions and 9 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,6 +1,9 @@
|
||||||
/build/
|
/build/
|
||||||
/.cache/
|
/.cache/
|
||||||
|
|
||||||
|
/cmake_install.cmake
|
||||||
|
/build.ninja
|
||||||
|
/.ninja_*
|
||||||
|
|
||||||
CMakeFiles/
|
CMakeFiles/
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
cmake_install.cmake
|
|
||||||
build.ninja
|
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
cmake_minimum_required(VERSION 3.10) # Or a newer version if you prefer
|
cmake_minimum_required(VERSION 3.10) # Or a newer version if you prefer
|
||||||
|
|
||||||
project(RingBufferTest CXX)
|
# 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)
|
# Specify the C++ standard to use (e.g., C++17)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
# Add your executable
|
# Add your executable
|
||||||
add_executable(ringbuffer_test main.cpp ringbuffer.cpp)
|
add_executable(${PROJECT_NAME} main.cpp ringbuffer.cpp)
|
||||||
|
|
||||||
# Add include directories for your header files
|
# Add include directories for your header files
|
||||||
target_include_directories(ringbuffer_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
# Add debugging flags (important for debugging)
|
# Add debugging flags (important for debugging)
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
target_compile_options(ringbuffer_test PRIVATE -g)
|
target_compile_options(${PROJECT_NAME} PRIVATE -g)
|
||||||
endif()
|
endif()
|
|
@ -9,7 +9,7 @@
|
||||||
{
|
{
|
||||||
"name": "base",
|
"name": "base",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"generator": "Ninja", // Or "Unix Makefiles", "MinGW Makefiles", etc.
|
"generator": "Ninja",
|
||||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_CXX_STANDARD": "17",
|
"CMAKE_CXX_STANDARD": "17",
|
||||||
|
@ -22,7 +22,11 @@
|
||||||
"displayName": "Debug Build",
|
"displayName": "Debug Build",
|
||||||
"inherits": "base",
|
"inherits": "base",
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"CMAKE_VERBOSE_MAKEFILE": {
|
||||||
|
"type": "BOOL",
|
||||||
|
"value": "ON"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -52,7 +56,7 @@
|
||||||
{
|
{
|
||||||
"name": "default",
|
"name": "default",
|
||||||
"displayName": "Run Tests",
|
"displayName": "Run Tests",
|
||||||
"configurePreset": "debug", // Use the debug configuration for running tests
|
"configurePreset": "debug",
|
||||||
"output": {
|
"output": {
|
||||||
"outputOnFailure": true
|
"outputOnFailure": true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue