cmake package registry / locating most recent install of submodule












0















I have a large cmake project with an OS abstraction layer (OSAL) that I would like to use in another project. The large project is....very touchy and not mine, but adding new info to the install is always an option.



The basic scenario is this. The large project has an install prefix, typically _install. All the submodules end up in _build/_install/lib and _build/_install/include of this larger project. And the large project has a very configurable build, so there's numerous _build directories (_dbBuild, _clientBuild, _serverBuild, etc).



The submodule has a simple install (where DESTINATION is just the install prefix)...



install (TARGETS osal DESTINATION lib)
install (FILES ${OSAL_HDRS} DESTINATION include)


Given an entirely separate project, what's the best way to find those headers/librarie(s)? I'll almost always want the most recent install of them.



Various google searches make this seem like a good option.
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry



My basic issue is that this seems like it should be 1 or 2 lines of code for the source project, likewise for the 2nd/using project...store the newest package(or include/lib) location in the source project, and read it in the destination. But all I see are very complicated scenarios with 20-30 lines of cmake configuration. I'd like to replicate the behavior of Find* in the destination:



find_path(OSAL_INCLUDE_DIR osal.h)
find_library(OSAL_LIBRARIES NAMES osal)


Like find*, I want to be able to override the found location. I also would like an existing build to find a new location if it exists (not just found once and done). But that last bit is optional.



What's a straightforward way to achieve this? I apologize if this is obvious to others from the documentation I've linked. For some reason, cmake documentation is inscrutable for me. I stared at it for literally over an hour before posting.



Been now playing with various forms of install(TARGETS EXPORT), install(EXPORT), export(PACKAGE) an osalConfig.cmake file for several hours. The downstream project manages to find the Config file in the build folder (I want to find it in the install prefix directory)..presumably I then have to explicitly include the config file to get access to the variables it sets?



I assume no one is answering me because everyone else just sets two environment variables in the upstream project, reads them in the downstream project, and calls it a day? This all seems like it should be very simple.










share|improve this question

























  • Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

    – zzxyz
    Nov 14 '18 at 22:56


















0















I have a large cmake project with an OS abstraction layer (OSAL) that I would like to use in another project. The large project is....very touchy and not mine, but adding new info to the install is always an option.



The basic scenario is this. The large project has an install prefix, typically _install. All the submodules end up in _build/_install/lib and _build/_install/include of this larger project. And the large project has a very configurable build, so there's numerous _build directories (_dbBuild, _clientBuild, _serverBuild, etc).



The submodule has a simple install (where DESTINATION is just the install prefix)...



install (TARGETS osal DESTINATION lib)
install (FILES ${OSAL_HDRS} DESTINATION include)


Given an entirely separate project, what's the best way to find those headers/librarie(s)? I'll almost always want the most recent install of them.



Various google searches make this seem like a good option.
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry



My basic issue is that this seems like it should be 1 or 2 lines of code for the source project, likewise for the 2nd/using project...store the newest package(or include/lib) location in the source project, and read it in the destination. But all I see are very complicated scenarios with 20-30 lines of cmake configuration. I'd like to replicate the behavior of Find* in the destination:



find_path(OSAL_INCLUDE_DIR osal.h)
find_library(OSAL_LIBRARIES NAMES osal)


Like find*, I want to be able to override the found location. I also would like an existing build to find a new location if it exists (not just found once and done). But that last bit is optional.



What's a straightforward way to achieve this? I apologize if this is obvious to others from the documentation I've linked. For some reason, cmake documentation is inscrutable for me. I stared at it for literally over an hour before posting.



Been now playing with various forms of install(TARGETS EXPORT), install(EXPORT), export(PACKAGE) an osalConfig.cmake file for several hours. The downstream project manages to find the Config file in the build folder (I want to find it in the install prefix directory)..presumably I then have to explicitly include the config file to get access to the variables it sets?



I assume no one is answering me because everyone else just sets two environment variables in the upstream project, reads them in the downstream project, and calls it a day? This all seems like it should be very simple.










share|improve this question

























  • Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

    – zzxyz
    Nov 14 '18 at 22:56
















0












0








0








I have a large cmake project with an OS abstraction layer (OSAL) that I would like to use in another project. The large project is....very touchy and not mine, but adding new info to the install is always an option.



The basic scenario is this. The large project has an install prefix, typically _install. All the submodules end up in _build/_install/lib and _build/_install/include of this larger project. And the large project has a very configurable build, so there's numerous _build directories (_dbBuild, _clientBuild, _serverBuild, etc).



