view extern/libircclient/CMakeLists.txt @ 513:928a40398dec

CMake: split options and conditions, closes #716 As described in the issue, the CMake process force off a cache variable when a condition is not met. If the user installs the requirements and re-run CMake it must also set the variable to on which is inconvenient. The new process is to add a secondary variable and do not touch user defined options.
author David Demelier <markand@malikania.fr>
date Mon, 23 Oct 2017 21:30:17 +0200
parents 6ec510722582
children
line wrap: on
line source

#
# CMakeLists.txt -- CMake build system for irccd
#
# Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

# Libircclient bundled
project(extern-libircclient)

set(FLAGS "ENABLE_THREADS")

# Portability checks
include(CheckFunctionExists)

check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
check_function_exists(localtime_r HAVE_LOCALTIME_R)

if (HAVE_GETHOSTBYNAME_R)
    list(APPEND FLAGS "HAVE_GETHOSTBYNAME_R")
endif ()
if (HAVE_LOCALTIME_R)
    list(APPEND FLAGS "HAVE_LOCALTIME_R")
endif ()

# SSL is optional
if (HAVE_SSL)
    list(APPEND INCLUDES ${OPENSSL_INCLUDE_DIR})
    list(APPEND LIBRARIES ${OPENSSL_LIBRARIES})
    list(APPEND FLAGS "ENABLE_SSL")
endif ()

# Enable or disable IPv6
if (WITH_IPV6)
    list(APPEND FLAGS "ENABLE_IPV6")
endif ()

if (WIN32)
    list(APPEND LIBRARIES ws2_32)
endif ()

irccd_define_library(
    LOCAL EXTERNAL
    TARGET extern-ircclient
    SOURCES src/libircclient.c
    FLAGS ${FLAGS}
    LIBRARIES ${LIBRARIES}
    PUBLIC_INCLUDES "${extern-libircclient_SOURCE_DIR}/include"
    LOCAL_INCLUDES ${INCLUDES}
)

set_target_properties(
    extern-ircclient
    PROPERTIES
        PROJECT_LABEL libircclient
        FOLDER extern
)