From 179c6227a89ff80bec348e46aba934265a22cf50 Mon Sep 17 00:00:00 2001 From: rasmartguy Date: Fri, 29 Mar 2019 22:33:29 +0300 Subject: [PATCH 1/2] :art: change repo to be useful as external library --- .gitignore | 1 + CMakeLists.txt | 10 +++++++--- main.cpp => example/main.cpp | 0 {source => incl/a-star}/AStar.hpp | 0 source/AStar.cpp | 4 +++- 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .gitignore rename main.cpp => example/main.cpp (100%) rename {source => incl/a-star}/AStar.hpp (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index c0a6f00..18fff5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,12 @@ project (a-star) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -include_directories(source) +option(BUILD_EXAMPLE "Build a-star example") add_library(a-star source/AStar.cpp) -add_executable(main main.cpp) -target_link_libraries(main a-star) +if(BUILD_EXAMPLE) + add_executable(main main.cpp) + target_link_libraries(main a-star) +endif() + +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/incl) diff --git a/main.cpp b/example/main.cpp similarity index 100% rename from main.cpp rename to example/main.cpp diff --git a/source/AStar.hpp b/incl/a-star/AStar.hpp similarity index 100% rename from source/AStar.hpp rename to incl/a-star/AStar.hpp diff --git a/source/AStar.cpp b/source/AStar.cpp index 7bf471a..8a1a834 100644 --- a/source/AStar.cpp +++ b/source/AStar.cpp @@ -1,7 +1,9 @@ -#include "AStar.hpp" #include +#include +#include "a-star/AStar.hpp" using namespace std::placeholders; +using namespace std; bool AStar::Vec2i::operator == (const Vec2i& coordinates_) { From 3aee1d7e248c7144088d3f7b3d4adafa4d8bfa2f Mon Sep 17 00:00:00 2001 From: rasmartguy Date: Fri, 29 Mar 2019 22:37:50 +0300 Subject: [PATCH 2/2] :ambulance: fix cmake option --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18fff5b..71d9454 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ project (a-star) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -option(BUILD_EXAMPLE "Build a-star example") +option(BUILD_EXAMPLE "Build a-star example" OFF) add_library(a-star source/AStar.cpp) if(BUILD_EXAMPLE)