From e17d2cbaf51218f33e9f745d8332f63c844eba67 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Wed, 4 Oct 2023 13:19:44 -0700 Subject: [PATCH] build: fixes for nix on macOS Add references to frameworks being linked to `buildInputs` in `default.nix`. Remove `-framework System` from `wxWidgets_LIBRARIES` in the cmake code as it's not necessary and nix does it have it in `darwin.apple_sdk.frameworks`. TODO: Debug build currently builds and runs. Release build builds but does not run because of a problem with the dylib bundling. Signed-off-by: Rafael Kitover --- default.nix | 2 +- src/wx/CMakeLists.txt | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index d85025fe..25808174 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,7 @@ with import {}; stdenv.mkDerivation { name = "visualboyadvance-m"; buildInputs = if stdenv.isDarwin then - [ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 ] + [ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 SDL2 pcre pcre2 darwin.apple_sdk.frameworks.IOKit darwin.apple_sdk.frameworks.Carbon darwin.apple_sdk.frameworks.Cocoa darwin.apple_sdk.frameworks.QuartzCore darwin.apple_sdk.frameworks.AudioToolbox darwin.apple_sdk.frameworks.OpenGL darwin.apple_sdk.frameworks.OpenAL ] else [ ninja cmake gcc nasm gettext pkg-config zip sfml zlib openal ffmpeg wxGTK32 mesa glfw SDL2 gtk3-x11 pcre pcre2 util-linuxMinimal libselinux libsepol libthai libdatrie xorg.libXdmcp xorg.libXtst libxkbcommon epoxy dbus at-spi2-core ]; } diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 8d936774..e9d39ef2 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -259,7 +259,7 @@ else() include_directories(${wxWidgets_INCLUDE_DIRS}) - if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$") + if(CMAKE_BUILD_TYPE STREQUAL Debug) # tell wx to enable debug mode if possible, if the cmake module did not do it for us execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE} --debug=yes" RESULT_VARIABLE WX_CONFIG_DEBUG OUTPUT_QUIET ERROR_QUIET) @@ -279,6 +279,17 @@ else() add_compile_options(${CXX_COMPILE_FLAG}) endforeach() + # Remove "-framework System" from libs on macOS, it's not necessary and nix doesn't have it. + if(APPLE) + unset(tmp_libs) + foreach(lib ${wxWidgets_LIBRARIES}) + if(NOT lib STREQUAL "-framework System") + list(APPEND tmp_libs "${lib}") + endif() + endforeach() + set(wxWidgets_LIBRARIES "${tmp_libs}") + endif() + # set up variables for some compile/run checks for wxWidgets set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${MY_CXX_FLAGS} ${MY_C_FLAGS} ${MY_CXX_LINKER_FLAGS} ${MY_C_LINKER_FLAGS} ${wxWidgets_LIBRARIES}) set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${wxWidgets_CXX_FLAGS} ${MY_CXX_FLAGS} ${MY_C_FLAGS})