[CMake] Compiling OpenGL application with CMake

Christopher Harvey chris at basementcode.com
Tue Feb 24 22:11:01 EST 2009


Packages don't have to be required because many projects don't require
every single library they can use. For example, not requiring libpng
just means if it's not on the system then your project can't open pngs.

Andrea Tagliasacchi wrote:
> This is a bit odd to me. Why would not everything be required?
> Are there situations in which you might not need a package?
>
> Maybe I can answer my own question...
>
> If you have 2 libraries A and B that do the same task maybe you can
> use different compile rules like you showed below, while if A is the only
> one, then "REQUIRED" gives the trick.
>
> --
> Andrea Tagliasacchi
>
>
>     You might want to consider adding the REQUIRED keyword to the
>     find_package() command if the package is absolutely essential to
>     compiling your entire project.  It should yield a far more useful
>     error message if the package is not found.
>     If you don't declare a package REQUIRED, a good rule of thumb is
>     to use conditionals keyed on the CMake module's found variable
>     (e.g OPENGL_FOUND ) to control where you use it.
>     *find_package(Foo)
>     if(FOO_FOUND)
>        include_directories(${FOO_INCLUDE_DIR})
>     endif()
>     *
>     -- 
>     Philip Lowman
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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



More information about the CMake mailing list