Hi Greg, Thanks for helping!
Could you please send me an example file that is working for you? Below is a short testcase (the original CMakeLists.txt is rather long and spread across several files) with the commands relevant for add_library add_executable. I am using CMake 2.6-patch1 and Visual C++ 2008 Express. I will try as you said without source_group.
Cheers, Thomas _______________________________________ cmake_minimum_required(VERSION 2.4) project(libname) file(GLOB_RECURSE HEADERS ${PATH}/include/*.h) file(GLOB_RECURSE SOURCES ${PATH}/src/*.cpp) set(SOURCE_FILES ${HEADERS} ${SOURCES}) source_group("CMake Makefile" FILES CMakeLists.txt) source_group("Header File" REGULAR_EXPRESSION ".\\.h") source_group("Source Files" REGULAR_EXPRESSION ".*\\.cxx|.*\\.cpp") add_library(libname STATIC ${SOURCE_FILES}) add_executable(test "${PATH}/test.cpp") add_dependencies(test libname) target_link_libraries(test libname) Greg Peele wrote:
Thomas, I don't know how helpful saying this will be, but it works for me, at least for CMake 2.6.1 and VS 2008 Express. My same project also builds unchanged for 2005 Professional and 2003 Professional, and the headers even end up in the right project folders by default (I don't use source group or any globbing though). Could you provide an example of how you're using add_library or add_executable? Greg Peele Applied Research Associates, Inc. On Thu, 2008-08-28 at 01:10 +0200, Thomas T. wrote: > Hi CMakers! > > CMake is a great tool for cross-platform development, thanks! > > There is just one thing that is disturbing my workflow: After > searching the forums, and coming up with no working solution, I would > like to ask about including headers in a Visual C++ 2008 project with > cmake -G "Visual Studio 9 2008". Without including them, a lot of IDE > features like code completion (IntelliSense), class browser, search > and replace, and the file browser are broken for things that are in a > library project's headers, so it is not really a cosmetic but a real > productivity issue. > > The problem is, CMake seems not to provide an option to specifically > include the .h files explicitly as headers, but only as source files > like the .cpp files. It might have worked in previous versions of > Visual Studio, I have not tested it, but in 2008, the compiler tries > to compile the .h files if they are passed as parameters to > add_library or add_executable as the mailinglist archives suggest for > previous versions of Visual Studio. > > When opening the generated Visual C++ 2008 project, the header files > are there and even in the right filter folder since I use > source_group() and file(GLOB_RECURSE ...). However, when I compile, > the compiler tries to compile the header files as if they were .cpp > files, which leads to all kinds of strange results - from warnings > about no public symbols for object file to linker errors about > undefined external symbols for functions that are declared in a .h > file, but implemented in a .cpp file. > > It seems the root of the problem is that CMake adds them as source > files, not as headers, but there must be another way to do it - > probably we need to file a bug? > > Cheers, > Thomas > > > _______________________________________________ > CMake mailing list > CMake@cmake.org > http://www.cmake.org/mailman/listinfo/cmake
_______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake