Hi Roger,

> However, do I still need to independently check for <dlfcn.h>?

How do I know that I have a working dlopen?


dlopen defined in dlfcn.h is part of POSIX so generally if you're on a *nix
system then you can rely on it being there.  The associated library,
however, is a different story, hence CMAKE_DL_LIBS.  So then your code
would be:

----- Begin fooUnix.c -----
...
#include <dlfcn.h>
...
void foo()
{
  void *dl = dlopen(...);
  ...
}
...
----- End fooUnix.c -----

----- Begin CMakeLists.txt -----
...
if(UNIX)
   add_library(FooLib fooUnix.c)
  if(CMAKE_DL_LIBS)
    target_link_libraries(FooLib ${CMAKE_DL_LIBS})
  endif()
endif()
...
----- End CMakeLists.txt -----

which is actually overkill since you could avoid the if(CMAKE_DL_LIBS)
check entirely since passing an empty library list to target_link_libraries
is still valid.


- Chuck
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to