<div dir="ltr">On Mon, Sep 22, 2008 at 10:00 AM, Roy Zuo <span dir="ltr">&lt;<a href="mailto:ROYLZUO@gmail.com">ROYLZUO@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello eveyone,<br>
<br>
I am just new to cmake and have some trouble when compiling a big<br>
project whose cpp source files are put deep inside subdirectories.<br>
<br>
In my CMakeLists.txt, I use AUX_SOURCE_DIRECTORY(subdir VARX) and<br>
SET(SRC ${VAR1} ${VAR2} ...) to put all the source files in a<br>
variable, and then use ADD_EXECUTABLE(foo main.c ${SRC}) to make the<br>
executable. However, there are some cpp files containing only inline<br>
functions, and when complier tries to compile them into .o files, a<br>
lot of errors are throw out. So my question is, how to exclude those<br>
files from the compilation?<br>
<br>
I know this question is naive because this is my first time working<br>
with cmake as well as C++.</blockquote><div>There are a lot of solutions. One (possible most correct) is to keep in cpp files only code which should be compiled. Put other code to headers. For example, we&#39;ve used &quot;.inl&quot; or &quot;-inl.h&quot; files for template code which were included only to .cpp files (keeping prototypes in separate header).<br>
<br>Next, you can try using list(remove_item) function as work-around for your problem.<br>For example, you know exact list of your not-to-compile files:<br>set(MY_INLINE_FILES file1.cpp file2.cpp)<br>list(remove_item SRC ${MY_INLINE_FILES})<br>
<br>OR, It will be better to exclude such files from compilation, keeping them in target&#39;s sources, so CMake will put them into corresponding VS project:<br>set_source_files_properties(${MY_INLINE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)<br>
So, generated build system will not try to compile these files. We used this approach to include all sources into Studio projects (including linix-specific ones).<br>Also, you can mark them:<br>source_group(&quot;Inline files&quot; ${MY_INLINE_FILES})<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
Kind regards,<br>
<br>
Roy<br>
_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>