diff --git a/CMakeLists.txt b/CMakeLists.txt index 179a5d99..cf0daf0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") # Add a custom module path to locate additional CMake modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +set(YAML_CPP_STATIC_DEFINE ON) +add_compile_definitions(YAML_CPP_STATIC_DEFINE) if (WIN32) include(cmake/automate-vcpkg.cmake) @@ -25,6 +27,10 @@ set(VCPKG_TRIPLET x64-windows-static) set(VCPKG_TARGET_TRIPLET x64-windows-static) vcpkg_bootstrap() vcpkg_install_packages(zlib bzip2 libzip libpng sdl2 glew glfw3 nlohmann-json tinyxml2 spdlog) +if(NOT EXISTS ${CMAKE_BINARY_DIR}/config.yml) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/config.yml" "${CMAKE_BINARY_DIR}/config.yml") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/assets/" "${CMAKE_BINARY_DIR}/assets/") +endif() endif() if (MSVC) @@ -233,8 +239,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") ">" "INCLUDE_GAME_PRINTF;" "UNICODE;" - "_UNICODE" - STORMLIB_NO_AUTO_LINK + "_UNICODE;" "_CRT_SECURE_NO_WARNINGS;" "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) @@ -252,11 +257,12 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows") "INCLUDE_GAME_PRINTF;" "WIN32;" "UNICODE;" - "_UNICODE" - STORMLIB_NO_AUTO_LINK + "_UNICODE;" "_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS;" ) endif() + add_compile_definitions(STORMLIB_NO_AUTO_LINK) + set(STORMLIB_NO_AUTO_LINK ON) elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") target_compile_definitions(${PROJECT_NAME} PRIVATE "$<$:" @@ -321,10 +327,42 @@ endif() target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") -set(USE_STANDALONE OFF) -set(BUILD_STORMLIB OFF) -set(BUILD_SM64 OFF) -set(BUILD_MK64 OFF) +include(ExternalProject) +ExternalProject_Add(TorchExternal + PREFIX TorchExternal + SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/TorchExternal +) +ExternalProject_Get_Property(TorchExternal install_dir) +set(TORCH_EXECUTABLE ${install_dir}/src/TorchExternal-build/$/torch) +add_custom_target( + ExtractAssetHeaders + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 +) +add_custom_target( + GeneratePortOtr + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} pack port starship.otr + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" +) +add_custom_target( + ExtractAssets + DEPENDS TorchExternal + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 + COMMAND ${TORCH_EXECUTABLE} pack port starship.otr + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" +) + +option(USE_STANDALONE "Build as a standalone executable" OFF) +option(BUILD_STORMLIB "Build with StormLib support" OFF) + +option(BUILD_SM64 "Build with Super Mario 64 support" OFF) +option(BUILD_MK64 "Build with Mario Kart 64 support" OFF) add_subdirectory(tools/Torch) target_link_libraries(${PROJECT_NAME} PRIVATE torch) @@ -533,23 +571,4 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wl,-export-dynamic ) endif() -endif() - -include(ExternalProject) -ExternalProject_Add(TorchExternal - PREFIX TorchExternal - SOURCE_DIR ${CMAKE_SOURCE_DIR}/tools/Torch - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/Torch -) -ExternalProject_Get_Property(TorchExternal install_dir) -set(TORCH_EXECUTABLE ${install_dir}/src/Torch-build/$/torch) -add_custom_target( - ExtractAssets - DEPENDS TorchExternal - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${TORCH_EXECUTABLE} header -o baserom.us.uncompressed.z64 - COMMAND ${TORCH_EXECUTABLE} otr baserom.us.uncompressed.z64 - COMMAND ${TORCH_EXECUTABLE} pack port starship.otr - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/sf64.otr" "${CMAKE_BINARY_DIR}/sf64.otr" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/starship.otr" "${CMAKE_BINARY_DIR}/starship.otr" -) \ No newline at end of file +endif() \ No newline at end of file diff --git a/tools/Torch b/tools/Torch index 65ed1fac..42906f4d 160000 --- a/tools/Torch +++ b/tools/Torch @@ -1 +1 @@ -Subproject commit 65ed1faca66325606d1a2120d93a9814cf6d6361 +Subproject commit 42906f4d1504939aa7f85f08a39308db250a6b14