bsputil: refactor into a static lib

This commit is contained in:
Eric Wasylishen 2023-05-27 13:45:45 -06:00
parent 442237de02
commit 896da81bd6
5 changed files with 59 additions and 5 deletions

View File

@ -1,9 +1,13 @@
set(BSPUTIL_SOURCES
bsputil.cc
../include/bsputil/bsputil.hh
)
add_executable(bsputil ${BSPUTIL_SOURCES})
target_link_libraries(bsputil common TBB::tbb TBB::tbbmalloc fmt::fmt)
add_library(libbsputil STATIC ${BSPUTIL_SOURCES})
target_link_libraries(libbsputil common TBB::tbb TBB::tbbmalloc fmt::fmt)
add_executable(bsputil main.cc)
target_link_libraries(bsputil libbsputil)
# HACK: copy .dll dependencies
add_custom_command(TARGET bsputil POST_BUILD

View File

@ -61,7 +61,7 @@ struct lumpinfo_t
auto stream_data() { return std::tie(filepos, disksize, size, type, compression, pad1, pad2, name); }
};
static void ExportWad(std::ofstream &wadfile, mbsp_t *bsp)
void ExportWad(std::ofstream &wadfile, const mbsp_t *bsp)
{
int filepos, numvalid;
const auto &texdata = bsp->dtex;
@ -564,7 +564,7 @@ map_file_t LoadMapOrEntFile(const fs::path &source)
return map;
}
int main(int argc, char **argv)
int bsputil_main(int argc, char **argv)
{
logging::preinitialize();

25
bsputil/main.cc Normal file
View File

@ -0,0 +1,25 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
#include <cstdint>
int main(int argc, char **argv)
{
return bsputil_main(argc, argv);
}

View File

@ -0,0 +1,25 @@
/* Copyright (C) 1996-1997 Id Software, Inc.
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
See file, 'COPYING', for details.
*/
#include <iosfwd>
struct mbsp_t;
void ExportWad(std::ofstream &wadfile, const mbsp_t *bsp);
int bsputil_main(int argc, char **argv);

View File

@ -29,7 +29,7 @@ if (NOT EMBREE_TBB_DLL STREQUAL EMBREE_TBB_DLL-NOTFOUND)
message(STATUS "Found embree EMBREE_TBB_DLL: ${EMBREE_TBB_DLL}")
endif()
target_link_libraries(tests libqbsp liblight libvis common TBB::tbb TBB::tbbmalloc doctest::doctest fmt::fmt nanobench::nanobench)
target_link_libraries(tests libqbsp liblight libvis libbsputil common TBB::tbb TBB::tbbmalloc doctest::doctest fmt::fmt nanobench::nanobench)
target_compile_definitions(tests PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS)