CMakeLists.txt revision 268896
1268896SbaptPROJECT(libucl C) 2268896Sbapt 3268896SbaptSET(LIBUCL_VERSION_MAJOR 0) 4268896SbaptSET(LIBUCL_VERSION_MINOR 2) 5268896SbaptSET(LIBUCL_VERSION_PATCH 9) 6268896Sbapt 7268896SbaptSET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") 8268896Sbapt 9268896SbaptINCLUDE(CheckCCompilerFlag) 10268896SbaptINCLUDE(FindOpenSSL) 11268896SbaptCMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) 12268896Sbapt 13268896SbaptOPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) 14268896SbaptOPTION(ENABLE_URL_SIGN "Enable signatures check in ucl includes (requires openssl) [default: OFF]" OFF) 15268896SbaptOPTION(BUILD_SHARED_LIBS "Build Shared Libraries [default: OFF]" OFF) 16268896Sbapt 17268896SbaptIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") 18268896Sbapt LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) 19268896SbaptENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") 20268896Sbapt 21268896SbaptIF(ENABLE_URL_INCLUDE MATCHES "ON") 22268896Sbapt FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib 23268896Sbapt PATHS 24268896Sbapt ~/Library/Frameworks 25268896Sbapt /Library/Frameworks 26268896Sbapt /usr/local 27268896Sbapt /usr 28268896Sbapt /sw 29268896Sbapt /opt/local 30268896Sbapt /opt/csw 31268896Sbapt /opt 32268896Sbapt DOC "Path where the libfetch library can be found") 33268896Sbapt IF(LIBFETCH_LIBRARY) 34268896Sbapt FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include 35268896Sbapt /opt/include 36268896Sbapt /usr/local/include 37268896Sbapt DOC "Path to libfetch header") 38268896Sbapt ELSE(LIBFETCH_LIBRARY) 39268896Sbapt # Try to find libcurl 40268896Sbapt ProcessPackage(CURL libcurl) 41268896Sbapt IF(NOT CURL_FOUND) 42268896Sbapt MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") 43268896Sbapt ENDIF(NOT CURL_FOUND) 44268896Sbapt ENDIF(LIBFETCH_LIBRARY) 45268896SbaptENDIF(ENABLE_URL_INCLUDE MATCHES "ON") 46268896Sbapt 47268896SbaptSET(CMAKE_C_WARN_FLAGS "") 48268896SbaptCHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) 49268896SbaptCHECK_C_COMPILER_FLAG(-W SUPPORT_W) 50268896SbaptCHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) 51268896SbaptCHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) 52268896SbaptCHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES) 53268896SbaptIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) 54268896Sbapt CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) 55268896SbaptENDIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) 56268896SbaptIF(SUPPORT_W) 57268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") 58268896SbaptENDIF(SUPPORT_W) 59268896SbaptIF(SUPPORT_WALL) 60268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") 61268896SbaptENDIF(SUPPORT_WALL) 62268896SbaptIF(SUPPORT_WPARAM) 63268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") 64268896SbaptENDIF(SUPPORT_WPARAM) 65268896SbaptIF(SUPPORT_WPOINTER_SIGN) 66268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") 67268896SbaptENDIF(SUPPORT_WPOINTER_SIGN) 68268896SbaptIF(SUPPORT_WSTRICT_PROTOTYPES) 69268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes") 70268896SbaptENDIF(SUPPORT_WSTRICT_PROTOTYPES) 71268896SbaptIF(SUPPORT_STD_FLAG) 72268896Sbapt SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") 73268896SbaptENDIF(SUPPORT_STD_FLAG) 74268896Sbapt 75268896SbaptIF(ENABLE_URL_SIGN MATCHES "ON") 76268896Sbapt IF(OPENSSL_FOUND) 77268896Sbapt SET(HAVE_OPENSSL 1) 78268896Sbapt INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}") 79268896Sbapt ENDIF(OPENSSL_FOUND) 80268896SbaptENDIF(ENABLE_URL_SIGN MATCHES "ON") 81268896Sbapt 82268896SbaptINCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../src") 83268896SbaptINCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../include") 84268896SbaptINCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../uthash") 85268896Sbapt 86268896SbaptSET(UCLSRC ../src/ucl_util.c 87268896Sbapt ../src/ucl_parser.c 88268896Sbapt ../src/ucl_emitter.c 89268896Sbapt ../src/ucl_hash.c 90268896Sbapt ../src/ucl_schema.c 91268896Sbapt ../src/xxhash.c) 92268896Sbapt 93268896Sbapt 94268896SbaptSET (LIB_TYPE STATIC) 95268896SbaptIF (BUILD_SHARED_LIBS) 96268896Sbapt SET (LIB_TYPE SHARED) 97268896SbaptENDIF (BUILD_SHARED_LIBS) 98268896SbaptADD_LIBRARY(ucl ${LIB_TYPE} ${UCLSRC}) 99268896SbaptSET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION} SOVERSION ${LIBUCL_VERSION_MAJOR}) 100268896Sbapt 101268896SbaptIF(HAVE_FETCH_H) 102268896Sbapt TARGET_LINK_LIBRARIES(ucl fetch) 103268896SbaptELSE(HAVE_FETCH_H) 104268896Sbapt IF(CURL_FOUND) 105268896Sbapt TARGET_LINK_LIBRARIES(ucl ${CURL_LIBRARIES}) 106268896Sbapt ENDIF(CURL_FOUND) 107268896SbaptENDIF(HAVE_FETCH_H) 108268896SbaptIF(ENABLE_URL_SIGN MATCHES "ON") 109268896Sbapt IF(OPENSSL_FOUND) 110268896Sbapt TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES}) 111268896Sbapt ENDIF(OPENSSL_FOUND) 112268896SbaptENDIF(ENABLE_URL_SIGN MATCHES "ON") 113