Shipwright/CMakeLists.txt

202 lines
9.6 KiB
CMake
Raw Normal View History

2022-08-18 13:40:41 -04:00
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
2022-08-18 13:40:41 -04:00
2023-06-18 21:04:09 -04:00
project(Ship VERSION 7.1.0 LANGUAGES C CXX)
set(PROJECT_BUILD_NAME "Sulu Alfa" CACHE STRING "")
set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "")
2022-08-18 13:40:41 -04:00
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT soh)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/utf-8>)
2022-08-18 13:40:41 -04:00
2022-11-06 05:00:34 -05:00
if (CMAKE_SYSTEM_NAME MATCHES "Windows|Linux")
if(NOT DEFINED BUILD_CROWD_CONTROL)
set(BUILD_CROWD_CONTROL ON)
endif()
2022-11-06 05:00:34 -05:00
endif()
2022-08-18 13:40:41 -04:00
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(CMake/automate-vcpkg.cmake)
set(VCPKG_TRIPLET x64-windows-static)
set(VCPKG_TARGET_TRIPLET x64-windows-static)
vcpkg_bootstrap()
vcpkg_install_packages(zlib bzip2 libpng sdl2 sdl2-net glew glfw3)
2022-08-18 13:40:41 -04:00
endif()
################################################################################
# Set target arch type if empty. Visual studio solution generator provides it.
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT CMAKE_VS_PLATFORM_NAME)
set(CMAKE_VS_PLATFORM_NAME "x64")
endif()
message("${CMAKE_VS_PLATFORM_NAME} architecture in use")
if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64"
OR "${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32"))
message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!")
endif()
endif()
################################################################################
# Global configuration types
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
set(CMAKE_C_FLAGS_DEBUG "-g -ffast-math -DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -ffast-math -DDEBUG")
2022-08-18 13:40:41 -04:00
set(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math -DNDEBUG")
else()
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_OBJCXX_FLAGS_RELEASE "-O2 -DNDEBUG")
endif()
if(NOT CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()
################################################################################
# Common utils
################################################################################
include(CMake/Utils.cmake)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
get_linux_lsb_release_information()
message(STATUS "Linux ${LSB_RELEASE_ID_SHORT} ${LSB_RELEASE_VERSION_SHORT} ${LSB_RELEASE_CODENAME_SHORT}")
else()
message(STATUS ${CMAKE_SYSTEM_NAME})
endif()
################################################################################
# Additional Global Settings(add specific info there)
################################################################################
include(CMake/GlobalSettingsInclude.cmake OPTIONAL)
################################################################################
# Use solution folders feature
################################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
################################################################################
# Sub-projects
################################################################################
add_subdirectory(libultraship ${CMAKE_BINARY_DIR}/libultraship)
2022-08-18 13:40:41 -04:00
add_subdirectory(ZAPDTR/ZAPD ${CMAKE_BINARY_DIR}/ZAPD)
add_subdirectory(OTRExporter)
add_subdirectory(soh)
set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE_TERMINAL YES)
set_property(TARGET soh PROPERTY APPIMAGE_DESKTOP_FILE "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.desktop")
set_property(TARGET soh PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/sohIcon.png")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
install(PROGRAMS "${CMAKE_SOURCE_DIR}/scripts/linux/appimage/soh.sh" DESTINATION . COMPONENT appimage)
install(FILES "${CMAKE_SOURCE_DIR}/soh.otr" DESTINATION . COMPONENT appimage)
install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT appimage)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/extractor/" DESTINATION ./assets/extractor COMPONENT appimage)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT appimage)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists/" DESTINATION ./assets/extractor/filelists COMPONENT appimage)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT appimage)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT appimage)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols COMPONENT appimage)
2022-08-18 13:40:41 -04:00
endif()
find_package(Python3 COMPONENTS Interpreter)
# Target to generate OTRs
2022-08-18 13:40:41 -04:00
add_custom_target(
ExtractAssets
# CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f oot.otr oot-mq.otr soh.otr
Dual OTR MQ and Vanilla Support (#1694) * Changes OTR Extraction to have specific mq and nonmq paths. Also updates the game to load resources according to whether or not Master Quest or Vanilla is loaded. * Removes unneeded code from the last commit. * Fixes some weird formatting in ZRom.c * Loads oot-mq.otr and patches oot.otr on top, if both are present. If only one or the other are present, it becomes the only and main OTR. * Adds ImGui Logic for whether or an MQ Checkbox. Checkbox checked only specifies whether new saves should be MQ or not. Checkbox is disabled or force-enabled according to which OTRs are loaded. Also as a necessity includes tracking what game versions have been loaded from the OTRs. * Adds MQ settings logic for Randomizer's ImGui menu. * Writes Master Quest dungeons to the spoiler log * Loads MQ Dungeons from spoiler, persists in save, and loads when appropriate. * Adds logic to prevent loading or creating incompatible rando saves. * Fixdes some linux build issues and new rando save issues * Makes appimage create both vanilla and mq otrs If either rom is present, it makes the corresponding OTR. If both are present, it will make both. If one OTR is present but both roms are present, it will create the missing OTR. * Makes it so a randomized save file will not be marked as MQ. * Refactors to load all OTRs from MainPath or a specific list. Also adds the ability to take a std::unordered_set of hashes to validate each OTR's version file against. * Fixes a syntax error * Makes ExtractAssets output Vanilla and MQ OTRs if both roms are present * Fixes asset generation bug. * Partially working fix for dual OTR extract_assets Currently the cmake ExtractAssets target will return with a 1 if you only end up exporting one type of OTR isntead of both. Haven't found a great way to only attempt to copy a file if it exists from within cmake. It does actually correctly copy the OTR that is generated, despite the error from copying the other one. Pushing as is for now but will keep investigating. * Adds oot-mq.otr to the gitignore. * Makes ExtractAssets not fail on only one rom/OTR. * Removes PatchesPath from the constructors requiring OTRFiles vector. * Renames OOT_UNKNOWN to just UNKNOWN to remove OOT specific reference. * Removes randomizing MQ Dungeons and re-disables MQ rando. Doing this so the PR can get merged quicker with just the Dual OTR support and won't need to wait on rando logic to be updated. That will happen in another PR directly after the merge. * Update mac startup script for dual otr * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Implements new BinaryReader to fix Linux build issue. BinaryReader itself comes from https://github.com/Moneyl/BinaryTools I added a wrapper to adapt it to the ABI from ZAPD's Binary Reader and add Endianness checking. I also had to copy a handful of other bits and pieces from ZAPD to make it all function as expected. * A few edits to the updatream BinaryReader to compile it on Linux. * Adds the Endianness to the first byte of the version file. * Fixes Jenkins * Addresses some of Kenix's comments * Renames `ReadNullTerminatedString` to `ReadCString` * Refactors Archive::LoadFile into a private method with more arguments. * Removes BitConverter and extends existing endianness.h instead. * Fixes an endianness issue with the version file. Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
2022-10-16 23:07:35 -04:00
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive
Implement built in Extractor for Windows (#2730) * wip * const * split zapd into two targets * Workingish. * fix working dir and copy xmls on build (#2) * dont change current working dir with dialog prompts * copy asset xmls to target dir * make zpadlib public * Messagebox. * Check for WIN32 * threading * Cleanups to the exporter and main. * Multi extraction. * Fix byteswap header includes. * Fix another byteswap include. * fix again. * stddef size_t * Add other targets for ZAPDLib * Non windows. * IDYES IDNO * Linux fixes * hopefully remove switch and wiiu from building extractor * Please? * validate roms and add another valid rom * ifdef out extract.h for switch and wiiu * Maybe update lux * Remove ZAPDlib from switch and WiiU * more rules * Update soh/soh/Extractor/Extract.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update ZAPDTR/ZAPD/ExecutableMain.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update ZAPDTR/ZAPD/CMakeLists.txt Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update ZAPDTR/ZAPD/GameConfig.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update ZAPDTR/ZAPD/Globals.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update ZAPDTR/ZAPD/Main.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update soh/CMakeLists.txt Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update soh/soh/Extractor/Extract.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update soh/soh/Extractor/Extract.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * Update soh/soh/Extractor/Extract.cpp Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com> * the last fix * Add context to a comment --------- Co-authored-by: Adam Bird <archez39@me.com> Co-authored-by: Adam Bird <Archez@users.noreply.github.com> Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2023-04-25 00:01:17 -04:00
COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$<TARGET_FILE_DIR:ZAPD>" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake
2022-08-18 13:40:41 -04:00
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
COMMENT "Running asset extraction..."
DEPENDS ZAPD
BYPRODUCTS oot.otr ${CMAKE_SOURCE_DIR}/oot.otr oot-mq.otr ${CMAKE_SOURCE_DIR}/oot-mq.otr ${CMAKE_SOURCE_DIR}/soh.otr
2022-08-18 13:40:41 -04:00
)
# Target to generate headers
add_custom_target(
ExtractAssetHeaders
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --gen-headers
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter
COMMENT "Generating asset headers..."
DEPENDS ZAPD
)
2022-08-18 13:40:41 -04:00
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(ImageMagick COMPONENTS convert)
if (ImageMagick_FOUND)
execute_process (
COMMAND ${ImageMagick_convert_EXECUTABLE} soh/macosx/sohIcon.png -resize 512x512 ${CMAKE_BINARY_DIR}/sohIcon.png
OUTPUT_VARIABLE outVar
)
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_custom_target(CreateOSXIcons
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/macosx/soh.iconset
COMMAND sips -z 16 16 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16.png
COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_16x16@2x.png
COMMAND sips -z 32 32 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32.png
COMMAND sips -z 64 64 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_32x32@2x.png
COMMAND sips -z 128 128 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128.png
COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_128x128@2x.png
COMMAND sips -z 256 256 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256.png
COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_256x256@2x.png
COMMAND sips -z 512 512 soh/macosx/sohIcon.png --out ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512.png
COMMAND cp soh/macosx/sohIcon.png ${CMAKE_BINARY_DIR}/macosx/soh.iconset/icon_512x512@2x.png
COMMAND iconutil -c icns -o ${CMAKE_BINARY_DIR}/macosx/soh.icns ${CMAKE_BINARY_DIR}/macosx/soh.iconset
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Creating OSX icons ..."
)
add_dependencies(soh CreateOSXIcons)
install(TARGETS ZAPD DESTINATION ${CMAKE_BINARY_DIR}/assets/extractor)
set(PROGRAM_PERMISSIONS_EXECUTE OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/extractor/" DESTINATION ./assets/extractor)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/soh/assets/xml/" DESTINATION ./assets/extractor/xmls)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/filelists/" DESTINATION ./assets/extractor/filelists)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ActorList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/ObjectList_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols)
install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_OoTMqDbg.txt" DESTINATION ./assets/extractor/symbols)
2022-08-18 13:40:41 -04:00
install(DIRECTORY ${CMAKE_BINARY_DIR}/assets
DESTINATION .
PATTERN ZAPD.out
PERMISSIONS ${PROGRAM_PERMISSIONS_EXECUTE}
)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/soh-macos\" \"\" \"${dirs}\")
")
2022-08-18 13:40:41 -04:00
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION . COMPONENT ship RENAME readme.txt )
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_GENERATOR "External")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows|NintendoSwitch|CafeOS")
set(CPACK_GENERATOR "ZIP")
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_GENERATOR "Bundle")
endif()
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/CMake/Packaging-2.cmake)
include(CMake/Packaging.cmake)