Improve detection of system libraries.

This commit is contained in:
Andreas Schneider 2009-09-01 12:25:10 +02:00
parent 93acacfa62
commit 16c76166bd
4 changed files with 17 additions and 154 deletions

View file

@ -14,3 +14,19 @@ set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
set(BINARYDIR ${CMAKE_BINARY_DIR})
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
# FUNCTIONS
check_library_exists(dl dlopen "" HAVE_LIBDL)
if (HAVE_LIBDL)
find_library(DLFCN_LIBRARY dl)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${DLFCN_LIBRARY})
endif (HAVE_LIBDL)
check_library_exists(rt clock_gettime "" HAVE_LIBRT)
if (HAVE_LIBRT)
find_library(RT_LIBRARY rt)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${RT_LIBRARY})
endif (HAVE_LIBRT)
set(CSYNC_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "csync required system libraries")

View file

@ -1,74 +0,0 @@
# - Try to find Dlfcn
# Once done this will define
#
# DLFCN_FOUND - system has Dlfcn
# DLFCN_INCLUDE_DIRS - the Dlfcn include directory
# DLFCN_LIBRARIES - Link these to use Dlfcn
# DLFCN_DEFINITIONS - Compiler switches required for using Dlfcn
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (DLFCN_LIBRARIES AND DLFCN_INCLUDE_DIRS)
# in cache already
set(DLFCN_FOUND TRUE)
else (DLFCN_LIBRARIES AND DLFCN_INCLUDE_DIRS)
find_path(DLFCN_INCLUDE_DIR
NAMES
dlfcn.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(DL_LIBRARY
NAMES
dl
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (DL_LIBRARY)
set(DL_FOUND TRUE)
endif (DL_LIBRARY)
set(DLFCN_INCLUDE_DIRS
${DLFCN_INCLUDE_DIR}
)
if (DL_FOUND)
set(DLFCN_LIBRARIES
${DLFCN_LIBRARIES}
${DL_LIBRARY}
)
endif (DL_FOUND)
if (DLFCN_INCLUDE_DIRS AND DLFCN_LIBRARIES)
set(DLFCN_FOUND TRUE)
endif (DLFCN_INCLUDE_DIRS AND DLFCN_LIBRARIES)
if (DLFCN_FOUND)
if (NOT Dlfcn_FIND_QUIETLY)
message(STATUS "Found Dlfcn: ${DLFCN_LIBRARIES}")
endif (NOT Dlfcn_FIND_QUIETLY)
else (DLFCN_FOUND)
if (Dlfcn_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Dlfcn")
endif (Dlfcn_FIND_REQUIRED)
endif (DLFCN_FOUND)
# show the DLFCN_INCLUDE_DIRS and DLFCN_LIBRARIES variables only in the advanced view
mark_as_advanced(DLFCN_INCLUDE_DIRS DLFCN_LIBRARIES)
endif (DLFCN_LIBRARIES AND DLFCN_INCLUDE_DIRS)

View file

@ -1,74 +0,0 @@
# - Try to find RT
# Once done this will define
#
# RT_FOUND - system has RT
# RT_INCLUDE_DIRS - the RT include directory
# RT_LIBRARIES - Link these to use RT
# RT_DEFINITIONS - Compiler switches required for using RT
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (RT_LIBRARIES AND RT_INCLUDE_DIRS)
# in cache already
set(RT_FOUND TRUE)
else (RT_LIBRARIES AND RT_INCLUDE_DIRS)
find_path(RT_INCLUDE_DIR
NAMES
time.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(RT_LIBRARY
NAMES
rt
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (RT_LIBRARY)
set(RT_FOUND TRUE)
endif (RT_LIBRARY)
set(RT_INCLUDE_DIRS
${RT_INCLUDE_DIR}
)
if (RT_FOUND)
set(RT_LIBRARIES
${RT_LIBRARIES}
${RT_LIBRARY}
)
endif (RT_FOUND)
if (RT_INCLUDE_DIRS AND RT_LIBRARIES)
set(RT_FOUND TRUE)
endif (RT_INCLUDE_DIRS AND RT_LIBRARIES)
if (RT_FOUND)
if (NOT RT_FIND_QUIETLY)
message(STATUS "Found RT: ${RT_LIBRARIES}")
endif (NOT RT_FIND_QUIETLY)
else (RT_FOUND)
if (RT_FIND_REQUIRED)
message(FATAL_ERROR "Could not find RT")
endif (RT_FIND_REQUIRED)
endif (RT_FOUND)
# show the RT_INCLUDE_DIRS and RT_LIBRARIES variables only in the advanced view
mark_as_advanced(RT_INCLUDE_DIRS RT_LIBRARIES)
endif (RT_LIBRARIES AND RT_INCLUDE_DIRS)

View file

@ -4,8 +4,6 @@ add_subdirectory(std)
find_package(SQLite3 REQUIRED)
find_package(Iniparser REQUIRED)
find_package(Dlfcn REQUIRED)
find_package(RT REQUIRED)
set(CSYNC_PUBLIC_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}
@ -14,8 +12,6 @@ set(CSYNC_PUBLIC_INCLUDE_DIRS
)
set(CSYNC_PRIVATE_INCLUDE_DIRS
${DLFCN_INCLUDE_DIRS}
${RT_INCLUDE_DIRS}
${INIPARSER_INCLUDE_DIRS}
${LOG4C_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIRS}
@ -31,8 +27,7 @@ set(CSYNC_LIBRARY
set(CSYNC_LINK_LIBRARIES
${CSYNC_LIBRARY}
${CSTDLIB_LIBRARY}
${DLFCN_LIBRARIES}
${RT_LIBRARIES}
${CSYNC_REQUIRED_LIBRARIES}
${INIPARSER_LIBRARIES}
${LOG4C_LIBRARIES}
${SQLITE3_LIBRARIES}