cmake support

This commit is contained in:
Vítor Santos Costa
2014-12-14 12:05:43 +00:00
parent 289a36a0a1
commit 90feb7f9f8
32 changed files with 2309 additions and 2047 deletions

View File

@@ -108,7 +108,8 @@ endif (HAVE_LIBM)
check_library_exists( dl dlopen "" HAVE_LIBDL )
if (HAVE_LIBDL)
set(EXTRALIBS ${EXTRALIBS} dl)
target_link_libraries(libYap dl)
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} dl )
set(HAVE_DLOPEN 1)
endif (HAVE_LIBDL)
@@ -118,84 +119,76 @@ if (WIN32)
set(EXTRALIBS ${EXTRALIBS} comdlg32)
endif (HAVE_LIBCOMDLG32)
check_library_exists( msvcrt strtok "" HAVE_LIBMSCRT )
if (HAVE_LIBMSCRT)
set(EXTRALIBS ${EXTRALIBS} mscrt)
endif (HAVE_LIBMSCRT)
check_library_exists( shell32 main "" HAVE_LIBSHELL32 )
if (HAVE_LIBSHELL32)
set(EXTRALIBS ${EXTRALIBS} shell32)
endif (HAVE_LIBSHELL32)
check_library_exists( wsock32 main "" HAVE_LIBWSOCK32 )
if (HAVE_LIBWSOCK32)
set(EXTRALIBS ${EXTRALIBS} wsock32)
endif (HAVE_LIBWSOCK32)
check_library_exists( ws2_32 main "" HAVE_LIBWS2_32 )
if (HAVE_LIBWS2_32)
set(EXTRALIBS ${EXTRALIBS} ws2_32)
endif (HAVE_LIBWS2_32)
endif()
check_library_exists( crypt crypt "" HAVE_LIBCRYPT )
if (HAVE_LIBCRYPT)
set(EXTRALIBS ${EXTRALIBS} crypt)
target_link_libraries(libYap crypt)
endif (HAVE_LIBCRYPT)
check_library_exists( judy Judy1Set "" HAVE_LIBJUDY )
if (HAVE_LIBJUDY)
set(EXTRALIBS ${EXTRALIBS} judy)
endif (HAVE_LIBJUDY)
check_library_exists( log main "" HAVE_LIBLOG )
if (HAVE_LIBLOG)
set(EXTRALIBS ${EXTRALIBS} log)
endif (HAVE_LIBLOG)
# check_library_exists( nsl nis_add "" HAVE_LIBNSL )
# if (HAVE_LIBNSL)
# target_link_libraries(libYap nsl)
# endif (HAVE_LIBNSL)
check_library_exists( nsl nis_add "" HAVE_LIBNSL )
if (HAVE_LIBNSL)
set(EXTRALIBS ${EXTRALIBS} nsl)
endif (HAVE_LIBNSL)
# check_library_exists( nss_dns main "" HAVE_LIBNSS_DNS )
# if (HAVE_LIBNSS_DNS)
# target_link_libraries(libYap nss_dns)
# endif (HAVE_LIBNSS_DNS)
check_library_exists( nss_dns main "" HAVE_LIBNSS_DNS )
if (HAVE_LIBNSS_DNS)
set(EXTRALIBS ${EXTRALIBS} nss_dns)
endif (HAVE_LIBNSS_DNS)
# check_library_exists( nss_files main "" HAVE_LIBNSS_FILES )
# if (HAVE_LIBNSS_FILES)
# set(EXTRALIBS ${EXTRALIBS} nss_files)
# endif (HAVE_LIBNSS_FILES)
check_library_exists( nss_files main "" HAVE_LIBNSS_FILES )
if (HAVE_LIBNSS_FILES)
set(EXTRALIBS ${EXTRALIBS} nss_files)
endif (HAVE_LIBNSS_FILES)
# check_library_exists( psapi main "" HAVE_LIBPSAPI )
# if (HAVE_LIBPSAPI)
# set(EXTRALIBS ${EXTRALIBS} psapi)
# endif (HAVE_LIBPSAPI)
check_library_exists( psapi main "" HAVE_LIBPSAPI )
if (HAVE_LIBPSAPI)
set(EXTRALIBS ${EXTRALIBS} psapi)
endif (HAVE_LIBPSAPI)
check_library_exists( resolv main "" HAVE_LIBRESOLV )
if (HAVE_LIBRESOLV)
set(EXTRALIBS ${EXTRALIBS} resolv)
endif (HAVE_LIBRESOLV)
# check_library_exists( resolv main "" HAVE_LIBRESOLV )
# if (HAVE_LIBRESOLV)
# set(EXTRALIBS ${EXTRALIBS} resolv)
# endif (HAVE_LIBRESOLV)
check_library_exists( socket main "" HAVE_LIBSOCKET )
if (HAVE_LIBSOCKET)
set(EXTRALIBS ${EXTRALIBS} socket)
endif (HAVE_LIBSOCKET)
check_library_exists( stdc__ main "" HAVE_LIBSTDC__ )
if (HAVE_LIBSTDC__)
set(EXTRALIBS ${EXTRALIBS} stdc__)
endif (HAVE_LIBSTDC__)
# check_library_exists( socket socket "" HAVE_LIBSOCKET )
# if (HAVE_LIBSOCKET)
# set(EXTRALIBS ${EXTRALIBS} socket)
# endif (HAVE_LIBSOCKET)
check_library_exists( unicode main "" HAVE_LIBUNICODE )
if (HAVE_LIBUNICODE)
set(EXTRALIBS ${EXTRALIBS} unicode)
endif (HAVE_LIBUNICODE)
check_library_exists( ws2_32 main "" HAVE_LIBWS2_32 )
if (HAVE_LIBWS2_32)
set(EXTRALIBS ${EXTRALIBS} ws2_32)
endif (HAVE_LIBWS2_32)
check_library_exists( xnet main "" HAVE_LIBXNET )
if (HAVE_LIBXNET)
set(EXTRALIBS ${EXTRALIBS} xnet)

