How to avoid duplicate compile for each sub directory in which CMakeLists is defined with same resources.

I can't publish here actual CMakeLists and compile output for my company resource names.

I have a tree structure for my project.

```

root

  |- src

      |-  resource1.cpp

      |_ resource2.cpp

  |_test

       |- test1

       |- test2

```

test1 and test2 folder has each CMakeLists, but use same resources in src folder.

But I run "make" on the root directory. (actually ${PROJECT_SOURCE_DIR} = project root/cmake-build-debug folder)

When this situation, each test folder has independent directory in which compiled objects stored.

During compile time I got this message :

```

test/test1/CmakeFiles/executablename1.dir/_/_/src/resource1.cpp.o

test/test1/CmakeFiles/executablename1.dir/_/_/src/resource2.cpp.o

test/test1/CmakeFiles/executablename2.dir/_/_/src/resource1.cpp.o

test/test1/CmakeFiles/executablename2.dir/_/_/src/resource2.cpp.o

test/test2/CmakeFiles/executablename1.dir/_/_/src/resource1.cpp.o

test/test2/CmakeFiles/executablename1.dir/_/_/src/resource2.cpp.o

test/test2/CmakeFiles/executablename2.dir/_/_/src/resource1.cpp.o

test/test2/CmakeFiles/executablename2.dir/_/_/src/resource2.cpp.o

```

I use same resource in same time. but compilation time is growing exponentially whenever I add test case executable and test folders.

How can I do just 1 compile for same resources ?

0

Hi!

Sorry for the delay. It looks really weird. Is it possible for you to send us a project to reproduce (to clion-support at jetbrains.com)?

0

请先登录再写评论。