diff options
author | Freeyorp <TheFreeYorp+git@gmail.com> | 2024-06-05 22:06:13 +0000 |
---|---|---|
committer | Freeyorp <TheFreeYorp+git@gmail.com> | 2024-06-05 23:57:13 +0000 |
commit | dd024fdf9ca01c02b79371512672f6798468020d (patch) | |
tree | d097b70b264bf954d3c1ecd46abacfb0ce95cdec | |
parent | bf14f1b157333c53cc0578f20627529e5fd3e539 (diff) | |
download | tmwa-dd024fdf9ca01c02b79371512672f6798468020d.tar.gz tmwa-dd024fdf9ca01c02b79371512672f6798468020d.tar.bz2 tmwa-dd024fdf9ca01c02b79371512672f6798468020d.tar.xz tmwa-dd024fdf9ca01c02b79371512672f6798468020d.zip |
Create generated files in the build directory
Also, just require the use of full paths when #including a generated file.
This fixes fresh out-of-tree builds using attoconf, and gets rid of a lot of
annoying terminal output when attoconf is tracing dependencies.
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | Makefile.in | 10 | ||||
-rw-r--r-- | src/mmo/version.cpp | 2 | ||||
-rw-r--r-- | src/shared/lib.cpp | 2 |
4 files changed, 12 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d5e9d1..d997b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,13 +101,14 @@ set(PACKAGEDATADIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/tmwa") set(LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}") set(SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}") -# Generate the install.hpp and version.hpp files in the source directory. -# TODO: Is there a nicer way to handle this so we're still able to make fully -# out-of-tree builds, generating the files in the build directory, but still -# having them found by includes? -configure_file(src/conf/install.hpp.in ${CMAKE_SOURCE_DIR}/src/conf/install.hpp @ONLY) -configure_file(src/conf/version.hpp.in ${CMAKE_SOURCE_DIR}/src/conf/version.hpp @ONLY) +# Generate the install.hpp and version.hpp files. +configure_file(src/conf/install.hpp.in src/conf/install.hpp @ONLY) +configure_file(src/conf/version.hpp.in src/conf/version.hpp @ONLY) set(conf_SOURCES ${conf_SOURCES} src/conf/install.hpp src/conf/version.hpp) +# And have the build search for files in the build directory. +# Note that #includes with generated files should use a path relative to the +# top level source or build directory. +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # Add a shared library: libtmwa-shared.so.0 # When we add_executable later, we need to link against this library. diff --git a/Makefile.in b/Makefile.in index d4334eb..2f62baf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -488,12 +488,8 @@ obj/%.d: src/%.cpp | stamp/generated.stamp -MF $@ $< # -MG takes the include parameter as-is without prepending the path whenever # it's not found, and presumed to be a not-yet generated file. -# This is troublesome, since real.make tends not to be in the same directory. -# We work around this by checking to see if a file doesn't exist, and if it -# doesn't, we prepend the path. - for f in $$(sed -e '1s@$(patsubst obj/%.d,%,$@) := \(.*\)@\1@' $@ | tr ' ' \\n | grep -vFx -e : -e \\); do \ - test -f "$${f}" || sed -i "s|\($${f}\)|src/$(dir $*)\1|" $@; \ - done +# #include statements for generated files should always be relative to the +# source (or build) directory. endif # the above SRC_DIR replacement is not really safe, but it works okayish. obj/%.ii: src/%.cpp @@ -742,7 +738,7 @@ conf-raw/str-%.h: FORCE FORCE:: ; .PHONY: FORCE -override CPPFLAGS += -I . -I ${SRC_DIR}/include +override CPPFLAGS += -I. -I${SRC_DIR}/include # distribution tarballs # this only works from within a git checkout diff --git a/src/mmo/version.cpp b/src/mmo/version.cpp index f91b748..c75c25c 100644 --- a/src/mmo/version.cpp +++ b/src/mmo/version.cpp @@ -20,7 +20,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -#include "../conf/version.hpp" +#include "src/conf/version.hpp" #include "../strings/xstring.hpp" diff --git a/src/shared/lib.cpp b/src/shared/lib.cpp index 0eebf17..563bff4 100644 --- a/src/shared/lib.cpp +++ b/src/shared/lib.cpp @@ -18,7 +18,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -#include "../conf/install.hpp" +#include "src/conf/install.hpp" #include "../strings/literal.hpp" #include "../strings/astring.hpp" |