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)?

a06e
  • 18,594
  • 33
  • 93
  • 169
  • 2
    I would recommend against doing this for a variety of reasons that have been discussed before, see http://stackoverflow.com/a/18538444/393701 – SirDarius Dec 17 '14 at 15:33

1 Answers1

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.

Community
  • 1
  • 1
Gluttton
  • 5,739
  • 3
  • 31
  • 58