From c30b4e430ef5bfc332eca5ffd8afd2037c6ed56d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 16 Mar 2017 21:32:35 +0000 Subject: [PATCH] Make inclusions to vectorwrapper through generated headers. This way cloonelgraphics includes headers using the absolute path and should be usable from other projecs. Setting CLOONEL_SRC_DIR to the path to cloonel's top-level cmake file is now compulsory. --- cloonel_vectorwrapper/vector_cast.hpp.in | 36 +++++++++++++++ cloonel_vectorwrapper/vectorops.hpp.in | 36 +++++++++++++++ cloonel_vectorwrapper/vectorwrapper.hpp.in | 45 +++++++++++++++++++ src/cloonelgraphics/CMakeLists.txt | 15 ++++++- .../cloonel_vectorwrapper | 1 - 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 cloonel_vectorwrapper/vector_cast.hpp.in create mode 100644 cloonel_vectorwrapper/vectorops.hpp.in create mode 100644 cloonel_vectorwrapper/vectorwrapper.hpp.in delete mode 120000 src/cloonelgraphics/vectorwrapper_include/cloonel_vectorwrapper diff --git a/cloonel_vectorwrapper/vector_cast.hpp.in b/cloonel_vectorwrapper/vector_cast.hpp.in new file mode 100644 index 0000000..7b90e67 --- /dev/null +++ b/cloonel_vectorwrapper/vector_cast.hpp.in @@ -0,0 +1,36 @@ +/* + Copyright 2014 Michele "King_DuckZ" Santullo + + This file is part of CloonelJump. + + CloonelJump is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + CloonelJump is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with CloonelJump. If not, see . +*/ + +#pragma once + +//See vectorwrapper.hpp.in for comments + +#if defined(VWR_OUTER_NAMESPACE) +# define OLD_VWR_OUTER_NAMESPACE VWR_OUTER_NAMESPACE +# undef VWR_OUTER_NAMESPACE +#endif + +#define VWR_OUTER_NAMESPACE cloonel +#include "@CMAKE_CURRENT_SOURCE_DIR@/../../lib/vectorwrapper/include/vectorwrapper/vector_cast.hpp" +#undef VWR_OUTER_NAMESPACE + +#if defined(OLD_VWR_OUTER_NAMESPACE) +# define VWR_OUTER_NAMESPACE OLD_VWR_OUTER_NAMESPACE +# undef OLD_VWR_OUTER_NAMESPACE +#endif diff --git a/cloonel_vectorwrapper/vectorops.hpp.in b/cloonel_vectorwrapper/vectorops.hpp.in new file mode 100644 index 0000000..8f3776a --- /dev/null +++ b/cloonel_vectorwrapper/vectorops.hpp.in @@ -0,0 +1,36 @@ +/* + Copyright 2014 Michele "King_DuckZ" Santullo + + This file is part of CloonelJump. + + CloonelJump is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + CloonelJump is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with CloonelJump. If not, see . +*/ + +#pragma once + +//See vectorwrapper.hpp.in for comments + +#if defined(VWR_OUTER_NAMESPACE) +# define OLD_VWR_OUTER_NAMESPACE VWR_OUTER_NAMESPACE +# undef VWR_OUTER_NAMESPACE +#endif + +#define VWR_OUTER_NAMESPACE cloonel +#include "@CMAKE_CURRENT_SOURCE_DIR@/../../lib/vectorwrapper/include/vectorwrapper/vectorops.hpp" +#undef VWR_OUTER_NAMESPACE + +#if defined(OLD_VWR_OUTER_NAMESPACE) +# define VWR_OUTER_NAMESPACE OLD_VWR_OUTER_NAMESPACE +# undef OLD_VWR_OUTER_NAMESPACE +#endif diff --git a/cloonel_vectorwrapper/vectorwrapper.hpp.in b/cloonel_vectorwrapper/vectorwrapper.hpp.in new file mode 100644 index 0000000..8eba04d --- /dev/null +++ b/cloonel_vectorwrapper/vectorwrapper.hpp.in @@ -0,0 +1,45 @@ +/* + Copyright 2014 Michele "King_DuckZ" Santullo + + This file is part of CloonelJump. + + CloonelJump is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + CloonelJump is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with CloonelJump. If not, see . +*/ + +#pragma once + +//The reason for this file is that I want to force cloonelgraphics to use the +//version of vectorwrapper that it's bundled with in git. When it's used as a +//library into a project different than clooneljump, the outer project will +//probably have its own version of vectorwrapper, and likely in a different +//outer namespace. Since both sdlmain.hpp, for example, and some hypotetical +//mygame.cpp from the client code will both #include +//"vectorwrapper/vectorwrapper.hpp", the search paths at the time mygame.cpp is +//built will be different than the one used by cloonelgraphics. By putting an +//absolute path here and forcing the outer namespace to cloonel this problem +//should be avoided. + +#if defined(VWR_OUTER_NAMESPACE) +# define OLD_VWR_OUTER_NAMESPACE VWR_OUTER_NAMESPACE +# undef VWR_OUTER_NAMESPACE +#endif + +#define VWR_OUTER_NAMESPACE cloonel +#include "@CMAKE_CURRENT_SOURCE_DIR@/../../lib/vectorwrapper/include/vectorwrapper/vectorwrapper.hpp" +#undef VWR_OUTER_NAMESPACE + +#if defined(OLD_VWR_OUTER_NAMESPACE) +# define VWR_OUTER_NAMESPACE OLD_VWR_OUTER_NAMESPACE +# undef OLD_VWR_OUTER_NAMESPACE +#endif diff --git a/src/cloonelgraphics/CMakeLists.txt b/src/cloonelgraphics/CMakeLists.txt index dfb7c54..7181f1b 100644 --- a/src/cloonelgraphics/CMakeLists.txt +++ b/src/cloonelgraphics/CMakeLists.txt @@ -21,8 +21,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${PNG_INCLUDE_DIRS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${PHYSFS_INCLUDE_DIR} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vectorwrapper_include PUBLIC ../../lib/tree-3.1/src + PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ) target_compile_definitions(${PROJECT_NAME} @@ -32,3 +32,16 @@ target_compile_definitions(${PROJECT_NAME} set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) + +configure_file( + ${CLOONEL_SRC_DIR}/cloonel_vectorwrapper/vectorwrapper.hpp.in + ${CMAKE_CURRENT_BINARY_DIR}/include/cloonel_vectorwrapper/vectorwrapper.hpp +) +configure_file( + ${CLOONEL_SRC_DIR}/cloonel_vectorwrapper/vector_cast.hpp.in + ${CMAKE_CURRENT_BINARY_DIR}/include/cloonel_vectorwrapper/vector_cast.hpp +) +configure_file( + ${CLOONEL_SRC_DIR}/cloonel_vectorwrapper/vectorops.hpp.in + ${CMAKE_CURRENT_BINARY_DIR}/include/cloonel_vectorwrapper/vectorops.hpp +) diff --git a/src/cloonelgraphics/vectorwrapper_include/cloonel_vectorwrapper b/src/cloonelgraphics/vectorwrapper_include/cloonel_vectorwrapper deleted file mode 120000 index b159702..0000000 --- a/src/cloonelgraphics/vectorwrapper_include/cloonel_vectorwrapper +++ /dev/null @@ -1 +0,0 @@ -../../../lib/vectorwrapper/include/vectorwrapper-1.0 \ No newline at end of file