>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. I want the cmake-generated VS solution to include a "Header Files" folder in the project containing all .h files. Perhaps there are other ways of accomplishing this but adding them to add_library() or add_executable() works well enough.
># Make sure the library is up to date >add_dependencies(cmTestMain cmTestLib) I had tried this previously. It does not fix the problem and appears to have no effect on the generated VS solution. How did you expect that to change the generated VS project/solution? >add_library (cmTestLib STATIC MySub.cpp) That will solve the problem but I don't consider it an acceptable solution in the general case. As I stated in my original post, this one-executable, one-lib example is a trivial one to reproduce the problem. In general, the complete project (VS solution) would have several executables depending on the same library. Surely you are not suggesting putting an add_library() entry in all the CMakeLists.txt files associated with those executables? That would destroy most of the advantages of having a library in the first place-- basically a "sledgehammer" solution to use your phrase. >If I understand your problem correctly, I fear you may be trying to use a sledgehammer to crack a peanut! What do you consider the downsides of the approach I proposed? Based on limited testing, I have not run into problems with having all exe and lib files in a single directory. I don't like having to add the two set() entries but they are only in the top-level CMakeLists.txt file. When I first posted my request for help with this problem, I assumed it was a common enough issue that I would quickly get a response with a simple solution. That I have not has left me somewhat astonished. I know people are using cmake with large Visual Studio projects and I assume they are using static libs. So I'm unclear on why there isn't more discussion of this issue. If anyone has insights to share on this, I'd be very interested in hearing them. On Sat, Oct 4, 2014 at 8:12 PM, Jim Butler <[email protected]> wrote: > Bill Greene<[email protected]> 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 > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/ > opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
