[CMake] Main program not getting rebuilt when library changes.

Jim Butler j.e.butler at limitpoint.com
Sat Oct 4 20:12:45 EDT 2014


Bill Greene<w.h.greene at gmail.com>  wrote:

> add_library (cmTestLib STATIC MySub.cpp MySub.h)
You need not include the header files in an add_library call. They'll be 
found by the compiler, provided you have  included them in the cpp files.

If I understand your problem correctly, I fear you may be trying to use 
a sledgehammer to crack a peanut!

Try this:

         add_library (cmTestLib STATIC MySub.cpp)

         add_executable(cmTestMain cmTestMain.cpp)

         # Make sure the library is up to date
         add_dependencies(cmTestMain cmTestLib)

         # Add lib to the link line
         target_link_libraries(cmTestMain cmTestLib)

Cheers,
Jim

--
Jim Butler
Build Systems Engineer
Limit Point Systems, Inc.
http://cmake.limitpoint.com


More information about the CMake mailing list