[CMake] Compiling header files

David Doria daviddoria at gmail.com
Tue Nov 16 14:03:22 EST 2010


I am trying to use ADD_LIBRARY to create a .lib file from a collection
of .cpp and .h files.

If I do:
ADD_LIBRARY(LibraryName AllOfTheCPPFiles.cpp)

and then try to link against that library, I get many missing-function
type linker errors. I looked in the .h files and many of them have
actual function definitions:

(an example):
class UdpTransmitSocket : public UdpSocket{
public:
	UdpTransmitSocket( const IpEndpointName& remoteEndpoint )
		{ Connect( remoteEndpoint ); }
};

I tried to tell CMake to compile the .h files into the library as well
by doing this:

set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${CMAKE_CXX_SOURCE_FILE_EXTENSIONS} h)
ADD_LIBRARY(LibraryName AllOfTheCPPFiles.cpp  AllOfTheHFiles.h)

but it didn't seem to change anything. Is there a way this is typically handled?

Thanks,

David


More information about the CMake mailing list