From 42a7718f71b105b227d05ac925de7d767e082654 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 15:12:00 +0200 Subject: [PATCH 1/3] Simplify CMake + add a few more building instructions --- CMakeLists.txt | 59 +++++++++----------------------------------------- README.md | 13 ++++++++++- 2 files changed, 22 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c06943..46cf21a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,51 +10,18 @@ add_subdirectory(lib/fmt) # Rabbitizer project(rabbitizer) -add_library(rabbitizer STATIC) -target_sources(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrId.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstrIdType.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR3000GTE.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerRegistersTracker.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerConfig.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/RabbitizerVersion.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/common/Utils.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrCategory.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrIdType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstrSuffix.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR3000GTE/RabbitizerInstructionR3000GTE_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Operand.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegister.c" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/instructions/RabbitizerRegisterDescriptor.c") +file(GLOB_RECURSE RABBITIZER_SOURCES + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/*.cpp" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" +) -target_include_directories(rabbitizer PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/tables") +add_library(rabbitizer STATIC ${RABBITIZER_SOURCES}) + +target_include_directories(rabbitizer PRIVATE "${CMAKE_SOURCE_DIR}/lib/rabbitizer/tables") +target_include_directories(rabbitizer PUBLIC + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") # N64 recompiler project(N64Recomp) @@ -67,10 +34,7 @@ target_sources(N64Recomp PRIVATE ${CMAKE_SOURCE_DIR}/src/recompilation.cpp) target_include_directories(N64Recomp PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" "${CMAKE_SOURCE_DIR}/lib/ELFIO" - "${CMAKE_SOURCE_DIR}/lib/fmt/include" "${CMAKE_SOURCE_DIR}/lib/toml11" "${CMAKE_SOURCE_DIR}/include") @@ -81,9 +45,6 @@ project(RSPRecomp) add_executable(RSPRecomp) target_include_directories(RSPRecomp PRIVATE - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/include" - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include" - "${CMAKE_SOURCE_DIR}/lib/fmt/include" "${CMAKE_SOURCE_DIR}/lib/toml11" "${CMAKE_SOURCE_DIR}/include") diff --git a/README.md b/README.md index 57911ac..a0e7f35 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,18 @@ RSP microcode can also be recompiled with this tool. Currently there is no suppo * Ability to recompile into a dynamic language (such as Lua) to be able to load code at runtime for mod support ## Building -This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. +This project can be built with CMake 3.20 or above and a C++ compiler that supports C++20. This repo uses git submodules, so be sure to clone recursively (`git clone --recurse-submodules`) or initialize submodules recursively after cloning (`git submodule update --init --recursive`). + +From there, building is identical to any other cmake project, e.g. run `cmake` in the target build folder and point it at the root of this repo, then run `cmake --build .` from that target folder. You can also use different generators if you'd like to work in different IDE's like Xcode or Visual Studio by using the generator flag: +```bash +# generates into a folder called `build-cmake` +# open the generated Xcode project in that folder +cmake -H. -Bbuild-cmake -GXcode + +# generates into a folder called `build-cmake` +# open the generated Visual Studio 2022 solution in that folder +cmake -S . -B "build-cmake" -G "Visual Studio 17 2022" +``` ## Libraries Used * [rabbitizer](https://github.com/Decompollaborate/rabbitizer) for instruction decoding/analysis From 0325461afb99c828cca1cd16eba6ff5497360bd8 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 15:17:46 +0200 Subject: [PATCH 2/3] Be more explicit with the cplusplus path --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46cf21a..d0bdab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ add_subdirectory(lib/fmt) project(rabbitizer) file(GLOB_RECURSE RABBITIZER_SOURCES - "${CMAKE_SOURCE_DIR}/lib/rabbitizer/*.cpp" + "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/*.cpp" "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" ) From ef2e47166722dbdc9323bec33da5d42e210b3f03 Mon Sep 17 00:00:00 2001 From: dcvz Date: Tue, 14 May 2024 17:18:27 +0200 Subject: [PATCH 3/3] Only one project define --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0bdab3..a0c6107 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +project(N64Recomp) cmake_minimum_required(VERSION 3.20) set(CMAKE_C_STANDARD 17) set(CMAKE_CXX_STANDARD 20) @@ -9,8 +10,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) add_subdirectory(lib/fmt) # Rabbitizer -project(rabbitizer) - file(GLOB_RECURSE RABBITIZER_SOURCES "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/*.cpp" "${CMAKE_SOURCE_DIR}/lib/rabbitizer/src/*.c" @@ -24,7 +23,6 @@ target_include_directories(rabbitizer PUBLIC "${CMAKE_SOURCE_DIR}/lib/rabbitizer/cplusplus/include") # N64 recompiler -project(N64Recomp) add_executable(N64Recomp) target_sources(N64Recomp PRIVATE @@ -41,7 +39,6 @@ target_include_directories(N64Recomp PRIVATE target_link_libraries(N64Recomp fmt rabbitizer) # RSP recompiler -project(RSPRecomp) add_executable(RSPRecomp) target_include_directories(RSPRecomp PRIVATE