summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-09-02 14:23:12 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-09-02 14:23:12 +0200
commit6e69591846410cef6b278f454e95ae13690f0bae (patch)
tree428735f341e5e1a533212ea067ed6aa48d3b3513 /CMakeLists.txt
parent8461cb6c3df7dc9390b877dff416d979630359c2 (diff)
downloadeurephia-6e69591846410cef6b278f454e95ae13690f0bae.tar.gz
eurephia-6e69591846410cef6b278f454e95ae13690f0bae.tar.xz
eurephia-6e69591846410cef6b278f454e95ae13690f0bae.zip
Cleaned up main CMakeLists.txt file
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt137
1 files changed, 87 insertions, 50 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 761fae2..d56b616 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,76 +1,67 @@
PROJECT(eurephia C)
cmake_minimum_required(VERSION 2.6)
+# Set the eurephia version
ADD_DEFINITIONS(-DEUREPHIAVERSION="0.9.4_beta")
+# eurephia parameters - boolean values
OPTION(DEBUG "Add more verbose debug information" OFF)
OPTION(SHOW_SECRETS "Show passwords as clear text in logs." OFF)
OPTION(SQLITE3 "Build database driver for SQLite3" OFF)
OPTION(EUREPHIADM "Build command line based admin utility" OFF)
OPTION(PLUGIN "Build the eurephia plugin for OpenVPN" OFF)
+# eurephia parameters - string values
SET(OPENVPN_SRC "" CACHE STRING "Path to OpenVPN source code")
SET(PREFIX "/usr/local" CACHE STRING "Install prefix for eurephia")
SET(BINDIR "/usr/local/bin" CACHE STRING "Directory for eurephia binaries")
SET(PLUGINDIR "/usr/local/lib/eurephia" CACHE STRING "Plug-in path for the eurephia modules")
SET(XSLTROOT "/usr/local/share/eurephia/xslt" CACHE STRING "Root path for the XSLT templates")
+# Set install prefix
SET(CMAKE_INSTALL_PREFIX ${PREFIX})
-SET(CMAKE_C_FLAGS "-fno-delete-null-pointer-checks")
+# Default C compiler flags
+SET(CMAKE_C_FLAGS "-fno-delete-null-pointer-checks -g -Wall")
+
+# Needed cmake modules
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckLibraryExists)
+FIND_PACKAGE(PkgConfig)
+
+#
+# Add support for extra eurephia modules
+#
+
+# Database drivers
IF(SQLITE3)
message(STATUS "Will build database interface for SQLite")
- SET(subdirs ${subdirs} database/sqlite)
SET(DATABASE ON)
+ # Add the sqlite3 database driver to the build queue
+ SET(subdirs ${subdirs} database/sqlite)
ENDIF(SQLITE3)
+# Make sure we build at least one database driver
+IF(NOT DATABASE)
+ message(FATAL_ERROR "Cannot build eurephia without any database drivers.")
+ENDIF(NOT DATABASE)
+
+
+# eurephiadm - console based admin utility
IF(EUREPHIADM)
message(STATUS "Will build command line based admin utility")
- SET(subdirs ${subdirs} eurephiadm)
SET(ADMIN_ENABLED on)
ADD_DEFINITIONS(-DENABLE_EUREPHIADM)
+ # Add the eurephiadm utility to the build queue
+ SET(subdirs ${subdirs} eurephiadm)
ENDIF(EUREPHIADM)
-IF(ADMIN_ENABLED)
- # Find required packages for eurephiadm - libxml2 and libxslt
- find_package(PkgConfig)
- pkg_search_module(LIBXML2 REQUIRED libxml-2.0 libxml2 libxml>=2.6)
- INCLUDE_DIRECTORIES(BEFORE ${LIBXML2_INCLUDE_DIRS})
- ADD_DEFINITIONS(-DHAVE_LIBXML2)
- SET(EXTRA_LIBS ${EXTRA_LIBS} ${LIBXML2_LIBRARIES})
-
- pkg_search_module(LIBXSLT REQUIRED libxslt)
- INCLUDE_DIRECTORIES(BEFORE ${LIBXSLT_INCLUDE_DIRS})
- ADD_DEFINITIONS(-DHAVE_LIBXSLT)
- SET(EXTRA_LIBS ${EXTRA_LIBS} ${LIBXSLT_LIBRARIES})
-
- # Find optional package for eurephiadm - OpenSSL.
- # Used for parsing certificate files.
- pkg_search_module(OPENSSL OPTIONAL openssl>=0.9.8)
- IF(OPENSSL_FOUND)
- ADD_DEFINITIONS(-DHAVE_OPENSSL)
- SET(EXTRA_LIBS ${EXTRA_LIBS} ${OPENSSL_LIBRARIES})
- ENDIF(OPENSSL_FOUND)
-ENDIF(ADMIN_ENABLED)
-
-IF(NOT DATABASE)
- message(FATAL_ERROR "Cannot build eurephia without any database drivers.")
-ENDIF(NOT DATABASE)
-
+# Enable firewall features if iptables is enabled
IF(FW_IPTABLES)
SET(FIREWALL on)
ENDIF(FW_IPTABLES)
-
-IF(DEBUG)
- message(STATUS "DEBUG enabled - might be a security issue")
- ADD_DEFINITIONS(-DENABLE_DEBUG)
- IF(SHOW_SECRETS)
- message(STATUS "SHOW_SECRETS ENABLED -- THIS WILL LOG PASSWORDS IN CLEAR TEXT")
- ADD_DEFINITIONS(-DSHOW_SECRETS)
- ENDIF(SHOW_SECRETS)
-ENDIF(DEBUG)
-
+# Extra checks when the openvpn plug-in is enabled
IF(PLUGIN)
IF(NOT OPENVPN_SRC)
message(FATAL_ERROR "Missing path to OpenVPN source - try running ./configure again")
@@ -81,26 +72,25 @@ IF(PLUGIN)
IF(NOT EXISTS ${CHECK_INCL_FILE})
message(FATAL_ERROR "Missing openvpn-plugin.h ... Is the OpenVPN source code really located here? ${OPENVPN_SRC}")
ENDIF(NOT EXISTS ${CHECK_INCL_FILE})
+
INCLUDE_DIRECTORIES(BEFORE ${OPENVPN_SRC} .)
- SET(subdirs ${subdirs} plugin utils)
+ # Add the openvpn plug-in to the build queue
+ SET(subdirs ${subdirs} plugin)
ENDIF(PLUGIN)
-INCLUDE(CheckIncludeFile)
+#
+# Check for some standard glibc functions which we need
+#
+
+# Check that we have dynamic loader available
CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
-INCLUDE(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DLOPEN)
CHECK_LIBRARY_EXISTS(dl dlclose "" HAVE_DLCLOSE)
IF(NOT HAVE_DLOPEN OR NOT HAVE_DLCLOSE)
message(FATAL_ERROR "Missing proper dl library")
ENDIF(NOT HAVE_DLOPEN OR NOT HAVE_DLCLOSE)
-CHECK_INCLUDE_FILE(openssl/rand.h HAVE_OPENSSL_RAND_H)
-CHECK_LIBRARY_EXISTS(crypto RAND_load_file "" HAVE_OPENSSL_RAND_LOAD_FILE)
-CHECK_LIBRARY_EXISTS(crypto RAND_pseudo_bytes "" HAVE_OPENSSL_RAND_PSEUDO_BYTES)
-IF(NOT HAVE_OPENSSL_RAND_H OR NOT HAVE_OPENSSL_RAND_LOAD_FILE OR NOT HAVE_OPENSSL_RAND_PSEUDO_BYTES)
- message(FATAL_ERROR "Missing OpenSSL crypto support")
-ENDIF(NOT HAVE_OPENSSL_RAND_H OR NOT HAVE_OPENSSL_RAND_LOAD_FILE OR NOT HAVE_OPENSSL_RAND_PSEUDO_BYTES)
-
+# Check that we have some pthread functions
CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
CHECK_LIBRARY_EXISTS(pthread pthread_mutex_lock "" HAVE_PTHREAD_MUTEX_LOCK)
CHECK_LIBRARY_EXISTS(pthread pthread_mutex_unlock "" HAVE_PTHREAD_MUTEX_UNLOCK)
@@ -108,9 +98,56 @@ IF(NOT HAVE_PTHREAD_MUTEX_LOCK OR NOT HAVE_PTHREAD_MUTEX_UNLOCK)
message(FATAL_ERROR "Missing proper pthread_mutex support")
ENDIF(NOT HAVE_PTHREAD_MUTEX_LOCK OR NOT HAVE_PTHREAD_MUTEX_UNLOCK)
-ADD_DEFINITIONS(-g -Wall)
+#
+# Check for other needed modules
+#
+
+# Check for openssl ... needed for gathering safe random data
+pkg_search_module(OPENSSL REQUIRED openssl)
+CHECK_LIBRARY_EXISTS(crypto RAND_load_file "" HAVE_OPENSSL_RAND_LOAD_FILE)
+CHECK_LIBRARY_EXISTS(crypto RAND_pseudo_bytes "" HAVE_OPENSSL_RAND_PSEUDO_BYTES)
+IF(NOT HAVE_OPENSSL_RAND_LOAD_FILE OR NOT HAVE_OPENSSL_RAND_PSEUDO_BYTES)
+ message(FATAL_ERROR "Missing OpenSSL crypto support")
+ENDIF(NOT HAVE_OPENSSL_RAND_LOAD_FILE OR NOT HAVE_OPENSSL_RAND_PSEUDO_BYTES)
+
+
+# Generic checks when administration utilities are enabled
+IF(ADMIN_ENABLED)
+ # Check for libxml2
+ pkg_search_module(LIBXML2 REQUIRED libxml-2.0 libxml2 libxml>=2.6)
+ INCLUDE_DIRECTORIES(BEFORE ${LIBXML2_INCLUDE_DIRS})
+ ADD_DEFINITIONS(-DHAVE_LIBXML2)
+ SET(EXTRA_LIBS ${EXTRA_LIBS} ${LIBXML2_LIBRARIES})
+ # Check for libxslt
+ pkg_search_module(LIBXSLT REQUIRED libxslt)
+ INCLUDE_DIRECTORIES(BEFORE ${LIBXSLT_INCLUDE_DIRS})
+ ADD_DEFINITIONS(-DHAVE_LIBXSLT)
+ SET(EXTRA_LIBS ${EXTRA_LIBS} ${LIBXSLT_LIBRARIES})
+
+ # Find optional package for eurephiadm - OpenSSL.
+ # Used for parsing certificate files, and we need a fairly
+ # new openssl version.
+ pkg_search_module(OPENSSL OPTIONAL openssl>=0.9.8)
+ IF(OPENSSL_FOUND)
+ ADD_DEFINITIONS(-DHAVE_OPENSSL)
+ SET(EXTRA_LIBS ${EXTRA_LIBS} ${OPENSSL_LIBRARIES})
+ ENDIF(OPENSSL_FOUND)
+ENDIF(ADMIN_ENABLED)
+
+# Export our internal common library
ADD_LIBRARY(common STATIC IMPORTED)
SET_PROPERTY(TARGET common PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/common/libeurephiacommon.a)
+# Start the building. First build the common library, and then the requested eurephia modules
SUBDIRS(common ${subdirs})
+
+# Give warning if DEBUG is enabled
+IF(DEBUG)
+ message(STATUS "***** DEBUG enabled ***** might be a security issue")
+ ADD_DEFINITIONS(-DENABLE_DEBUG)
+ IF(SHOW_SECRETS)
+ message(STATUS "SHOW_SECRETS ENABLED -- THIS WILL LOG PASSWORDS IN CLEAR TEXT")
+ ADD_DEFINITIONS(-DSHOW_SECRETS)
+ ENDIF(SHOW_SECRETS)
+ENDIF(DEBUG)