mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-21 05:29:11 +00:00
.github
bin
cmake
scripts
Baseset.cmake
CreateGRF.cmake
FindVersion.cmake
GenerateWidget.cmake
Regression.cmake
SquirrelExport.cmake
SquirrelIncludes.cmake
AddCustomXXXTimestamp.cmake
CompileFlags.cmake
CreateGrfCommand.cmake
CreateRegression.cmake
Endian.cmake
FindAllegro.cmake
FindEditbin.cmake
FindFluidsynth.cmake
FindFontconfig.cmake
FindGrfcodec.cmake
FindICU.cmake
FindIconv.cmake
FindLZO.cmake
FindSSE.cmake
FindXDG_basedir.cmake
FindXaudio2.cmake
InstallAndPackage.cmake
LinkPackage.cmake
MSVCFilters.cmake
Options.cmake
PackageBundle.cmake
PackageDeb.cmake
PackageNSIS.cmake
SourceList.cmake
Static.cmake
docs
media
os
regression
src
.dorpsgek.yml
.editorconfig
.gitignore
CMakeLists.txt
COMPILING.md
CONTRIBUTING.md
COPYING.md
CPackProperties.cmake.in
CREDITS.md
Doxyfile.in
README.md
changelog.txt
known-bugs.txt
45 lines
1.7 KiB
CMake
45 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
|
|
#
|
|
# Create a single GRF file based on sprites/<grfname>.nfo and sprites/*.png
|
|
# files.
|
|
#
|
|
|
|
if(NOT NFORENUM_EXECUTABLE)
|
|
message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined")
|
|
endif()
|
|
if(NOT GRFCODEC_EXECUTABLE)
|
|
message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined")
|
|
endif()
|
|
if(NOT GRF_SOURCE_FOLDER)
|
|
message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined")
|
|
endif()
|
|
if(NOT GRF_BINARY_FILE)
|
|
message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined")
|
|
endif()
|
|
|
|
get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME)
|
|
|
|
file(WRITE sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "")
|
|
file(READ ${GRF_SOURCE_FOLDER}/${GRF_SOURCE_FOLDER_NAME}.nfo NFO_LINES)
|
|
# Replace ; with \;, and make a list out of this based on \n
|
|
string(REPLACE ";" "\\;" NFO_LINES "${NFO_LINES}")
|
|
string(REPLACE "\n" ";" NFO_LINES "${NFO_LINES}")
|
|
|
|
foreach(NFO_LINE IN LISTS NFO_LINES)
|
|
# Recover the ; that was really in the text (and not a newline)
|
|
string(REPLACE "\\;" ";" NFO_LINE "${NFO_LINE}")
|
|
|
|
if(NFO_LINE MATCHES "^#include")
|
|
string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE})
|
|
file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES)
|
|
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}")
|
|
else()
|
|
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n")
|
|
endif()
|
|
endforeach()
|
|
|
|
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
|
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${GRF_SOURCE_FOLDER_NAME}.grf ${GRF_BINARY_FILE})
|