[CMake] Conditional compiling [i.e. OpenMP]

Raymond Wan r.wan at aist.go.jp
Tue Aug 31 12:22:13 EDT 2010

Hi Eric,

On Tue, Aug 31, 2010 at 20:59, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2010/8/31 Raymond Wan <r.wan at aist.go.jp>:
>> /* #undef HAVE_OPENMP */
>> I can confirm that OpenMP is being detected because I can see the
>> various values being defined in CMakeCache.txt.  HAVE_OPENMP is not in
>> this file, though (it should, I presume?).
> HAVE_OPENMP is not in CMakeCache.txt because you did not defined
> it to be a cache var.
> However, I don't think HAVE_OPENMP have to be a cache var for this to work.

I see.  I didn't realize that I had to make variables into cache-able
and that they aren't be default.  I'll read more about it; I thought
it was by default and that I could use CMakeCache.txt to see where the
problem was.

> We are missing your CONFIGURE_FILE statement how does it look like?
> May be you can try a simple test:
> endif()
> configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in
>                            ${CMAKE_CURRENT_BINARY_DIR}/config.hpp)

Thank you for this!  As I just said in my previous message to the
list, that was exactly my problem.  I didn't realize the importance of
the location of "configure_file" and placed it at the top of
CMakeLists.txt.  In hindsight, that was such a terrible idea!

I've been looking at the cmake docs for individual commands and
somewhat ignoring their order (since some, like the compiler flags,
just append to what it is so far).  This thinking got me in
trouble...and I'll be careful about this -- thank you!


More information about the CMake mailing list