Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vcpkg manifest #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add vcpkg manifest #57

wants to merge 1 commit into from

Conversation

shermp
Copy link

@shermp shermp commented Apr 22, 2024

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
Copy link

000MDK commented Apr 23, 2024

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
Copy link
Author

shermp commented Apr 23, 2024

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
Copy link

000MDK commented Apr 23, 2024

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

@Kappa971
Copy link

Kappa971 commented Apr 23, 2024

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
Copy link
Author

shermp commented Apr 23, 2024

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.

Allows for easy installation of SDL2 using MSVC
@shermp
Copy link
Author

shermp commented Apr 24, 2024

Ok, cmake change removed.

@nikitalita
Copy link
Contributor

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

@shermp
Copy link
Author

shermp commented Apr 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants