Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable cross-compiling of HogMaker #465

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,18 @@ endif()

add_subdirectory(Descent3)

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 "$<CONFIG>/")
endif()
set(HogMakerBin ${CMAKE_BINARY_DIR}/tools/${HogMakerBin_ConfigDir}HogMaker)

add_subdirectory(netcon)
add_subdirectory(netgames)
add_subdirectory(scripts)
Expand Down
3 changes: 1 addition & 2 deletions netcon/lanclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()

add_custom_target(Direct_TCP_IP_Hog
COMMAND $<TARGET_FILE:HogMaker>
COMMAND ${HogMakerBin}
"$<TARGET_FILE_DIR:Descent3>/online/Direct TCP~IP.d3c"
"${CMAKE_SOURCE_DIR}/netcon/lanclient/TCP_IP.d3c.txt"
"${CMAKE_SOURCE_DIR}/scripts/data/fullhog/"
"$<TARGET_FILE_DIR:Direct_TCP_IP>"

DEPENDS Direct_TCP_IP HogMaker
COMMENT "Generate 'Direct TCP~IP.d3c'"
)
Expand Down
3 changes: 1 addition & 2 deletions netcon/mtclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()

add_custom_target(Parallax_Online_Hog
COMMAND $<TARGET_FILE:HogMaker>
COMMAND ${HogMakerBin}
"$<TARGET_FILE_DIR:Descent3>/online/Parallax Online.d3c"
"${CMAKE_SOURCE_DIR}/netcon/mtclient/Parallax_Online.d3c.txt"
"${CMAKE_SOURCE_DIR}/scripts/data/fullhog/"
"$<TARGET_FILE_DIR:Parallax_Online>"

DEPENDS Parallax_Online HogMaker
COMMENT "Generate 'Parallax Online.d3c'"
)
Expand Down
4 changes: 2 additions & 2 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
endif()

add_custom_target(HogFull
COMMAND $<TARGET_FILE:HogMaker>
COMMAND ${HogMakerBin}
"$<TARGET_FILE_DIR:Descent3>/d3-${HOG_NAME}.hog"
"${CMAKE_SOURCE_DIR}/scripts/data/fullhog/d3-${HOG_NAME}-fullhog.txt"
"$<TARGET_FILE_DIR:AIGame>"
Expand All @@ -109,7 +109,7 @@ install(FILES "$<TARGET_FILE_DIR:Descent3>/d3-${HOG_NAME}.hog" DESTINATION ${CMA

# FIXME: there may be only one d3-linux.hog, need deal with demo somehow.
# add_custom_target(HogLinuxDemo
# COMMAND $<TARGET_FILE:HogMaker>
# 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/"
Expand Down
11 changes: 9 additions & 2 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.20) # For using CMAKE_<LANG>_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
)
add_dependencies(HogMaker get_git_hash)
target_include_directories(HogMaker PRIVATE ${PROJECT_BINARY_DIR}/lib)

target_include_directories(HogMaker PRIVATE ${PROJECT_SOURCE_DIR}/../lib ${PROJECT_BINARY_DIR}/lib)
3 changes: 1 addition & 2 deletions tools/HogMaker/HogMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <fstream>
#include <string>

#include "d3_version.h"
#include "HogFormat.h"

// TODO: To our descendants from the future: remove it when code will support C++20
Expand All @@ -48,7 +47,7 @@ int main(int argc, char *argv[]) {
std::vector<std::filesystem::path> input_files;

if (argc < 3) {
std::cout << "HogMaker v" << D3_MAJORVER << "." << D3_MINORVER << "." << D3_BUILD << "-g" << D3_GIT_HASH << "\n"
std::cout << "HogMaker" << "\n"
<< "Usage:\n"
<< " " << argv[0] << " <hogfile.hog> <inputfile.txt> [search_path]\n"
<< std::endl;
Expand Down
Loading