Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Specify macOS min version #863

Open
mrod502 opened this issue May 31, 2024 · 0 comments
Open

Unable to Specify macOS min version #863

mrod502 opened this issue May 31, 2024 · 0 comments

Comments

@mrod502
Copy link

mrod502 commented May 31, 2024

Problem

  • When compiling static objects, passing -mmacos-version-min=<version> as an option via cmake .. -DCMAKE_C_FLAGS_INIT="-mmacos-version-min=<version>" doesn't apply to the built objects.
  • This can be seen when building a library with the static objects generated from make. Example below:

Example

$ sw_vers -productVersion
-> 14.4.1

$ cmake .. -DCMAKE_C_FLAGS_INIT="-mmacos-version-min=14.0" -DENABLE_CJSON_UTILS=On -DENABLE_CJSON_TEST=Off -DBUILD_SHARED_AND_STATIC_LIBS=On
$ make
$ mkdir -p cjson_tmp
$ cd cjson_tmp
$ ar x ../build/libcjson.a
$ ls
-> ... cjson.c.o
$ gcc -fcommon -shared -o lib.so -fPIC -Ideps -Ideps/b64  -IcJSON cjson_tmp/*.o
-> warning: object file (cjson_tmp/cjson.c.o) was built for newer 'macOS' version (14.4) than being linked (14.0)

Solution

add an option for macos min version:

option(MACOS_VERSION_MIN "Set the minimum macOS SDK version" OFF)
if (APPLE AND MACOS_VERSION_MIN)
    add_compile_options(-mmacos-version-min=${MACOS_VERSION_MIN})
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant