0

I am currently trying to include SFML in my C++ application. I am using CMake to link the libraries.

Steps I followed / to reproduce:

  1. Downloaded latest official release of SFML. (clang arm64)

  2. Copied the files in the downloaded folder to system paths:

SFML/include/* -> usr/local/include/
SFML/lib/* -> usr/local/lib/
SFML/Frameworks/* -> Libraries/Frameworks/
SFML/extlibs/* -> Libraries/Frameworks/
  1. Linked the libraries using CMake
.
.
.
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)
.
.
.
target_link_libraries(
    ${PROJECT_NAME}
    PRIVATE
    ${SFML_LIBRARIES}
)
.
.
.

target_include_directories(
    ${PROJECT_NAME} PUBLIC
    ${SFML_INCLUDE_DIR}
)
.
.
.
  1. Created app bundle for macOS in CMakeLists.txt:
set_target_properties(${PROJECT_NAME} PROPERTIES
    MACOSX_BUNDLE_GUI_IDENTIFIER app.yildirimege.com
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)

CMake build is successful, finds the SFML include dirs and libraries. and successfully links.

When I try to run the app in QtCreator, (or manually by running make and ./app) the same messagebox occurs: "sfml-*.framework is damaged and can't be opened.

My Application Output:

'/Library/Frameworks/sfml-system.framework/Versions/2.6.0/sfml-system' not valid for use in process: library load disallowed by system policy)

However, I have a clue. When I print ${SFML_LIBRARIES} in CMake, this is the output:

-- Found SFML .. in /Library/Frameworks/SFML.framework

SFML LIBRARIES:/Library/Frameworks/sfml-system.framework/Library/Frameworks/sfml-window.framework/Library/Frameworks/sfml-graphics.framework/Library/Frameworks/sfml-network.framework/Library/Frameworks/sfml-audio.framework

the libraries cmake trys to link are not the libraries in usr/local/lib, but the frameworks inside the Libraries/Frameworks. Is this the common behavior?

Also just saw this:

-- SFML INCLUDE DIR:/Library/Frameworks/SFML.framework
-- Found SFML .. in /Library/Frameworks/SFML.framework

Include dir is also wrong. I am using the official FindSFML.cmake config file

What I've Tried:

  1. Since this might be caused by invalid app signature, I selected "Allow apps to run downloaded from anywhere, in Settings -> Privacy & Security.
  2. Re-downloaded the SFML 2.6.0 after step 1.
  3. Downgraded SFML to below versions.

My system:

macOS Version: Ventura 13.4.1

M2 Pro Apple Silicon

Ege Yıldırım
  • 430
  • 3
  • 14
  • Ah, the joys of modern macos development with unclear/vague error messages. Stfu downloaded from the internet gets quarantine flags set which may be preventing you from loading the files. I'm not sure that `Allow apps to run downloaded from anywhere` will help much, you probably still need to sign your code. You might have more success putting the Frameworks inside your application bundle rather than as system libraries – Alan Birtles Aug 09 '23 at 08:26
  • I will try to include frameworks in app bundle and locate them there, or build the SFML statically. Apparently Signing requires Apple Developer account.. Not being able to use system level frameworks for development purposes looks like a security overkill to me. – Ege Yıldırım Aug 09 '23 at 08:59
  • you can sign with an adhoc signature (mostly) when you only want to run code on your own machine, this doesn't require a dev account – Alan Birtles Aug 09 '23 at 09:14
  • I face tha same issue as described by @EgeYıldırım. Alan Birtles: How to link Frameworks located inside application bundle or sign them adhoc? – Andrew P. Aug 10 '23 at 15:11

0 Answers0