[cmake-developers] Knowing if a C project is being built
Rolf Eike Beer
eike at sf-mail.de
Wed Feb 22 11:32:08 EST 2012
Brad King wrote:
> On 2/21/2012 5:47 PM, Stephen Kelly wrote:
> >> add_library(mylib mylib.c)
> >> generate_export_header(mylib)
> >
> > I'm looking into fixing this bug, and I was wondering how to. I have never
> > built C code with CMake.
> >
> > I will need to conditionally call different check_compiles macros. Can I
> > so
> > something like
> >
> > if(CMAKE_C_PROJECT)
> > check_cxx_compiler_flag(-fvisibility=hidden
> > COMPILER_HAS_HIDDEN_VISIBILITY)
> > else()
> > check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
> > endif()
>
> Use CMAKE_<LANG>_COMPILER_LOADED to determine which
> languages are enabled. Then check both C and CXX
> compilers. If the results are the same then you
> can just write the header normally. Otherwise write
> the header with #ifdef __cplusplus to distinguish
> the two compilers.
In the last modification in FindOpenMP I used the ENABLED_LANGUAGES property.
Which of both ways is the preferred one?
Eike
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120222/0f06a047/attachment.sig>
More information about the cmake-developers
mailing list