From 75f1e6f6b12f9fe461e4afa5bf3c998d21d48394 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Sat, 11 Apr 2009 00:31:48 +0200 Subject: Rewritten CMake rules to build common/ as static library This static library is later on linked in. This is to avoid recompiling the same source files several times during a complete eurephia compilation. --- .gitignore | 1 + CMakeLists.txt | 5 ++++- common/CMakeLists.txt | 19 +++++++++++++++++++ database/sqlite/CMakeLists.txt | 16 +++++----------- eurephiadm/CMakeLists.txt | 12 +----------- plugin/CMakeLists.txt | 16 ++++------------ plugin/firewall/iptables/CMakeLists.txt | 3 +-- utils/CMakeLists.txt | 10 +--------- 8 files changed, 36 insertions(+), 46 deletions(-) create mode 100644 common/CMakeLists.txt diff --git a/.gitignore b/.gitignore index c0db8f6..48d811f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.so +*.a */tmp/ *.log *.conf diff --git a/CMakeLists.txt b/CMakeLists.txt index a281c9d..07b5cb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,4 +109,7 @@ ENDIF(NOT HAVE_PTHREAD_MUTEX_LOCK OR NOT HAVE_PTHREAD_MUTEX_UNLOCK) ADD_DEFINITIONS(-g -Wall) -SUBDIRS(${subdirs}) +ADD_LIBRARY(common STATIC IMPORTED) +SET_PROPERTY(TARGET common PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/common/libeurephiacommon.a) + +SUBDIRS(common ${subdirs}) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 0000000..e08e3e6 --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,19 @@ +PROJECT(eurephiaCOMMON C) +cmake_minimum_required(VERSION 2.6) + +INCLUDE_DIRECTORIES(. ../database) + +ADD_LIBRARY( eurephiacommon STATIC + certinfo.c + eurephia_getsym.c + eurephia_log.c + eurephia_values.c + eurephia_xml.c + passwd.c + randstr.c + sha512.c + ../database/eurephiadb.c + ../database/eurephiadb_mapping.c +) +SET_TARGET_PROPERTIES( eurephiacommon PROPERTIES COMPILE_FLAGS -fPIC) + diff --git a/database/sqlite/CMakeLists.txt b/database/sqlite/CMakeLists.txt index 03dab63..8ca860f 100644 --- a/database/sqlite/CMakeLists.txt +++ b/database/sqlite/CMakeLists.txt @@ -5,17 +5,9 @@ SET(SQLITE3PREFIX "/etc/openvpn" CACHE STRING "Install prefix for the eurephia S SET(edb_sqlite_SRC sqlite.c edb-sqlite.c -) -SET(COMMON - ../../common/eurephia_log.c ../../common/eurephiadb_session_common.c - ../../common/eurephia_values.c - ../../common/passwd.c - ../../common/sha512.c - ../../common/randstr.c ) - INCLUDE(CheckIncludeFile) INCLUDE(CheckLibraryExists) @@ -35,8 +27,6 @@ ENDIF(NOT SQLITE3BIN) IF(ADMIN_ENABLED) SET(edb_sqlite_SRC ${edb_sqlite_SRC} - ../../common/eurephia_xml.c - ../eurephiadb_mapping.c administration.c firewalladmin.c attempts.c @@ -44,7 +34,11 @@ IF(ADMIN_ENABLED) ENDIF(ADMIN_ENABLED) INCLUDE_DIRECTORIES(BEFORE ../../common/ ../../plugin/ ../../plugin/firewall ../) -ADD_LIBRARY(edb-sqlite SHARED ${edb_sqlite_SRC} ${COMMON}) + +ADD_LIBRARY(edb-sqlite SHARED ${edb_sqlite_SRC}) +TARGET_LINK_LIBRARIES(edb-sqlite common) +SET_TARGET_PROPERTIES( edb-sqlite PROPERTIES COMPILE_FLAGS -fPIC) + IF(SQLITE3BIN) ADD_CUSTOM_COMMAND(TARGET edb-sqlite POST_BUILD diff --git a/eurephiadm/CMakeLists.txt b/eurephiadm/CMakeLists.txt index c6c7458..4196bb9 100644 --- a/eurephiadm/CMakeLists.txt +++ b/eurephiadm/CMakeLists.txt @@ -17,21 +17,11 @@ SET(efw_ipt_SRC commands/adminaccess.c commands/edit_config.c commands/fwprofiles.c - ../common/eurephia_log.c - ../common/eurephia_getsym.c - ../common/eurephia_values.c ../common/eurephiadb_session_common.c - ../common/eurephia_xml.c - ../common/passwd.c - ../common/sha512.c - ../common/randstr.c - ../common/certinfo.c - ../database/eurephiadb.c ) IF(FIREWALL) ADD_DEFINITIONS(-DFIREWALL) - ENDIF(FIREWALL) @@ -40,7 +30,7 @@ ADD_DEFINITIONS(-DEUREPHIADM_XSLT_PATH="${EUREPHIADM_XSLT_PATH}") INCLUDE_DIRECTORIES(../common ../database) ADD_EXECUTABLE(eurephiadm ${efw_ipt_SRC}) -TARGET_LINK_LIBRARIES(eurephiadm dl crypto ${EXTRA_LIBS}) +TARGET_LINK_LIBRARIES(eurephiadm dl crypto common ${EXTRA_LIBS}) INSTALL(TARGETS eurephiadm RUNTIME DESTINATION ${BINDIR}) SUBDIRS(../xslt/eurephiadm) diff --git a/plugin/CMakeLists.txt b/plugin/CMakeLists.txt index 2ac083e..21ab780 100644 --- a/plugin/CMakeLists.txt +++ b/plugin/CMakeLists.txt @@ -1,20 +1,12 @@ PROJECT(eurephia-plugin C) cmake_minimum_required(VERSION 2.6) SET(eurephia_auth_SRC - ../common/certinfo.c eurephia-auth.c eurephia.c - ../database/eurephiadb.c eurephiadb_session.c - firewall/eurephiafw.c - firewall/eurephiafw_helpers.c - ../common/eurephia_getsym.c - ../common/eurephia_log.c - ../common/eurephia_values.c + firewall/eurephiafw.c + firewall/eurephiafw_helpers.c ../common/eurephiadb_session_common.c - ../common/passwd.c - ../common/sha512.c - ../common/randstr.c ) SET(subdirs "") IF(FW_IPTABLES) @@ -44,11 +36,11 @@ ENDIF(NOT HAVE_RT_MQ_OPEN OR NOT HAVE_RT_MQ_CLOSE OR NOT HAVE_RT_MQ_UNLINK OR NO INCLUDE_DIRECTORIES(../common ../database ./firewall .) ADD_LIBRARY(eurephia-auth MODULE ${eurephia_auth_SRC}) -TARGET_LINK_LIBRARIES(eurephia-auth dl pthread rt crypto) +TARGET_LINK_LIBRARIES(eurephia-auth dl pthread rt crypto common) SET_TARGET_PROPERTIES(eurephia-auth PROPERTIES OUTPUT_NAME eurephia-auth PREFIX "") INSTALL(TARGETS eurephia-auth LIBRARY DESTINATION ${PLUGINDIR}) IF(subdirs) - SUBDIRS(${subdirs}) + ADD_SUBDIRECTORY(${subdirs}) ENDIF(subdirs) diff --git a/plugin/firewall/iptables/CMakeLists.txt b/plugin/firewall/iptables/CMakeLists.txt index 69173d7..789a237 100644 --- a/plugin/firewall/iptables/CMakeLists.txt +++ b/plugin/firewall/iptables/CMakeLists.txt @@ -3,11 +3,10 @@ cmake_minimum_required(VERSION 2.6) SET(efw_ipt_SRC efw-iptables.c ../eurephiafw_helpers.c - ../../../common/eurephia_log.c ) INCLUDE_DIRECTORIES(BEFORE ../..) ADD_LIBRARY(efw-iptables MODULE ${efw_ipt_SRC}) -TARGET_LINK_LIBRARIES(efw-iptables pthread rt gcc_s) +TARGET_LINK_LIBRARIES(efw-iptables pthread rt gcc_s common) SET_TARGET_PROPERTIES(efw-iptables PROPERTIES PREFIX "") INSTALL(TARGETS efw-iptables LIBRARY DESTINATION ${PLUGINDIR}) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 949c376..9301678 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -5,14 +5,6 @@ IF(EUREPHIADM) SET(e_init_SRC eurephia_init.c benchmark.c - ../common/eurephia_values.c - ../common/eurephia_log.c - ../common/eurephia_getsym.c - ../common/eurephia_xml.c - ../common/passwd.c - ../common/sha512.c - ../common/randstr.c - ../database/eurephiadb.c ../eurephiadm/get_console_input.c ../eurephiadm/argparser.c ../eurephiadm/client_context.c @@ -25,7 +17,7 @@ IF(EUREPHIADM) INCLUDE_DIRECTORIES(../common ../database ../eurephiadm) ADD_EXECUTABLE(eurephia_init ${e_init_SRC}) - TARGET_LINK_LIBRARIES(eurephia_init dl crypto ${EXTRA_LIBS}) + TARGET_LINK_LIBRARIES(eurephia_init dl crypto common ${EXTRA_LIBS}) SET(saltdecode_SRC saltdecode.c -- cgit