project(gophrier) cmake_minimum_required(VERSION 2.8) #macros macro(GOPHRIER_BOOL_OPTION OPT DEFAULT) set(${OPT} ${DEFAULT} CACHE BOOL "") if(${OPT}) add_definitions(-D${OPT}=1) else() add_definitions(-D${OPT}=0) endif() endmacro() macro(GOPHRIER_INT_OPTION OPT DEFAULT) set(${OPT} ${DEFAULT} CACHE STRING "") add_definitions(-D${OPT}=${DEFAULT}) endmacro() macro(GOPHRIER_STRING_OPTION OPT DEFAULT) set(${OPT} ${DEFAULT} CACHE STRING "") add_definitions(-D${OPT}="${DEFAULT}") endmacro() macro(GOPHRIER_PATH_OPTION OPT DEFAULT) set(${OPT} ${DEFAULT} CACHE PATH "") add_definitions(-D${OPT}="${DEFAULT}") endmacro() set(GOPHRIER_VERSION_MAJOR 0) set(GOPHRIER_VERSION_MINOR 2) set(GOPHRIER_VERSION_PATCH 3) set(GOPHRIER_VERSION "${GOPHRIER_VERSION_MAJOR}.${GOPHRIER_VERSION_MINOR}.${GOPHRIER_VERSION_PATCH}") add_definitions(-DGOPHRIER_VERSION="${GOPHRIER_VERSION}") # options gophrier_path_option(GOPHRIER_CONF_DIR "/etc/gophrier") gophrier_path_option(GOPHRIER_DEFAULT_ROOT_DIR "/var/gopher") gophrier_path_option(GOPHRIER_DEFAULT_LOG_DIR "/var/log/gophrier") gophrier_path_option(GOPHRIER_PID_PATH "/var/run/gophrier.pid") gophrier_bool_option(GOPHRIER_DEFAULT_DAEMON ON) gophrier_bool_option(GOPHRIER_DEFAULT_IPV6 OFF) gophrier_bool_option(GOPHRIER_DEFAULT_BROWSABLE ON) gophrier_bool_option(GOPHRIER_DEFAULT_SYMLINKS ON) gophrier_bool_option(GOPHRIER_DEFAULT_SHOW_HIDDEN OFF) gophrier_int_option(GOPHRIER_DEFAULT_PORT "70") gophrier_string_option(GOPHRIER_DEFAULT_TYPE_HELPER "ext") gophrier_bool_option(GOPHRIER_DEFAULT_GM_ENABLE ON) gophrier_string_option(GOPHRIER_DEFAULT_GM_NAME "gophermap") gophrier_bool_option(GOPHRIER_MOD_ENABLED OFF) gophrier_path_option(GOPHRIER_MOD_DIR "${CMAKE_INSTALL_PREFIX}/lib/gophrier") # compilation add_definitions(-Wall -Wextra -g -D_GNU_SOURCE) set(gophrier_SOURCES cli.c client.c conf.c dbstring.c dir.c error.c exe.c file.c list.c log.c main.c map.c path.c pool.c prerequest.c request.c server.c sock.c type.c ) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(gophrier_SOURCES ${gophrier_SOURCES} linux/hand.c) else() set(gophrier_SOURCES ${gophrier_SOURCES} hand.c) endif() include(CheckFunctionExists) check_function_exists(get_current_dir_name IS_GNU_LIBC) if (NOT IS_GNU_LIBC) set(gophrier_SOURCES ${gophrier_SOURCES} posix/compat.c) add_definitions(-DGOPHRIER_POSIX=1) endif() if (GOPHRIER_MOD_ENABLED) check_function_exists(dlopen HAVE_DLOPEN) if (NOT HAVE_DLOPEN) find_library(LIBDL dl) if (LIBDL) set(gophrier_LIBRARIES ${LIBDL}) endif() endif() set(gophrier_SOURCES ${gophrier_SOURCES} mod.c) add_subdirectory(modules) endif() find_library(HAVE_PTHREAD pthread) set(gophrier_LIBRARIES ${gophrier_LIBRARIES} ${HAVE_PTHREAD}) add_executable(gophrier ${gophrier_SOURCES}) target_link_libraries(gophrier ${gophrier_LIBRARIES}) install(TARGETS gophrier DESTINATION "sbin") install(FILES "doc/gophrier.1" DESTINATION "share/man/man1") set(CPACK_SOURCE_GENERATOR TGZ) set(CPACK_PACKAGE_VERSION_MAJOR ${GOPHRIER_VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${GOPHRIER_VERSION_MINOR}) set(CPACK_PACKAGE_VERSION_PATCH ${GOPHRIER_VERSION_PATCH}) set(CPAKE_PACKAGE_VENDOR "Guillaume Duhamel") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") set(CPACK_SOURCE_IGNORE_FILES "\\\\.hg;/build/;/install/") set(CPACK_SOURCE_PACKAGE_FILE_NAME "gophrier-${GOPHRIER_VERSION}") include(CPack)