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

SDL_MAIN_HANDLED vs CMake target property #138

Open
PeterBowman opened this issue Sep 13, 2018 · 4 comments
Open

SDL_MAIN_HANDLED vs CMake target property #138

PeterBowman opened this issue Sep 13, 2018 · 4 comments
Assignees

Comments

@PeterBowman
Copy link
Member

We need to define a SDL_MAIN_HANDLED on executable targets in order to make them work on Windows: 9e36c06. I just found today this answer in the CMake FAQ that could render useful here: the WIN32_EXECUTABLE property target which can be set through add_executable(<name> WIN32 ...) (docs).

@PeterBowman
Copy link
Member Author

If SDL_MAIN_HANDLED is not defined, SDL2 redefines main as SDL_main so that it's handled internally (CLI parsing and so on). Compilations errors are expected if the main entry point is not given the full, standard signature (e.g. int main(void) instead of int main(int argc, char ** argv)). I managed to overcome that via edf35f4, but tests are failing now with SDL not found.

@PeterBowman
Copy link
Member Author

The game starts successfully if I use add_executable(robotDevastation WIN32 ...). However, no input/output is allowed through the console since it's now a pure windowed application.

@PeterBowman
Copy link
Member Author

Per https://stackoverflow.com/a/11976179/10404307:

SDL requires initialization, so it injects its own main function that runs its initialization before calling your "main" function, which it renames to SDL_main so that it does not conflict with the actual main function.

As Captain Obvious said in the comment section, this is a massive pain in the patooty. I'd like to check why SDL fails to initialize before closing this as invalid (no action needed). Probably unrelated, but SDL_SetMainReady() is mentioned here.

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

No branches or pull requests

1 participant