nukeykt / Nuked-SC55

Roland SC-55 series emulation
Other
285 stars 33 forks source link

Add vcpkg manifest #57

Open shermp opened 2 months ago

shermp commented 2 months ago

Adds a vcpkg manifest to easily install SDL2 when compiling in a MSVC environment.

To build for MSVC, open the "x64 Native Tools Command Prompt for VS 2022" and use the following:

md build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake" ..
cmake --build . --config=Release

You can then copy .\back.data, .\Release\nuked-sc55.exe .\Release\SDL2.dll to a folder with the SC55 ROM's.

This assumes you are using a newish version of VS 2022 with integrated vcpkg. You can also use it with the standalone release of vcpkg as well.

I had to add WIN32 to add_executable in CMakeLists.txt so it would link against WinMain. If there are any cmake experts out there, please let me know if this needs to be changed. I tested it under MSYS2 as well, and it compiled fine.

000MDK commented 2 months ago

compiling: as it compiles fine with mingw, I just added

if(MSVC)
    set_property(TARGET "nuked-sc55" APPEND_STRING PROPERTY LINK_FLAGS " /ENTRY:WinMainCRTStartup")
endif()

to CMakeList.txt for VS22 compilation in the pr

your vcpkg manifest is a good addition, I just like to ask if it's not preferred to just have the line vcpkg install sdl2 in instructions instead of adding a new file to the project?

shermp commented 2 months ago

So, I used the cmake documentation here and here which seems to automatically add the linkage as required.

The advantage to the manifest is it works with the version of vcpkg bundled with VS 2022. That version only supports manifest mode due to filesystem permissions.

000MDK commented 2 months ago

I agree. I'll remove my changes to cmakelist and refer to your pr there

Kappa971 commented 2 months ago

add_executable(nuked-sc55 WIN32 ${SC55_SRC} ${UTF8MAIN_SRCS})

This works but the log console of Nuked-SC55 (if anyone needs it) no longer starts. It becomes a Windows /SUBSYSTEM:WINDOWS project instead of Console /SUBSYSTEM:CONSOLE.

The problem is that if set to Console, there is this error:

LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) 

(unless you set the linker flag /ENTRY:WinMainCRTStartup) because, apparently, Visual Studio does not find the int main() function in utf8main_win32.cpp (this is my guess, to be verified).

Also there are some warnings:

D:\Scaricati\Nuked-SC55\src\mcu.cpp(495,48): warning C4018: '<': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(688,29): warning C4018: '>=': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(688,58): warning C4018: '<': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(712,34): warning C4018: '>=': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(712,63): warning C4018: '<': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(1392,26): warning C4267: '=': conversione da 'size_t' a 'int'. Possibile perdita di dati. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu.cpp(1475,31): warning C4267: '=': conversione da 'size_t' a 'int'. Possibile perdita di dati. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\mcu_opcodes.cpp(760,29): warning C4244: 'argomento': conversione da 'uint16_t' a 'uint8_t'. Possibile perdita di dati. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\utils\files.cpp(309,15): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. See online help for details. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\utils\files.cpp(358,15): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. See online help for details. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\utils\files.cpp(367,15): warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _strdup. See online help for details. [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
D:\Scaricati\Nuked-SC55\src\midi_win32.cpp(87,35): warning C4018: '<': errata corrispondenza tra signed e unsigned [D:\Scaricati\Nuked-SC55\build\nuked-sc55.vcxproj]
shermp commented 2 months ago

When I get home this evening, I'll remove the cmake change. That probably needs to be made in a separate PR by setting WIN32_CONSOLE or something.

shermp commented 2 months ago

Ok, cmake change removed.

nikitalita commented 2 months ago

Why are you using the vcpkg-ce-catalog? SDL2 is in the main vcpkg repo.

shermp commented 2 months ago

Hi, this is the default configuration when invoking vcpkg new.