The submodule has a simple install (where DESTINATION is just the install prefix)...



install (TARGETS osal DESTINATION lib)
install (FILES ${OSAL_HDRS} DESTINATION include)


Given an entirely separate project, what's the best way to find those headers/librarie(s)? I'll almost always want the most recent install of them.



Various google searches make this seem like a good option.
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry



My basic issue is that this seems like it should be 1 or 2 lines of code for the source project, likewise for the 2nd/using project...store the newest package(or include/lib) location in the source project, and read it in the destination. But all I see are very complicated scenarios with 20-30 lines of cmake configuration. I'd like to replicate the behavior of Find* in the destination:



find_path(OSAL_INCLUDE_DIR osal.h)
find_library(OSAL_LIBRARIES NAMES osal)


Like find*, I want to be able to override the found location. I also would like an existing build to find a new location if it exists (not just found once and done). But that last bit is optional.



What's a straightforward way to achieve this? I apologize if this is obvious to others from the documentation I've linked. For some reason, cmake documentation is inscrutable for me. I stared at it for literally over an hour before posting.



Been now playing with various forms of install(TARGETS EXPORT), install(EXPORT), export(PACKAGE) an osalConfig.cmake file for several hours. The downstream project manages to find the Config file in the build folder (I want to find it in the install prefix directory)..presumably I then have to explicitly include the config file to get access to the variables it sets?



I assume no one is answering me because everyone else just sets two environment variables in the upstream project, reads them in the downstream project, and calls it a day? This all seems like it should be very simple.










share|improve this question
















I have a large cmake project with an OS abstraction layer (OSAL) that I would like to use in another project. The large project is....very touchy and not mine, but adding new info to the install is always an option.



The basic scenario is this. The large project has an install prefix, typically _install. All the submodules end up in _build/_install/lib and _build/_install/include of this larger project. And the large project has a very configurable build, so there's numerous _build directories (_dbBuild, _clientBuild, _serverBuild, etc).



The submodule has a simple install (where DESTINATION is just the install prefix)...



install (TARGETS osal DESTINATION lib)
install (FILES ${OSAL_HDRS} DESTINATION include)


Given an entirely separate project, what's the best way to find those headers/librarie(s)? I'll almost always want the most recent install of them.



Various google searches make this seem like a good option.
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#user-package-registry



My basic issue is that this seems like it should be 1 or 2 lines of code for the source project, likewise for the 2nd/using project...store the newest package(or include/lib) location in the source project, and read it in the destination. But all I see are very complicated scenarios with 20-30 lines of cmake configuration. I'd like to replicate the behavior of Find* in the destination:



find_path(OSAL_INCLUDE_DIR osal.h)
find_library(OSAL_LIBRARIES NAMES osal)


Like find*, I want to be able to override the found location. I also would like an existing build to find a new location if it exists (not just found once and done). But that last bit is optional.



What's a straightforward way to achieve this? I apologize if this is obvious to others from the documentation I've linked. For some reason, cmake documentation is inscrutable for me. I stared at it for literally over an hour before posting.



Been now playing with various forms of install(TARGETS EXPORT), install(EXPORT), export(PACKAGE) an osalConfig.cmake file for several hours. The downstream project manages to find the Config file in the build folder (I want to find it in the install prefix directory)..presumably I then have to explicitly include the config file to get access to the variables it sets?



I assume no one is answering me because everyone else just sets two environment variables in the upstream project, reads them in the downstream project, and calls it a day? This all seems like it should be very simple.







c cmake






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 19:37







zzxyz

















asked Nov 13 '18 at 23:53









zzxyzzzxyz

2,1931624




2,1931624













  • Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

    – zzxyz
    Nov 14 '18 at 22:56





















  • Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

    – zzxyz
    Nov 14 '18 at 22:56



















Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

– zzxyz
Nov 14 '18 at 22:56







Got this to work, but to be honest it's not clean. I think the registry is meant to supplement existing packages and cmake methodologies that I don't have a firm grasp on. If anyone is interested, I will post what I came up with as answer. Otherwise I will leave this question here to die :)

– zzxyz
Nov 14 '18 at 22:56














0






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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291181%2fcmake-package-registry-locating-most-recent-install-of-submodule%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291181%2fcmake-package-registry-locating-most-recent-install-of-submodule%23new-answer', 'question_page');
}
);

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







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud