forked from vstakhov/libucl
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple cmake build infrastructure.
- Loading branch information
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
PROJECT(libucl C) | ||
|
||
SET(LIBUCL_VERSION_MAJOR 0) | ||
SET(LIBUCL_VERSION_MINOR 2) | ||
SET(LIBUCL_VERSION_PATCH 8) | ||
|
||
SET(LIBUCL_VERSION "${LIBUCL_VERSION_MAJOR}.${LIBUCL_VERSION_MINOR}.${LIBUCL_VERSION_PATCH}") | ||
|
||
INCLUDE(CheckCCompilerFlag) | ||
INCLUDE(FindOpenSSL) | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) | ||
|
||
OPTION(ENABLE_URL_INCLUDE "Enable urls in ucl includes (requires libcurl or libfetch) [default: OFF]" OFF) | ||
|
||
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) | ||
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
|
||
IF(ENABLE_URL_INCLUDE MATCHES "ON") | ||
FIND_LIBRARY(LIBFETCH_LIBRARY NAMES fetch PATHS PATH_SUFFIXES lib64 lib | ||
PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local | ||
/usr | ||
/sw | ||
/opt/local | ||
/opt/csw | ||
/opt | ||
DOC "Path where the libfetch library can be found") | ||
IF(LIBFETCH_LIBRARY) | ||
FIND_FILE(HAVE_FETCH_H NAMES fetch.h PATHS /usr/include | ||
/opt/include | ||
/usr/local/include | ||
DOC "Path to libfetch header") | ||
ELSE(LIBFETCH_LIBRARY) | ||
# Try to find libcurl | ||
ProcessPackage(CURL libcurl) | ||
IF(NOT CURL_FOUND) | ||
MESSAGE(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration") | ||
ENDIF(NOT CURL_FOUND) | ||
ENDIF(LIBFETCH_LIBRARY) | ||
ENDIF(ENABLE_URL_INCLUDE MATCHES "ON") | ||
|
||
SET(CMAKE_C_WARN_FLAGS "") | ||
CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) | ||
CHECK_C_COMPILER_FLAG(-W SUPPORT_W) | ||
CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) | ||
CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) | ||
CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES) | ||
IF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) | ||
CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) | ||
ENDIF(NOT "${CMAKE_C_COMPILER_ID}" MATCHES SunPro) | ||
IF(SUPPORT_W) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") | ||
ENDIF(SUPPORT_W) | ||
IF(SUPPORT_WALL) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") | ||
ENDIF(SUPPORT_WALL) | ||
IF(SUPPORT_WPARAM) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") | ||
ENDIF(SUPPORT_WPARAM) | ||
IF(SUPPORT_WPOINTER_SIGN) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") | ||
ENDIF(SUPPORT_WPOINTER_SIGN) | ||
IF(SUPPORT_WSTRICT_PROTOTYPES) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wstrict-prototypes") | ||
ENDIF(SUPPORT_WSTRICT_PROTOTYPES) | ||
IF(SUPPORT_STD_FLAG) | ||
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") | ||
ENDIF(SUPPORT_STD_FLAG) | ||
|
||
IF(OPENSSL_FOUND) | ||
SET(HAVE_OPENSSL 1) | ||
INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}") | ||
ENDIF(OPENSSL_FOUND) | ||
|
||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../src") | ||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../include") | ||
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../uthash") | ||
|
||
SET(UCLSRC ../src/ucl_util.c | ||
../src/ucl_parser.c | ||
../src/ucl_emitter.c | ||
../src/ucl_hash.c | ||
../src/xxhash.c) | ||
|
||
ADD_LIBRARY(ucl STATIC ${UCLSRC}) | ||
SET_TARGET_PROPERTIES(ucl PROPERTIES VERSION ${LIBUCL_VERSION}) | ||
|
||
IF(HAVE_FETCH_H) | ||
TARGET_LINK_LIBRARIES(ucl fetch) | ||
ELSE(HAVE_FETCH_H) | ||
IF(CURL_FOUND) | ||
TARGET_LINK_LIBRARIES(ucl ${CURL_LIBRARIES}) | ||
ENDIF(CURL_FOUND) | ||
ENDIF(HAVE_FETCH_H) | ||
IF(OPENSSL_FOUND) | ||
TARGET_LINK_LIBRARIES(ucl ${OPENSSL_LIBRARIES}) | ||
ENDIF(OPENSSL_FOUND) |