CMake Mac: creating a universal binary using custom command/target

Multi tool use
the overall story: I'm creating 2 libraries (32, 64) and want to create a universal binary out of them, and that the final universal binary would update only if:
(1) one of the two libraries had changed.
(2) the universal binary had been deleted.
Details:
My two per-architecture libraries are created using an add_library
(SHARED). Each need slightly different build options, otherwise I would have used CMAKE_OSX_ARCHITECTURES.
I have a set of commands for creating the universal binary (lipo etc.)
Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments.
What is the right way to do it?
The following code creates the universal every time:
add_custom_target(${target} ALL
"lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
The following doesn't create it at all:
add_custom_command(OUTPUT ../Temp/${target_filename}
COMMAND "lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
macos cmake universal-binary
add a comment |
the overall story: I'm creating 2 libraries (32, 64) and want to create a universal binary out of them, and that the final universal binary would update only if:
(1) one of the two libraries had changed.
(2) the universal binary had been deleted.
Details:
My two per-architecture libraries are created using an add_library
(SHARED). Each need slightly different build options, otherwise I would have used CMAKE_OSX_ARCHITECTURES.
I have a set of commands for creating the universal binary (lipo etc.)
Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments.
What is the right way to do it?
The following code creates the universal every time:
add_custom_target(${target} ALL
"lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
The following doesn't create it at all:
add_custom_command(OUTPUT ../Temp/${target_filename}
COMMAND "lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
macos cmake universal-binary
1
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
1
A COMMAND, specified inadd_custom_target
, is intended to be run every time. Approach withadd_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….
– Tsyvarev
Dec 27 '18 at 20:26
add a comment |
the overall story: I'm creating 2 libraries (32, 64) and want to create a universal binary out of them, and that the final universal binary would update only if:
(1) one of the two libraries had changed.
(2) the universal binary had been deleted.
Details:
My two per-architecture libraries are created using an add_library
(SHARED). Each need slightly different build options, otherwise I would have used CMAKE_OSX_ARCHITECTURES.
I have a set of commands for creating the universal binary (lipo etc.)
Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments.
What is the right way to do it?
The following code creates the universal every time:
add_custom_target(${target} ALL
"lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
The following doesn't create it at all:
add_custom_command(OUTPUT ../Temp/${target_filename}
COMMAND "lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
macos cmake universal-binary
the overall story: I'm creating 2 libraries (32, 64) and want to create a universal binary out of them, and that the final universal binary would update only if:
(1) one of the two libraries had changed.
(2) the universal binary had been deleted.
Details:
My two per-architecture libraries are created using an add_library
(SHARED). Each need slightly different build options, otherwise I would have used CMAKE_OSX_ARCHITECTURES.
I have a set of commands for creating the universal binary (lipo etc.)
Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments.
What is the right way to do it?
The following code creates the universal every time:
add_custom_target(${target} ALL
"lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
The following doesn't create it at all:
add_custom_command(OUTPUT ../Temp/${target_filename}
COMMAND "lipo" "-create" ${subtarget_filenames} "-output" "../Temp/${target_filename}"
COMMAND "ln" "-f" "-s" "../Temp/${target_filename}" "../Products/${target_filename}"
COMMENT "Creating a universal binary: ${target_filename}")
macos cmake universal-binary
macos cmake universal-binary
edited Dec 27 '18 at 19:58
asked Dec 27 '18 at 16:36
gil_mo
1509
1509
1
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
1
A COMMAND, specified inadd_custom_target
, is intended to be run every time. Approach withadd_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….
– Tsyvarev
Dec 27 '18 at 20:26
add a comment |
1
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
1
A COMMAND, specified inadd_custom_target
, is intended to be run every time. Approach withadd_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….
– Tsyvarev
Dec 27 '18 at 20:26
1
1
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
1
1
A COMMAND, specified in
add_custom_target
, is intended to be run every time. Approach with add_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….– Tsyvarev
Dec 27 '18 at 20:26
A COMMAND, specified in
add_custom_target
, is intended to be run every time. Approach with add_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….– Tsyvarev
Dec 27 '18 at 20:26
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948145%2fcmake-mac-creating-a-universal-binary-using-custom-command-target%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948145%2fcmake-mac-creating-a-universal-binary-using-custom-command-target%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
L,KG KmnZX kju1Yu1II5FtgcBEunHzI8laXfBNg 1wqTYWqpMTG SOYTL qifTpdWN1sq331lWMk2HfHIvV wJ
1
"Now, when using add_custom_command() or add_custom_target(), either the final universal binary ALWAYS builds, or it does not build at all - depending on how I tweak the arguments." - Show the code which causes this behaviour.
– Tsyvarev
Dec 27 '18 at 17:27
Thanks, code added.
– gil_mo
Dec 27 '18 at 19:59
1
A COMMAND, specified in
add_custom_target
, is intended to be run every time. Approach withadd_custom_command
is correct, but see there why your code doesn't work and how to fix it: stackoverflow.com/questions/2937128/….– Tsyvarev
Dec 27 '18 at 20:26