Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:35:35+00:00 2026-06-08T08:35:35+00:00

Brief: Does anyone know if it possible to add a custom_target in CMake that

  • 0

Brief:
Does anyone know if it possible to add a custom_target in CMake that is included in all submodules? An example would be how the Install/Run_Tests/Package targets are added to every submodule in a build.

More Detail:
My scenario is that for a directory structure such as:

Project
  --CMakeLists.txt
  --SubMod A
      --CMakeListsA.txt
  --SubMod B
      --CMakeListsB.txt

I would like to add a custom_target for doxygen generation to the top level CMakeLists.txt file and have that included in Sub Module A and B. The command will be exactly the same between all modules.

I could add the custom_target to each sub-module’s cmake file but this seems wrong. The other issue with this is if I have CMake generate a Visual Studio solution there will be conflicts with a “doc” project already existing (if opening the top level solution). CMake provided targets are however smart enough to not be included twice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:35:38+00:00Added an answer on June 8, 2026 at 8:35 am

    I think the best you can do is wrap the add_custom_target in a function defined in your top-level CMakeLists.txt and use it in each CMakeLists.txt.

    To avoid the problem of repeating target names, you could define the function something like:

    function(AddDoxygenTarget)
      add_custom_target(Doxygen${PROJECT_NAME} ...)
    endfunction()
    

    This depends on each submodule’s CMakeLists.txt having a project command. If not, you could use each subdirectory’s name:

      get_filename_component(SubDirName ${CMAKE_CURRENT_LIST_DIR} NAME)
      add_custom_target(Doxygen${SubDirName} ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know if there is any documentation that describes all the possible exceptions
Does anyone know an API or other method that I could generate a short
Does anyone know why the BookmarkablePageLink class is generic in wicket? I have been
Here's a brief rundown of my issue: I have a JavaScript function that gets
brief history. I have a little reporting tool that I am creating that uses
Through some brief testing it appears that click() will trigger any applicable handlers synchronously
I have a framework that's part of my app and I want to add
Ok here is the problem in brief. I do have a pyramid setup that
Semi-brief overview... --- Indices is a Python list of indices that correspond to the
Possible Duplicate: What does a colon following a C++ constructor name do? I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.