From 8d607675d01bc6b621303b0c7b4fd62cd20c8f71 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Wed, 21 Sep 2022 02:55:57 -0500 Subject: [PATCH] chore(cmake): cmake license header, update a bit Instead of using set_target_properties on all tool binaries, instead we can use target_compile_features([xxx] PUBLIC cxx_std_20). This properly alienates projects which depend on libeuropa, allowing the src/tools CMakeLists to be trimmed down quite a bit. Also fixes a build break I accidentally introduced. --- CMakeLists.txt | 14 +++++++++++++- cmake/Policies.cmake | 8 ++++++++ include/europa/io/PakWriter.h | 2 +- src/libeuropa/CMakeLists.txt | 13 ++++++++----- src/libeuropa/io/PakWriter.cpp | 4 ++-- src/tools/CMakeLists.txt | 29 ++++++++--------------------- src/tools/pakcreate.cpp | 4 ++-- 7 files changed, 42 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5a249c..ee66adc 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,11 @@ +# +# EuropaTools +# +# (C) 2021-2022 modeco80 +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + cmake_minimum_required(VERSION 3.10) # Prohibit in-source tree builds. @@ -7,7 +15,11 @@ endif() include(cmake/Policies.cmake) -project(EuropaTools) +project(EuropaTools + VERSION 0.0.1 # Placeholder for sem-ver usage. Replace with real value later. + LANGUAGES C CXX + DESCRIPTION "Tools for working with LEC Europa based games (Star Wars: Starfighter & Star Wars: Jedi Starfighter)" + ) add_subdirectory(third_party/libpixel) add_subdirectory(third_party/indicators) diff --git a/cmake/Policies.cmake b/cmake/Policies.cmake index fda2204..29cf1ff 100755 --- a/cmake/Policies.cmake +++ b/cmake/Policies.cmake @@ -1,3 +1,11 @@ +# +# EuropaTools +# +# (C) 2021-2022 modeco80 +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + # CMake policy configuration # Macro to enable new CMake policy. diff --git a/include/europa/io/PakWriter.h b/include/europa/io/PakWriter.h index af41721..9822c7b 100644 --- a/include/europa/io/PakWriter.h +++ b/include/europa/io/PakWriter.h @@ -21,7 +21,7 @@ namespace europa::io { * Writer for package files. */ struct PakWriter { - void Init(structs::PakVersion version); + void Init(structs::PakHeader::Version version); std::unordered_map& GetFiles(); diff --git a/src/libeuropa/CMakeLists.txt b/src/libeuropa/CMakeLists.txt index 23942be..6a4cf72 100644 --- a/src/libeuropa/CMakeLists.txt +++ b/src/libeuropa/CMakeLists.txt @@ -1,4 +1,10 @@ - +# +# EuropaTools +# +# (C) 2021-2022 modeco80 +# +# SPDX-License-Identifier: GPL-3.0-or-later +# add_library(libeuropa # Implementation details @@ -15,10 +21,7 @@ add_library(libeuropa target_include_directories(libeuropa PUBLIC ${PROJECT_SOURCE_DIR}/include) -set_target_properties(libeuropa PROPERTIES - CXX_STANDARD 20 - CXX_STANDARD_REQUIRED ON - ) +target_compile_features(libeuropa PUBLIC cxx_std_20) # Projects which libeuropa depends on target_link_libraries(libeuropa PUBLIC diff --git a/src/libeuropa/io/PakWriter.cpp b/src/libeuropa/io/PakWriter.cpp index db1400b..f62f7fa 100644 --- a/src/libeuropa/io/PakWriter.cpp +++ b/src/libeuropa/io/PakWriter.cpp @@ -17,7 +17,7 @@ namespace europa::io { - void PakWriter::Init(structs::PakVersion version) { + void PakWriter::Init(structs::PakHeader::Version version) { // for now. pakHeader.Init(version); } @@ -87,7 +87,7 @@ namespace europa::io { // Version 5 paks seem to have an additional bit of reserved data // (which is all zeros.) - if(pakHeader.version == structs::PakVersion::Ver2) { + if(pakHeader.version == structs::PakHeader::Version::Ver5) { os.seekp(6, std::ostream::cur); } diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 116a9d8..d92e49e 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,3 +1,11 @@ +# +# EuropaTools +# +# (C) 2021-2022 modeco80 +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + add_executable(europa_pack_extractor europa_pack_extractor.cpp) target_link_libraries(europa_pack_extractor PUBLIC @@ -5,11 +13,6 @@ target_link_libraries(europa_pack_extractor PUBLIC indicators::indicators ) -set_target_properties(europa_pack_extractor PROPERTIES - CXX_STANDARD 20 - CXX_STANDARD_REQUIRED ON - ) - add_executable(pakcreate pakcreate.cpp) target_link_libraries(pakcreate PUBLIC @@ -17,30 +20,14 @@ target_link_libraries(pakcreate PUBLIC indicators::indicators ) -set_target_properties(pakcreate PROPERTIES - CXX_STANDARD 20 - CXX_STANDARD_REQUIRED ON - ) - - add_executable(texdump texdump.cpp) target_link_libraries(texdump PUBLIC libeuropa ) -set_target_properties(texdump PROPERTIES - CXX_STANDARD 20 - CXX_STANDARD_REQUIRED ON - ) - add_executable(paktest paktest.cpp) target_link_libraries(paktest PUBLIC libeuropa ) - -set_target_properties(paktest PROPERTIES - CXX_STANDARD 20 - CXX_STANDARD_REQUIRED ON - ) diff --git a/src/tools/pakcreate.cpp b/src/tools/pakcreate.cpp index a0b8d66..1b71bc3 100644 --- a/src/tools/pakcreate.cpp +++ b/src/tools/pakcreate.cpp @@ -32,11 +32,11 @@ int main(int argc, char** argv) { if(argv[3] != nullptr) { if(!strcmp(argv[3], "--jedi")) { std::cout << "Writing Jedi Starfighter archive\n"; - writer.Init(structs::PakVersion::Ver2); + writer.Init(structs::PakHeader::Version::Ver5); } } else { std::cout << "Writing Starfighter archive\n"; - writer.Init(structs::PakVersion::Starfighter); + writer.Init(structs::PakHeader::Version::Ver4); } for(auto& ent : fs::recursive_directory_iterator(argv[1])) {