Check dl library existence (fix #990)

As FreeBSD includes dl functions in libc, dl library doesn't exist.
(dlfcn.h header file must exist anyway.)
This commit is contained in:
David Capello 2016-03-01 09:16:19 -03:00
parent 1d7184dd37
commit a22039cd16
3 changed files with 19 additions and 3 deletions

View File

@ -20,6 +20,13 @@ int main() {
}
" HAVE_SCHED_YIELD)
check_c_source_compiles("
#include <dlfcn.h>
int main() {
return 0;
}
" HAVE_DLFCN_H)
check_c_source_runs("
int main() {
unsigned long value = 0x40302010ul;
@ -85,5 +92,8 @@ target_link_libraries(base-lib modp_b64)
if(WIN32)
target_link_libraries(base-lib dbghelp shlwapi)
else()
target_link_libraries(base-lib dl)
find_library(DL_LIBRARY NAMES dl)
if(DL_LIBRARY_FOUND)
target_link_libraries(base-lib ${DL_LIBRARY})
endif()
endif()

View File

@ -1,5 +1,5 @@
// Aseprite Base Library -*- C++ -*-
// Copyright (c) 2001-2015 David Capello
// Copyright (c) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -10,6 +10,7 @@
#cmakedefine HAVE_STDINT_H
#cmakedefine HAVE_SCHED_YIELD
#cmakedefine HAVE_DLFCN_H
#cmakedefine ASEPRITE_LITTLE_ENDIAN
#cmakedefine ASEPRITE_BIG_ENDIAN

View File

@ -5,7 +5,12 @@
// Read LICENSE.txt for more information.
#include "base/string.h"
#include <dlfcn.h>
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#else
#error dlfcn.h is needed or include a file that defines dlopen/dlclose
#endif
namespace base {