CMake Tests for a library intended as a git submoduleCMake exclude tests in subdirectoriesHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?

Who was this character from the Tomb of Annihilation adventure before they became a monster?

What to do if SUS scores contradict qualitative feedback?

Does kinetic energy warp spacetime?

How are one-time password generators like Google Authenticator different from having two passwords?

How do I tell my supervisor that he is choosing poor replacements for me while I am on maternity leave?

Find the cipher used

What's the word for the soldier salute?

Run script for 10 times until meets the condition, but break the loop if it meets the condition during iteration

Is there a spell to protect inanimate objects?

What does i386 mean on macOS Mojave?

Can I make ravioli dough with only all-purpose flour or do I NEED semolina flour?

Understanding integration over Orthogonal Group

Size of a folder with du

Can the sorting of a list be verified without comparing neighbors?

As programers say: Strive to be lazy

Setting the major mode of a new buffer interactively

Meaning of「〜てみたいと思います」

Does Lawful Interception of 4G / the proposed 5G provide a back door for hackers as well?

Extracting sublists that contain similar elements

iMac 27" 2017 memory upgrade question

Why was castling bad for white in this game, and engine strongly prefered trading queens?

"Right on the tip of my tongue" meaning?

Why was Thor doubtful about his worthiness to Mjolnir?

How can this triangle figure be modeled/drawn with TikZ?



CMake Tests for a library intended as a git submodule


CMake exclude tests in subdirectoriesHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I force “git pull” to overwrite local files?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















Situation: You develop a library which uses CMake as its (meta-)buildsystem. The library is header-only (actually it does need to, the question still applies), has tests and examples (like benchmarks). The library can be used by installing it and using the resulting package files or (which is often easier to avoid mismatches in ABIs) by adding it as a git submodule and simply add_subdirectory it.



Question: What is the best way to handle tests in that library?



Usually the top-level CMake will look like this:



[...setup code, project(...)`]
add_library(foo src/foo.cpp)
target_include_libraries(foo PUBLIC include)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(FOO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
install(TARGETS foo ...)
install(...)


The issue I have with this is that when this is used as a submodule and the super project also uses include(CTest) and BUILD_TESTING then enabling the super projects tests enables also the submodule tests.



Is this what should be done and expected?



Similar for the install commands: Installing the super project installs also the submodule (I think) which may be wrong as the CMAKE_INSTALL_PREFIX given was intended for the super project and might not be appropriate for the submodule.



This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often.



Am I worrying to much or missing anything? What is the way to go with building (and running) tests and installs for git submodules?










share|improve this question






















  • "This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

    – Tsyvarev
    Mar 23 at 12:53

















1















Situation: You develop a library which uses CMake as its (meta-)buildsystem. The library is header-only (actually it does need to, the question still applies), has tests and examples (like benchmarks). The library can be used by installing it and using the resulting package files or (which is often easier to avoid mismatches in ABIs) by adding it as a git submodule and simply add_subdirectory it.



Question: What is the best way to handle tests in that library?



Usually the top-level CMake will look like this:



[...setup code, project(...)`]
add_library(foo src/foo.cpp)
target_include_libraries(foo PUBLIC include)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(FOO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
install(TARGETS foo ...)
install(...)


The issue I have with this is that when this is used as a submodule and the super project also uses include(CTest) and BUILD_TESTING then enabling the super projects tests enables also the submodule tests.



Is this what should be done and expected?



Similar for the install commands: Installing the super project installs also the submodule (I think) which may be wrong as the CMAKE_INSTALL_PREFIX given was intended for the super project and might not be appropriate for the submodule.



This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often.



Am I worrying to much or missing anything? What is the way to go with building (and running) tests and installs for git submodules?










share|improve this question






















  • "This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

    – Tsyvarev
    Mar 23 at 12:53













1












1








1








Situation: You develop a library which uses CMake as its (meta-)buildsystem. The library is header-only (actually it does need to, the question still applies), has tests and examples (like benchmarks). The library can be used by installing it and using the resulting package files or (which is often easier to avoid mismatches in ABIs) by adding it as a git submodule and simply add_subdirectory it.



Question: What is the best way to handle tests in that library?



Usually the top-level CMake will look like this:



[...setup code, project(...)`]
add_library(foo src/foo.cpp)
target_include_libraries(foo PUBLIC include)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(FOO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
install(TARGETS foo ...)
install(...)


The issue I have with this is that when this is used as a submodule and the super project also uses include(CTest) and BUILD_TESTING then enabling the super projects tests enables also the submodule tests.



Is this what should be done and expected?



Similar for the install commands: Installing the super project installs also the submodule (I think) which may be wrong as the CMAKE_INSTALL_PREFIX given was intended for the super project and might not be appropriate for the submodule.



This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often.



Am I worrying to much or missing anything? What is the way to go with building (and running) tests and installs for git submodules?










share|improve this question














Situation: You develop a library which uses CMake as its (meta-)buildsystem. The library is header-only (actually it does need to, the question still applies), has tests and examples (like benchmarks). The library can be used by installing it and using the resulting package files or (which is often easier to avoid mismatches in ABIs) by adding it as a git submodule and simply add_subdirectory it.



Question: What is the best way to handle tests in that library?



Usually the top-level CMake will look like this:



[...setup code, project(...)`]
add_library(foo src/foo.cpp)
target_include_libraries(foo PUBLIC include)

include(CTest)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(FOO_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
install(TARGETS foo ...)
install(...)


The issue I have with this is that when this is used as a submodule and the super project also uses include(CTest) and BUILD_TESTING then enabling the super projects tests enables also the submodule tests.



Is this what should be done and expected?



Similar for the install commands: Installing the super project installs also the submodule (I think) which may be wrong as the CMAKE_INSTALL_PREFIX given was intended for the super project and might not be appropriate for the submodule.



This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often.



Am I worrying to much or missing anything? What is the way to go with building (and running) tests and installs for git submodules?







git testing cmake






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 11:58









FlamefireFlamefire

1,4971127




1,4971127












  • "This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

    – Tsyvarev
    Mar 23 at 12:53

















  • "This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

    – Tsyvarev
    Mar 23 at 12:53
















"This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

– Tsyvarev
Mar 23 at 12:53





"This would lead to using prefixes and options like FOO_BUILD_TESTING and FOO_INSTALL but I don't see them used often." - This is not so rare as you think. E.g. libevent uses EVENT__DISABLE_TESTS for disable tests, see that question: stackoverflow.com/questions/23713650/…. Actually, the problem is not specific for testing, this is common for all projects which allow to be "embedded" into other projects, and want to be tunable.

– Tsyvarev
Mar 23 at 12:53












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%2f55313494%2fcmake-tests-for-a-library-intended-as-a-git-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%2f55313494%2fcmake-tests-for-a-library-intended-as-a-git-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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript