diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f876fa..4290b71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,15 @@ +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OSX deployment version" FORCE) +set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "OSX target CPU architectures" FORCE) + cmake_minimum_required(VERSION 3.9) project(cgbwebcam) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# i think SDL should be setting this if(APPLE) + # i think SDL should be setting this set(CMAKE_EXE_LINKER_FLAGS "-framework AVFoundation") + set(SDL_CPU_X64 ON) + set(SDL_CPU_ARM64 ON) endif() set(SDL_STATIC ON) @@ -39,9 +43,26 @@ add_subdirectory(mgba) include_directories(SDL/include) include_directories(mgba/include) -#set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS "-Wall -Werror -pedantic -std=c89") +set_source_files_properties(main.c PROPERTIES COMPILE_FLAGS "-Wall -Werror -pedantic -std=c99 -Wno-extra-semi") -add_executable(cgbwebcam main.c) +if(APPLE) + set(cgbwebcam_ICON ${CMAKE_SOURCE_DIR}/cmake/cgbwebcam.icns) + set_source_files_properties(${cgbwebcam_ICON} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") + add_executable(cgbwebcam MACOSX_BUNDLE main.c ${cgbwebcam_ICON}) + set_target_properties(cgbwebcam PROPERTIES + BUNDLE True + MACOSX_BUNDLE_GUI_IDENTIFIER "net.hell-labs.cgbwebcam" + MACOSX_BUNDLE_BUNDLE_NAME "cgbwebcam" + MACOSX_BUNDLE_BUNDLE_VERSION "0.1" + MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1" + MACOSX_BUNDLE_ICON_FILE cgbwebcam.icns + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Templates/Info.plist + # OSX_ARCHITECTURES "x86_64;arm64" + ) +else() + add_executable(cgbwebcam main.c) +endif() target_link_libraries(cgbwebcam SDL3-static mgba) include(CheckIPOSupported) diff --git a/cmake/Templates/Info.plist b/cmake/Templates/Info.plist new file mode 100644 index 0000000..91a048f --- /dev/null +++ b/cmake/Templates/Info.plist @@ -0,0 +1,35 @@ + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + NSCameraUsageDescription + cgbwebcam requires access to your camera in order to simulate the Gameboy Camera's sensor. + + diff --git a/cmake/cgbwebcam.icns b/cmake/cgbwebcam.icns new file mode 100644 index 0000000..b57aa71 Binary files /dev/null and b/cmake/cgbwebcam.icns differ diff --git a/main.c b/main.c index f48924d..65fcd4b 100644 --- a/main.c +++ b/main.c @@ -578,6 +578,9 @@ SDL_AppResult SDL_AppIterate(void* appstate) { SDL_SetTextureColorMod(st->textures[0], 255, 0, 0); SDL_SetTextureColorMod(st->textures[1], 0, 255, 0); SDL_SetTextureColorMod(st->textures[2], 0, 0, 255); + + /* weird bug on OSX, shows file browser twice if unfocused when selecting camera */ + SDL_RaiseWindow(st->window); return SDL_APP_CONTINUE; }