Thanks, Alex F, nice solution, but didn't work for me, because my project was created by cmake. So, to do as Alex F suggested, add WIN32 or MACOSX_BUNDLE to add_executable
add_executable(target_name WIN32 )
Or, if you can't edit the CMakeList.txt, you can add -DCMAKE_WIN32_EXECUTABLE=1 to the cmake configure command.