Add CMakeLists.txt and build script

This commit is contained in:
stefiosif
2024-08-03 13:14:07 +03:00
parent f5b48bbafd
commit d216a9611f
6 changed files with 86 additions and 118 deletions

63
.gitattributes vendored
View File

@@ -1,63 +1,2 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
*.h linguist-language=C++

27
.gitignore vendored
View File

@@ -1,26 +1,3 @@
.vs/
.vscode/
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Bb]in/
[Bb]uild/
# MVS Created files
*.rsuser
*.suo
*.userosscache
*.sln.docstates
*.hint
*.vcxproj
*.vcxproj.user
*.vcxproj.filters
.cache/
build/

45
CMakeLists.txt Normal file
View File

@@ -0,0 +1,45 @@
cmake_minimum_required(VERSION 3.10)
# Project name and version
project(DynamicGraphAlgorithms VERSION 1.0)
# Set the C++ standard to C++20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Enable compile commands generation
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Specify the include directories
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/third_party/nanobench
${PROJECT_SOURCE_DIR}/third_party/doctest
)
# Gather all header files from include/algorithm and include/graph directories
file(GLOB_RECURSE ALGORITHM_HEADER_FILES ${PROJECT_SOURCE_DIR}/include/algorithm/*.h)
file(GLOB_RECURSE GRAPH_HEADER_FILES ${PROJECT_SOURCE_DIR}/include/graph/*.h)
file(GLOB_RECURSE RODITTY_ZWICK_HEADER ${PROJECT_SOURCE_DIR}/include/roditty_zwick.h)
# Gather all source files from src directory
file(GLOB_RECURSE SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.cc)
# Debugging output to ensure files are found
message(STATUS "Algorithm headers: ${ALGORITHM_HEADER_FILES}")
message(STATUS "Graph headers: ${GRAPH_HEADER_FILES}")
message(STATUS "Roditty-Zwick header: ${RODITTY_ZWICK_HEADER}")
message(STATUS "Source files: ${SOURCE_FILES}")
message(STATUS "Include directories: ${PROJECT_SOURCE_DIR}/include, ${PROJECT_SOURCE_DIR}/third_party/nanobench/src/include, ${PROJECT_SOURCE_DIR}/third_party/doctest/doctest")
# Add the executable target
if(SOURCE_FILES)
add_executable(DynamicGraphAlgorithms ${SOURCE_FILES} ${ALGORITHM_HEADER_FILES} ${GRAPH_HEADER_FILES} ${RODITTY_ZWICK_HEADER})
else()
message(FATAL_ERROR "No source files found. Please add at least one .cpp or .cc file to the src directory.")
endif()
# Link libraries if necessary (e.g., Boost, Abseil, etc.)
# find_package(Boost REQUIRED) # Example for Boost
# target_link_libraries(DynamicGraphAlgorithms Boost::Boost) # Link Boost

View File

@@ -41,6 +41,7 @@ Clone the repository with submodules (doctest/nanobench):
```bash
git clone --recurse-submodules https://github.com/stefiosif/dynamic-reachability-algorithms
cd dynamic-reachability-algorithms
./build_project.sh
```
## References

37
build_project.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Define the build directory
BUILD_DIR="build"
# Remove the existing build directory if it exists
if [ -d "$BUILD_DIR" ]; then
echo "Removing existing build directory..."
rm -rf "$BUILD_DIR"
fi
# Create a new build directory
echo "Creating build directory..."
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" || exit
# Run CMake to configure the project
echo "Configuring the project with CMake..."
cmake ..
# Check if CMake configuration was successful
if [ $? -ne 0 ]; then
echo "CMake configuration failed!"
exit 1
fi
# Build the project
echo "Building the project..."
make
# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Build failed!"
exit 1
fi
echo "Build completed successfully!"

View File

@@ -1,31 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32421.90
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dynamic-reachability-algorithms", "dynamic-reachability-algorithms.vcxproj", "{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Debug|x64.ActiveCfg = Debug|x64
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Debug|x64.Build.0 = Debug|x64
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Debug|x86.ActiveCfg = Debug|Win32
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Debug|x86.Build.0 = Debug|Win32
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Release|x64.ActiveCfg = Release|x64
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Release|x64.Build.0 = Release|x64
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Release|x86.ActiveCfg = Release|Win32
{1CB6022E-575B-4DA3-9AB6-0EE7090A56C8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {940035A3-C111-4769-BB27-9285F4CDDA52}
EndGlobalSection
EndGlobal