9
cmake/EmptyArray.c Normal file
View File

@@ -0,0 +1,9 @@
#include <sys/types.h>
int array[0];
int
main ()
{
return array[1];
}

View File

@@ -2,7 +2,7 @@
#Works under the assumption than when gecode is installed at least the kernel component exists
# Look for the header file
find_path(GECODE_INCLUDE_DIR NAMES gecode/kernel.hh)
find_path(GECODE_INCLUDE_DIR NAMES gecode/kernel.hh )
find_file(GECODE_CONFIG gecode/support/config.hpp)
# Look for the library
find_library(GECODE_LIBRARY NAMES gecodekernel)
@@ -40,6 +40,10 @@ if(GECODE_FOUND)
if(GECODE_INT_LIBRARY)
list(APPEND GECODE_LIBRARIES ${GECODE_INT_LIBRARY})
endif()
find_library(GECODE_FLOAT_LIBRARY gecodefloat)
if(GECODE_FLOAT_LIBRARY)
list(APPEND GECODE_LIBRARIES ${GECODE_FLOAT_LIBRARY})
endif()
find_library(GECODE_MM_LIBRARY gecodeminimodel)
if(GECODE_MM_LIBRARY)
list(APPEND GECODE_LIBRARIES ${GECODE_MM_LIBRARY})

View File

