4

I have a bunch of C++ source files and static libraries which form a framework F. To use this, I have created a main_A.cpp and some cMake files, which create an executable and run successfully (project A).

Now I use a different main_B.cpp for project B. For this I created an own cMakeLists.txt with e.g. a different executable name and which refers to the config.cmake files for framework F

framework F (global config.cmake)  
|  
|___ project A   
|  
|___ project B (own cMakeLists.txt)  

When I compile project B after project A, all the files from framework F get recompiled, which takes long and is unnecessary.

How do I get cMake to detect that framework F is already compiled when using a different projects?

Approach: Create static libraries, and compile them into a common folder (lib):

add_library( framework STATIC ${SRC_FILES} )
set_target_properties( framework PROPERTIES LIBRARY_OUTPUT_DIRECTORY /lib)

The libraries got compiled and put into /lib but when I compile project B, everything gets re-compiled.

  • 2
    Possible duplicate of [Making cmake library accessible by other cmake packages automatically](http://stackoverflow.com/questions/33462209/making-cmake-library-accessible-by-other-cmake-packages-automatically) – Florian Dec 15 '16 at 20:34

0 Answers0