[Cmake] Adding Header files to CMakeLists.txt

Ian Scott ian.m.scott at stud.man.ac.uk
Fri Aug 17 06:20:16 EDT 2001


Hi,

I've been playing around with adding .h files to the CMakeLists.txt, so that
they appear in my generated .dsp file.* This appears to do the correct thing
under NT, adding them to the "Header Files" cmSourceGroup, and then into the
correct place in the dsp file.

My CMakeLists.txt file looks like


ADD_LIBRARY(ian ian_sources)

SOURCE_FILES(ian_sources
ian_file1.cxx
ian_file1.h
ian_file2.cxx
ian_file2.h
)


However using the same CMakeLists.txt file under Unix, it attempts to build
ian_file2.o and ian_file1.o twice

So my solution is
ADD_LIBRARY(ian ian_sources)

SOURCE_FILES(ian_sources
ian_file1.cxx
ian_file2.cxx
)

IF (WIN32)
  SOURCE_FILES(ian_sources
  ian_file1.h
  ian_file2.h
  )
ENDIF(WIN32)

This appears to work satisfactorily. However, I wondered if it was
necessary, or if I or CMake was doing something wrong?

Many thanks,
Ian.


* I know that some UNIX users will have doubts about the desirability of
this. However, our NT users have been complaining loudly about the lack of
.h files in the produced DSP files, and our UNIX users are willing to
tolerate additions to the CMakeLists.txt.





More information about the CMake mailing list