@@ -1,99 +1,77 @@
# -*- cmake -*-
#
# FindR.cmake: Try to find R
# - This module locates an installed R distribution.
#
# (C) Copyright 2005-2012 EDF-EADS-Phimeca
# Defines the following:
# R_COMMAND - Path to R command
# R_HOME - Path to 'R home', as reported by R
# R_INCLUDE_DIR - Path to R include directory
# R_LIBRARY_BASE - Path to R library
# R_LIBRARY_BLAS - Path to Rblas / blas library
# R_LIBRARY_LAPACK - Path to Rlapack / lapack library
# R_LIBRARY_READLINE - Path to readline library
# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE]
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
# VTK_R_HOME - (deprecated, use R_HOME instead) Path to 'R home', as reported by R
#
# This library is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# Variable search order:
# 1. Attempt to locate and set R_COMMAND
# - If unsuccessful, generate error and prompt user to manually set R_COMMAND
# 2. Use R_COMMAND to set R_HOME
# 3. Locate other libraries in the priority:
# 1. Within a user-built instance of R at R_HOME
# 2. Within an installed instance of R
# 3. Within external system libraries
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# @author dutka
# @date 2010-02-04 16:44:49 +0100 (Thu, 04 Feb 2010)
# Id Makefile.am 1473 2010-02-04 15:44:49Z dutka
#
#
# - Try to find R
# Once done this will define
#
# R_FOUND - System has R
# R_LIBRARIES - The libraries needed to use R
# R_DEFINITIONS - Compiler switches required for using R
# R_EXECUTABLE - The R interpreter
set(TEMP_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
set(CMAKE_FIND_APPBUNDLE "NEVER")
find_program(R_COMMAND R DOC "R executable.")
set(CMAKE_FIND_APPBUNDLE ${TEMP_CMAKE_FIND_APPBUNDLE})
if ( R_EXECUTABLE AND R_LIBRARIES )
# in cache already
set( R_FIND_QUIETLY TRUE )
endif ( R_EXECUTABLE AND R_LIBRARIES )
if(R_COMMAND)
execute_process(WORKING_DIRECTORY .
COMMAND ${R_COMMAND} RHOME
OUTPUT_VARIABLE R_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
# deprecated
if(VTK_R_HOME)
set(R_HOME ${VTK_R_HOME} CACHE PATH "R home directory obtained from R RHOME")
else()
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
set(VTK_R_HOME ${R_HOME})
endif()
# /deprecated
# the following command does nothing currently, but will be used when deprecated code is removed
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
#IF (NOT WIN32)
# # use pkg-config to get the directories and then use these values
# # in the FIND_PATH() and FIND_LIBRARY() calls
# FIND_PACKAGE(PkgConfig)
# PKG_CHECK_MODULES(PC_R R)
# SET(R_DEFINITIONS ${PC_R_CFLAGS_OTHER})
#ENDIF (NOT WIN32)
find_path(R_INCLUDE_DIR R.h
HINTS ${R_ROOT_DIR}
PATHS /usr/local/lib /usr/local/lib64 /usr/share
PATH_SUFFIXES include R/include
DOC "Path to file R.h")
find_program ( R_EXECUTABLE
NAMES R R.exe
DOC "Path to the R command interpreter"
)
find_library(R_LIBRARY_BASE R
HINTS ${R_ROOT_DIR}/lib
DOC "R library (example libR.a, libR.dylib, etc.).")
get_filename_component ( _R_EXE_PATH ${R_EXECUTABLE} PATH )
find_library(R_LIBRARY_BLAS NAMES Rblas blas
HINTS ${R_ROOT_DIR}/lib
DOC "Rblas library (example libRblas.a, libRblas.dylib, etc.).")
if ( R_EXECUTABLE )
execute_process ( COMMAND ${R_EXECUTABLE} RHOME
OUTPUT_VARIABLE _R_HOME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif ( R_EXECUTABLE )
find_library(R_LIBRARY_LAPACK NAMES Rlapack lapack
HINTS ${R_ROOT_DIR}/lib
DOC "Rlapack library (example libRlapack.a, libRlapack.dylib, etc.).")
find_library ( R_LIBRARIES
NAMES R
HINTS
${PC_R_LIBDIR}
${PC_R_LIBRARY_DIRS}
${_R_HOME}/lib
${_R_HOME}/lib/x86_64
)
find_library(R_LIBRARY_READLINE readline
DOC "(Optional) system readline library. Only required if the R libraries were built with readline support.")
set ( R_PACKAGES )
if ( R_EXECUTABLE )
foreach ( _component ${R_FIND_COMPONENTS} )
if ( NOT R_${_component}_FOUND )
execute_process ( COMMAND echo "library(${_component})"
COMMAND ${R_EXECUTABLE} --no-save --silent --no-readline --slave
RESULT_VARIABLE _res
OUTPUT_VARIABLE _trashout
ERROR_VARIABLE _trasherr
)
if ( NOT _res )
message ( STATUS "Looking for R package ${_component} - found" )
set ( R_${_component}_FOUND 1 CACHE INTERNAL "True if R package ${_component} is here" )
else ( NOT _res )
message ( STATUS "Looking for R package ${_component} - not found" )
set ( R_${_component}_FOUND 0 CACHE INTERNAL "True if R package ${_component} is here" )
endif ( NOT _res )
list ( APPEND R_PACKAGES R_${_component}_FOUND )
endif ( NOT R_${_component}_FOUND )
endforeach ( _component )
endif ( R_EXECUTABLE )
else()
message(SEND_ERROR "FindR.cmake requires the following variables to be set: R_COMMAND")
endif()
include ( FindPackageHandleStandardArgs )
# handle the QUIETLY and REQUIRED arguments and set R_FOUND to TRUE if
# all listed variables are TRUE
find_package_handle_standard_args ( R DEFAULT_MSG R_EXECUTABLE R_LIBRARIES ${R_PACKAGES} )
mark_as_advanced ( R_EXECUTABLE R_LIBRARIES ${R_PACKAGES} )
# Note: R_LIBRARY_BASE is added to R_LIBRARIES twice; this may be due to circular linking dependencies; needs further investigation
set(R_LIBRARIES ${R_LIBRARY_BASE} ${R_LIBRARY_BLAS} ${R_LIBRARY_LAPACK} ${R_LIBRARY_BASE})
if(R_LIBRARY_READLINE)
set(R_LIBRARIES ${R_LIBRARIES} ${R_LIBRARY_READLINE})
endif()

View File

@@ -1,106 +0,0 @@
# Copyright (C) 2012 - 2013 by Pedro Mendes, Virginia Tech Intellectual
# Properties, Inc., University of Heidelberg, and The University
# of Manchester.
# All rights reserved.
# - Try to find the Raptor RDF parsing library (http://librdf.org/raptor/)
# Once done this will define
#
# RAPTOR_FOUND - system has Raptor
# RAPTOR_LIBRARIES - Link these to use Raptor
# RAPTOR_INCLUDE_DIR - Include directory for using Raptor
# RAPTOR_DEFINITIONS - Compiler switches required for using Raptor
#
# Capabilities
# RAPTOR_HAVE_TRIG - Set if raptor has TRIG
# (c) 2007-2011 Sebastian Trueg <trueg@kde.org>
# (c) 2011 Artem Serebriyskiy <v.for.vandal@gmail.com>
# (c) 2011 Michael Jansen <kde@michael-jansen.biz>
#
# Based on FindFontconfig Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO (FIND_RAPTOR)
ENDMACRO ()
# Check if we have cached results in case the last round was successful.
if (NOT (RAPTOR_INCLUDE_DIR AND RAPTOR_LIBRARIES) OR NOT RAPTOR_FOUND)
set(RAPTOR_LDFLAGS)
find_path(RAPTOR_INCLUDE_DIR raptor.h
PATHS $ENV{RAPTOR_DIR}/include
$ENV{RAPTOR_DIR}
~/Library/Frameworks
/Library/Frameworks
/sw/include # Fink
/opt/local/include # MacPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
NO_DEFAULT_PATH)
if (NOT RAPTOR_INCLUDE_DIR)
find_path(RAPTOR_INCLUDE_DIR raptor.h)
endif ()
find_library(RAPTOR_LIBRARY
NAMES raptor
PATHS $ENV{RAPTOR_DIR}/lib
$ENV{RAPTOR_DIR}/lib-dbg
$ENV{RAPTOR_DIR}
~/Library/Frameworks
/Library/Frameworks
/sw/lib # Fink
/opt/local/lib # MacPorts
/opt/csw/lib # Blastwave
/opt/lib
/usr/freeware/lib64
NO_DEFAULT_PATH)
if (NOT RAPTOR_LIBRARY)
find_library(RAPTOR_LIBRARY NAMES raptor)
endif ()
if (NOT WIN32)
find_package(PkgConfig)
pkg_check_modules(PC_RAPTOR QUIET raptor)
if (PC_RAPTOR_FOUND)
set(RAPTOR_DEFINITIONS ${PC_RAPTOR_CFLAGS_OTHER})
set(RAPTOR_VERSION ${PC_RAPTOR_VERSION} CACHE STRING "Raptor Version found" )
string( REGEX REPLACE "^.*-lraptor;" "" RAPTOR_LDFLAGS "${PC_RAPTOR_STATIC_LDFLAGS}")
string( REGEX REPLACE "-lexpat[;]*" "" RAPTOR_LDFLAGS "${RAPTOR_LDFLAGS}")
endif (PC_RAPTOR_FOUND)
endif (NOT WIN32)
if (RAPTOR_LDFLAGS)
set(RAPTOR_LIBRARY ${RAPTOR_LIBRARY} ${RAPTOR_LDFLAGS})
endif (RAPTOR_LDFLAGS)
mark_as_advanced(RAPTOR_INCLUDE_DIR RAPTOR_LIBRARY)
endif () # Check for cached values
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Raptor
VERSION_VAR RAPTOR_VERSION
REQUIRED_VARS RAPTOR_LIBRARY RAPTOR_INCLUDE_DIR)
mark_as_advanced(RAPTOR_VERSION)
if (NOT RAPTOR_FOUND AND Raptor_FIND_VERSION_MAJOR EQUAL "2" AND NOT Raptor_FIND_QUIET )
pkg_check_modules(PC_RAPTOR QUIET raptor)
if (PC_RAPTOR_FOUND)
message( STATUS "You have raptor1 version ${PC_RAPTOR_VERSION} installed. Please update." )
endif ()
endif ()

View File

@@ -1,21 +1,82 @@
# Find the Readline libraries
#
# READLINE_FOUND - system has Readline lib
# READLINE_INCLUDE_DIR - the Readline include directory
# READLINE_LIBRARIES - Libraries needed to use Readline
# READLINE_HAVE_READLINE_HISTORY_H - true if readline/history.h is available
# - Find the readline library
# This module defines
# READLINE_INCLUDE_DIR, path to readline/readline.h, etc.
# READLINE_LIBRARIES, the libraries required to use READLINE.
# READLINE_FOUND, If false, do not try to use READLINE.
# also defined, but not for general use are
# READLINE_readline_LIBRARY, where to find the READLINE library.
# READLINE_ncurses_LIBRARY, where to find the ncurses library [might not be defined]
if (READLINE_INCLUDE_DIR AND READLINE_LIBRARIES)
# Already in cache, be silent
set(READLINE_FIND_QUIETLY TRUE)
endif (READLINE_INCLUDE_DIR AND READLINE_LIBRARIES)
# Apple readline does not support readline hooks
# So we look for another one by default
IF(APPLE)
FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h PATHS
/sw/include
/opt/local/include
/opt/include
/usr/local/opt/readline/include #brew
/usr/local/include
/usr/include/
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_PATH(READLINE_INCLUDE_DIR NAMES readline/readline.h)
find_path(READLINE_INCLUDE_DIR NAMES readline/readline.h )
find_library(READLINE_LIBRARIES NAMES readline libreadline)
find_file(READLINE_HAVE_READLINE_HISTORY_H readline/history.h)
# Apple readline does not support readline hooks
# So we look for another one by default
IF(APPLE)
FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline PATHS
/sw/lib
/opt/local/lib
/usr/local/opt/readline/lib #brew
/opt/lib
/usr/local/lib
/usr/lib
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_LIBRARY(READLINE_readline_LIBRARY NAMES readline)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(READLINE DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARIES)
# Sometimes readline really needs ncurses
IF(APPLE)
FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses PATHS
/sw/lib
/opt/local/lib
/opt/lib
/usr/local/lib
/usr/lib
NO_DEFAULT_PATH
)
ENDIF(APPLE)
FIND_LIBRARY(READLINE_ncurses_LIBRARY NAMES ncurses)
mark_as_advanced(READLINE_INCLUDE_DIR READLINE_LIBRARIES)
MARK_AS_ADVANCED(
READLINE_INCLUDE_DIR
READLINE_readline_LIBRARY
READLINE_ncurses_LIBRARY
)
SET( READLINE_FOUND "NO" )
IF(READLINE_INCLUDE_DIR)
IF(READLINE_readline_LIBRARY)
SET( READLINE_FOUND "YES" )
SET( READLINE_LIBRARIES
${READLINE_readline_LIBRARY}
)
# some readline libraries depend on ncurses
IF(READLINE_ncurses_LIBRARY)
SET(READLINE_LIBRARIES ${READLINE_LIBRARIES} ${READLINE_ncurses_LIBRARY})
ENDIF(READLINE_ncurses_LIBRARY)
ENDIF(READLINE_readline_LIBRARY)
ENDIF(READLINE_INCLUDE_DIR)
IF(READLINE_FOUND)
MESSAGE(STATUS "Found readline library")
ELSE(READLINE_FOUND)
IF(READLINE_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find readline -- please give some paths to CMake")
ENDIF(READLINE_FIND_REQUIRED)
ENDIF(READLINE_FOUND)

View File

@@ -0,0 +1,22 @@
#include <ctype.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i))
exit(1);
exit (0);
}

16
cmake/TestSignalType.c Normal file
View File

@@ -0,0 +1,16 @@
#include <sys/types.h>
#include <signal.h>
#ifdef signal
# undef signal
#endif
#ifdef __cplusplus
extern "C" void (*signal (int, void (*)(int)))(int);
#else
void (*signal ()) ();
#endif
int
main ()
{
return 0;
}