2

I have a folder full of source files (*.h, *.cpp), that I want to include in a new project. However, the folder also contains two files (main.cpp, CMakeLists.txt) that I don't want to include in the new project (for obvious reasons).

I know that the commands:

aux_source_directory(. SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST}) 

add all the source files in the project directory to the project. Also I could say:

aux_source_directory(/path/to/folder/ SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST}) 

to include all source files in a folder. But how can I exclude some specific files (in this example, /path/to/folder/main.cpp and /path/to/folder/CMakeLists.txt)?

1
  • 2
    I would recommend against doing this for a variety of reasons that have been discussed before, see stackoverflow.com/a/18538444/393701 Commented Dec 17, 2014 at 15:33

1 Answer 1

3

But how can I exclude some specific files

Try this (according to Documentation):

list (REMOVE_ITEM SRC_LIST /path/to/folder/main.cpp /path/to/folder/CMakeLists.txt) 

This question looks like related.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.