CMake not finding Accelerate framework

Hi,

In a project of mine, some of my dependencies apparently use the Accelerate framework. When linking against them, I get link lines that look like (I’m not sure why the -framework Accelerate is duplicated, but deduplicating it manually didn’t seem to make a difference):

/Users/sam/code/project/dep/install/bin/clang++ -g -arch arm64 -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -Wl,-search_paths_first 
-Wl,-headerpad_max_install_names -Wl,-no_compact_unwind 
tests/CMakeFiles/my_test.dir/my_test.cpp.o -o tests/my_test 
-l/Users/sam/code/project/dep/install/lib/libstrumpack.a  
-Xlinker -framework -Xlinker Accelerate  -lm  -ldl  
-Xlinker -framework -Xlinker Accelerate  -lm  -ldl

which ends up failing with

ld: framework not found Accelerate

The accelerate framework is in the standard place:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/
and if I manually point the compiler at that directory with

target_link_options(mylib PUBLIC 
"-Wl,-F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/")

then things work correct correctly.


I’m trying to find out why this isn’t being done automatically, or how to work around it without hardcoding a machine-specific path in my CMakeLists.txt.

I see that there is a variable named CMAKE_SYSTEM_FRAMEWORK_PATH, and it has
the value of:

message(${CMAKE_SYSTEM_FRAMEWORK_PATH}) 

#output (verbatim)
~/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/Network/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Library/Developer/CommandLineTools/Library/Frameworks/Library/Developer/CommandLineTools/Library/Frameworks/Library/Frameworks/Network/Library/Frameworks/System/Library/Frameworks

Is this the expected output, with no whitespace or semicolon separators? If so, how can I extract the relevant framework directory from this variable?

Thank you

That output seems to indicate your CMAKE_SYSTEM_FRAMEWORK_PATH is not pointing at the standard system location, but rather your personal area under your home directory. That may be the source of your problem. I suggest tracking down what is setting CMAKE_SYSTEM_FRAMEWORK_PATH and if it is not coming from CMake itself, try to prevent that from happening.

If I just have a trivial CMake project I still get this incredibly long framework path:

% cat CMakeLists.txt 
cmake_minimum_required(VERSION 3.16)
project(simple LANGUAGES CXX)

message(${CMAKE_SYSTEM_FRAMEWORK_PATH})

% cmake . -Bbuild
~/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/Network/Library/Frameworks/Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/Library/Developer/CommandLineTools/Library/Frameworks/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Library/Frameworks/Network/Library/Frameworks/System/Library/Frameworks

Is this normal? This path doesn’t exist (or is this supposed to be multiple paths and the separators between list entries aren’t showing?), I would have expected something like a single entry of
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/

I don’t know how to find out where this value comes from or how to fix it. The relevant documentation doesn’t offer any guidance:
https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.html

update:

  • cleanly reinstalling CMake from brew to 3.26.4 doesn’t change anything
  • binaries downloaded from cmake.org give the same output

Sorry it took me so long to get back to this. The problem isn’t with CMAKE_SYSTEM_FRAMEWORK_PATH, it is with how you’re calling message(). When you pass a list to the message() command, it concatenates the list items without inserting any ; or other character between list items. If you quote the whole ${CMAKE_SYSTEM_FRAMEWORK_PATH} value, you’ll see the semicolon separators.

cmake_minimum_required(VERSION 3.16)
project(simple LANGUAGES CXX)

# Make sure the following is quoted
message("${CMAKE_SYSTEM_FRAMEWORK_PATH}")