[CMake] Conditional compiling [i.e. OpenMP]
Eric Noulard
eric.noulard at gmail.com
Tue Aug 31 07:59:33 EDT 2010
2010/8/31 Raymond Wan <r.wan at aist.go.jp>:
>
> #####
> FIND_PACKAGE (OpenMP)
>
> if (OPENMP_FOUND)
> SET (HAVE_OPENMP 1)
> SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
> endif()
> #####
>
> and then created a "config.hpp.in" which had this:
>
> #cmakedefine HAVE_OPENMP 1
>
> config.hpp gets generated fine, but it ends up having this:
>
> /* #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.
We are missing your CONFIGURE_FILE statement how does it look like?
May be you can try a simple test:
set(OPENMP_FOUND 1)
if (OPENMP_FOUND)
SET (HAVE_OPENMP 1)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/config.hpp)
with your current config.hpp.in.
If this does not generate the appropriate config.hpp file then
send this minimal project (CMakeLists.txt + config.hpp.in) on the list.
Which version of CMake are you using?
What is your platform (Linux, Windows, MacOS...)
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list