On Monday 07 June 2010, Mark Moll wrote:
> I must be missing something obvious, but I can’t get try_compile to work. I
> have the following file, CheckSZencoder.cpp:
>
> #include <stdlib.h>
> #include <szlib.h>
> int main(void)
> {
>     if(SZ_encoder_enabled() == 1)
>         exit(0);
>     else
>         exit(1);
> }
>
>
> I have these cmake commands:
>
> find_library(SZ_LIBRARY sz DOC "Szip library")
> find_path(SZ_INCLUDE szlib.h DOC "Szip include directory")
> message("${SZ_INCLUDE}\n${SZ_LIBRARY}")
> try_compile(SZ_ENCODER "${PROJECT_BINARY_DIR}"
>       "${CMAKE_SOURCE_DIR}/CMakeModules/CheckSZencoder.cpp"
>       CMAKE_FLAGS
>       INCLUDE_DIRECTORIES ${SZ_INCLUDE}
>       LINK_LIBRARIES ${SZ_LIBRARY}
>       OUTPUT_VARIABLE szoutput)
> message(${szoutput})

I'd recommend not to use try_compile() directly.
Checkout whether check_include_files(), check_library_exists() or 
check_c_source_compiles() do what you need. They are much easier to use.

Alex
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to