From 3f8f8764ded1ff68650eb21d9df09b7b552aabe1 Mon Sep 17 00:00:00 2001 From: Louis Gombert Date: Sun, 21 Jul 2024 18:55:25 +0200 Subject: [PATCH] HogMaker as external project --- .github/workflows/build.yml | 6 +-- CMakeLists.txt | 14 ++++-- cmake/HogMaker.cmake | 58 ---------------------- netcon/descent3onlineclient/CMakeLists.txt | 15 +++--- netcon/lanclient/CMakeLists.txt | 19 +++---- netcon/mtclient/CMakeLists.txt | 19 +++---- scripts/CMakeLists.txt | 16 +++--- tools/CMakeLists.txt | 11 +++- 8 files changed, 57 insertions(+), 101 deletions(-) delete mode 100644 cmake/HogMaker.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db2295695..27cb2bd32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,7 +69,7 @@ jobs: shell: arch -x86_64 /bin/bash -e {0} run: | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - eval "$(/usr/local/bin/brew shellenv)" # makes the Intel version of Brew and its installs are enshrined as the default + eval "$(/usr/local/bin/brew shellenv)" # makes the Intel version of Brew and its installs are enshrined as the default echo "PATH=$PATH" >> $GITHUB_ENV # modify $PATH so the above step persists into the future steps - name: Install macOS dependencies @@ -105,9 +105,7 @@ jobs: - name: Configure cross-compiled build if: ${{ matrix.os.preset == 'linux-cross-arm64' }} run: | - cmake --preset linux - ninja -f build-${{ matrix.build_type }}.ninja -C builds/linux/ HogMaker - cmake --preset linux-cross-arm64 -DHogMaker_DIR=$PWD/builds/linux/ -DBUILD_TESTING=OFF -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=OFF -DUSE_EXTERNAL_PLOG=ON + cmake --preset linux-cross-arm64 -DBUILD_TESTING=OFF -DENABLE_LOGGER=ON -DFORCE_PORTABLE_INSTALL=ON -DBUILD_EDITOR=OFF -DUSE_EXTERNAL_PLOG=ON - name: Configure CMake if: ${{ matrix.os.preset != 'linux-cross-arm64' }} diff --git a/CMakeLists.txt b/CMakeLists.txt index abe92825a..7b7cf444d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,11 +275,17 @@ endif() add_subdirectory(Descent3) -if (CMAKE_CROSSCOMPILING) - find_package(HogMaker REQUIRED) -else() - add_subdirectory(tools) +# Always build HogMaker natively. Build it as external project, +include(ExternalProject) +ExternalProject_Add(HogMaker + SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools + BINARY_DIR ${CMAKE_BINARY_DIR}/tools + INSTALL_COMMAND "" +) +if (DEFINED CMAKE_CONFIGURATION_TYPES) + set(HogMakerBin_ConfigDir "$/") endif() +set(HogMakerBin ${CMAKE_BINARY_DIR}/tools/${HogMakerBin_ConfigDir}HogMaker) add_subdirectory(netcon) add_subdirectory(netgames) diff --git a/cmake/HogMaker.cmake b/cmake/HogMaker.cmake deleted file mode 100644 index 4f58acc88..000000000 --- a/cmake/HogMaker.cmake +++ /dev/null @@ -1,58 +0,0 @@ -# Descent 3 -# Copyright (C) 2024 Descent Developers -# -# 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 3 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, see . - - -# - Function making a HOG file based on supplied filelist. -# -# This module provides function MakeHog() used for building HOG files. -# MakeHog() registers custom target TARGET which can be used as dependency. -# -# MakeHog( -# -# -# -# [SEARCH_PATH additional_dirs] -# [DEPENDS additional_dependencies] -# ) -# - -function(MakeHog) - set(options) - set(oneValueArgs INPUT_FILE OUTPUT TARGET) - set(multiValueArgs DEPENDS SEARCH_PATH) - - cmake_parse_arguments(PARSE_ARGV 0 - "HOG" - "${options}" - "${oneValueArgs}" - "${multiValueArgs}" - ) - - # Register custom target for tracking dependencies - add_custom_target("${HOG_TARGET}" - DEPENDS "${HOG_OUTPUT}" - ) - - add_custom_command(OUTPUT "${HOG_OUTPUT}" - COMMAND $ - "${HOG_OUTPUT}" - "${HOG_INPUT_FILE}" - "${HOG_SEARCH_PATH}" - DEPENDS HogMaker ${HOG_INPUT_FILE} ${HOG_DEPENDS} - COMMENT "Generate ${HOG_OUTPUT}" - COMMAND_EXPAND_LISTS - ) -endfunction() diff --git a/netcon/descent3onlineclient/CMakeLists.txt b/netcon/descent3onlineclient/CMakeLists.txt index 85b2bd9d6..f200ee9b2 100644 --- a/netcon/descent3onlineclient/CMakeLists.txt +++ b/netcon/descent3onlineclient/CMakeLists.txt @@ -26,13 +26,14 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(Descent3_Online_TCP_IP PROPERTIES SUFFIX ".dylib") endif() -include(HogMaker) -MakeHog( - TARGET Descent3_Online_TCP_IP_Hog - OUTPUT "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Descent3 Online.d3c" - INPUT_FILE "${CMAKE_SOURCE_DIR}/netcon/descent3onlineclient/d3online.d3c.txt" - SEARCH_PATH "$" "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" - DEPENDS Descent3_Online_TCP_IP +add_custom_target(Descent3_Online_TCP_IP_Hog + COMMAND ${HogMakerBin} + "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Descent3 Online.d3c" + "${CMAKE_SOURCE_DIR}/netcon/descent3onlineclient/d3online.d3c.txt" + "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" + "$" + DEPENDS Descent3_Online_TCP_IP HogMaker + COMMENT "Generate 'Direct Descent3 Online.d3c'" ) install( diff --git a/netcon/lanclient/CMakeLists.txt b/netcon/lanclient/CMakeLists.txt index 1ef045abc..633378d75 100644 --- a/netcon/lanclient/CMakeLists.txt +++ b/netcon/lanclient/CMakeLists.txt @@ -19,16 +19,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(Direct_TCP_IP PROPERTIES SUFFIX ".dylib") endif() -include(HogMaker) -MakeHog( - TARGET Direct_TCP_IP_Hog - OUTPUT "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Direct TCP~IP.d3c" - INPUT_FILE "${CMAKE_SOURCE_DIR}/netcon/lanclient/TCP_IP.d3c.txt" - SEARCH_PATH "$" "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" - DEPENDS Direct_TCP_IP +add_custom_target(Direct_TCP_IP_Hog + COMMAND ${HogMakerBin} + "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Direct TCP~IP.d3c" + "${CMAKE_SOURCE_DIR}/netcon/lanclient/TCP_IP.d3c.txt" + "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" + "$" + DEPENDS Direct_TCP_IP HogMaker + COMMENT "Generate 'Direct TCP~IP.d3c'" ) install( - FILES "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Direct TCP~IP.d3c" - DESTINATION ${CMAKE_INSTALL_DATADIR}/online + FILES "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Direct TCP~IP.d3c" + DESTINATION ${CMAKE_INSTALL_DATADIR}/online ) diff --git a/netcon/mtclient/CMakeLists.txt b/netcon/mtclient/CMakeLists.txt index 98e64e320..f99f988e1 100644 --- a/netcon/mtclient/CMakeLists.txt +++ b/netcon/mtclient/CMakeLists.txt @@ -29,16 +29,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_target_properties(Parallax_Online PROPERTIES SUFFIX ".dylib") endif() -include(HogMaker) -MakeHog( - TARGET Parallax_Online_Hog - OUTPUT "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Parallax Online.d3c" - INPUT_FILE "${CMAKE_SOURCE_DIR}/netcon/mtclient/Parallax_Online.d3c.txt" - SEARCH_PATH "$" "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" - DEPENDS Parallax_Online +add_custom_target(Parallax_Online_Hog + COMMAND ${HogMakerBin} + "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Parallax Online.d3c" + "${CMAKE_SOURCE_DIR}/netcon/mtclient/Parallax_Online.d3c.txt" + "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/" + "$" + DEPENDS Parallax_Online HogMaker + COMMENT "Generate 'Parallax Online.d3c'" ) install( - FILES "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Parallax Online.d3c" - DESTINATION ${CMAKE_INSTALL_DATADIR}/online + FILES "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/online/Parallax Online.d3c" + DESTINATION ${CMAKE_INSTALL_DATADIR}/online ) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 039a64243..560e3e3b5 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -90,13 +90,13 @@ foreach(SCRIPT ${SCRIPTS}) endif() endforeach() -include(HogMaker) -MakeHog( - TARGET HogFull - OUTPUT "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/d3-${HOG_NAME}.hog" - INPUT_FILE "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/d3-${HOG_NAME}-fullhog.txt" - SEARCH_PATH "$" - DEPENDS ${SCRIPTS} +add_custom_target(HogFull + COMMAND ${HogMakerBin} + "${D3_GENERATED_FILES_OUTPUT_DIRECTORY}/d3-${HOG_NAME}.hog" + "${CMAKE_SOURCE_DIR}/scripts/data/fullhog/d3-${HOG_NAME}-fullhog.txt" + "$" + DEPENDS ${SCRIPTS} HogMaker data/fullhog/d3-${HOG_NAME}-fullhog.txt + COMMENT "Generate fullhog/d3-${HOG_NAME}.hog" ) install( @@ -106,7 +106,7 @@ install( # FIXME: there may be only one d3-linux.hog, need deal with demo somehow. # add_custom_target(HogLinuxDemo -# COMMAND $ +# COMMAND ${HogMakerBin} # "${CMAKE_BINARY_DIR}/scripts/data/demohog/d3-${HOG_NAME}.hog" # "${CMAKE_BINARY_DIR}/scripts/data/demohog/d3-${HOG_NAME}-demohog.txt" # "${CMAKE_BINARY_DIR}/scripts/" diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 1b34f7e45..84718370d 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,7 +1,14 @@ +cmake_minimum_required(VERSION 3.20) # For using CMAKE__BYTE_ORDER + +project(HogMaker LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + add_executable( HogMaker HogMaker/HogFormat.cpp HogMaker/HogMaker.cpp ) -target_include_directories(HogMaker PRIVATE ${PROJECT_BINARY_DIR}/lib) -export(TARGETS HogMaker FILE "${CMAKE_BINARY_DIR}/HogMakerConfig.cmake") \ No newline at end of file + +target_include_directories(HogMaker PRIVATE ${PROJECT_SOURCE_DIR}/../lib ${PROJECT_BINARY_DIR}/lib)