Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass the CMAKE_OSX_ARCHITECTURES with multiple values in the ExternalProject_Add's CMAKE_ARGS

I cannot find out a way how to create a fat library of my CMake ExternalProjects. The merit of the problem is how one can pass the -DCMAKE_OSX_ARCHITECTURES:STRING="x86_64;arm64" to the CMAKE_ARGS within the ExternalProject_Add definition.

One would expect that the following definition will work flawlessly. However, it seems that the content of the CMAKE_ARGS is being parsed somehow and this results in the malformed value in the resulting CMakeCache.txt.

CMake Definition

ExternalProject_Add(
        ext_libexiv2
        GIT_REPOSITORY https://github.com/Exiv2/exiv2.git
        GIT_TAG v0.27.6
        GIT_SHALLOW true
        CMAKE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING="x86_64;arm64" -DBUILD_SHARED_LIBS=OFF -DEXIV2_BUILD_SAMPLES=OFF -DEXIV2_BUILD_EXIV2_COMMAND=OFF
        UPDATE_COMMAND ""
)

CMakeCache.txt

//No help, variable specified on the command line.
CMAKE_OSX_ARCHITECTURES:STRING="x86_64

I tried to escape the double quotes, use single quotes, escape the semicolon, but none of that worked out.

Certainly, I could do the fat library in the multiple steps, but I would prefer the cleaner solution. I will appreciate any direction you give me.

like image 430
vookimedlo Avatar asked Oct 26 '25 03:10

vookimedlo


1 Answers

The solution is to use the LIST_SEPARATOR option in the ExternalProject_Add definition.

ExternalProject_Add(
        ext_libexiv2
        GIT_REPOSITORY https://github.com/Exiv2/exiv2.git
        GIT_TAG v0.27.6
        GIT_SHALLOW true
        LIST_SEPARATOR |
        CMAKE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64|arm64 -DBUILD_SHARED_LIBS=OFF -DEXIV2_BUILD_SAMPLES=OFF -DEXIV2_BUILD_EXIV2_COMMAND=OFF
        UPDATE_COMMAND ""
)

Then, the resulting cache value is the correct one.

//No help, variable specified on the command line.
CMAKE_OSX_ARCHITECTURES:STRING=x86_64;arm64

Resulting libraries are really fat now.

➜  lib git:(prebuilt-components-replacement) ✗ lipo -info *.a
Architectures in the fat file: libexiv2-xmp.a are: x86_64 arm64
Architectures in the fat file: libexiv2.a are: x86_64 arm64
like image 167
vookimedlo Avatar answered Oct 29 '25 09:10

vookimedlo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!