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 6029059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:49:50+00:00 2026-05-23T04:49:50+00:00

I have a project organized as follows: include/ src/ share/myprogram/ where share/myprogram/ contains resources.

  • 0

I have a project organized as follows:

  • include/
  • src/
  • share/myprogram/

where share/myprogram/ contains resources.
My program is accessing these resources using relative paths. The executable expects to find them in ../share/myprogram/.

I would like when I run:

mkdir build
cd build
cmake ..
make

to have the following to happen:

  • make a bin directory
  • compile and put the executable in bin/
  • copy the share directory in the build directory

I am looking for a clean way of doing this. Ideally, I would like CMake to be aware of the resources as resources.
I know that I could use a copy custom command. Is this the only way to achieve this?

Bonus

If the resources could appear under Resources in Xcode when using the Xcode generator, and the copy be a clean copy phase under the mybin target, that would be awesome (and that’s what I mean by CMake being aware of the resources as resources.)


Update:

What I have thus far:

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
add_executable(mybin ${Headers} ${Sources})

add_custom_target(
    Resources ALL
    ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/share ${PROJECT_BINARY_DIR}/share
    SOURCES ${Resources}
)
  • 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-05-23T04:49:51+00:00Added an answer on May 23, 2026 at 4:49 am

    I am doing a unix command line tool, I am not doing a Mac OS X bundle and Xcode’s resource folder is only for bundle resources so forget the bonus.

    I realized that I wasn’t doing things correctly.
    Using a relative path to access a resource is not reliable since the program can be executed from anywhere.
    What I did is to look for resources in a hierarchy of folder, starting from user specified, to environment variable, to relative directories and finally to standard unix directories.

    So actually, the copy phase during the build is not necessary anymore. Only the installation matters and that is fairly easy:

    install(DIRECTORY share/ DESTINATION share)
    

    FYI, I kept my custom_target as is since I like having resources visible in Xcode, and calling it Resources makes it pretty 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application (KaleidoscopeApplication) organized as follows: Solution (6 projects) Cryptography (DLL)
I have a C project where all code is organized in *.c / *.h
I have a project that is organized something like project/ __init__.py builder.py component/ __init__.py
I have a jboss seam 2.2.2 project and it is my first time using
I have the project organized in this way: User is the main resource, each
My project modules are organized in such a way that I have to maintain
I have two targets on my project - iPad and iPhone. Some resources, as
I Have an MVC Project roughly organized like this: Project 1: MVC app (ViewModels,
I have project that I'm working on that is going to require a webserver.
I have project Emle in Launchpad . I set it to import from emle.svn.sourceforge.net

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.