Re-worked top-level CMakeLists.txt to allow configuring using ENABLE_* style variables.

This commit is contained in:
Richard H 2012-11-10 17:02:29 +01:00
parent 8bd6de3768
commit ba5f26a7ce

View file

@ -15,6 +15,21 @@ message(STATUS "|- log4cxx : -DLOG4CXX_INCLUDE_DIR, -DLOG4CXX_LIBRARY")
message(STATUS "|- purple : -DPURPLE_INCLUDE_DIR, -DPURPLE_LIBRARY")
message(STATUS " : -DPURPLE_NOT_RUNTIME - enables compilation with libpurple.lib")
option(ENABLE_SQLITE3 "Build with SQLite3 support" ON)
option(ENABLE_MYSQL "Build with MySQL support" ON)
option(ENABLE_PQXX "Build with Postgres supoort" ON)
#option(ENABLE_FROTZ "Build Frotz plugin" ON)
option(ENABLE_IRC "Build IRC plugin" ON)
option(ENABLE_PURPLE "Build Libpurple plugin" ON)
option(ENABLE_SKYPE "Build Skype plugin" ON)
#option(ENABLE_TWITTER "Build Twitter plugin" ON)
#option(ENABLE_YAHOO2 "Build Yahoo plugin" ON)
option(ENABLE_DOCS "Build Docs" ON)
option(ENABLE_LOG "Build with logging using Log4cxx" ON)
option(ENABLE_TESTS "Build Tests using CppUnit" ON)
MACRO(LIST_CONTAINS var value)
SET(${var})
FOREACH (value2 ${ARGN})
@ -30,69 +45,114 @@ endif()
set(CMAKE_MODULE_PATH "cmake_modules")
# FIND CPPUNIT
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(cppunit)
###### Prerequisites ######
if(NOT CPPUNIT_FOUND AND CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
set(CCPUNIT_LIBRARIES ${CPPUNIT_LIBRARY})
set(CPPUNIT_FOUND 1)
message(STATUS "Using cppunit: ${CPPUNIT_INCLUDE_DIR} ${CPPUNIT_LIBRARIES}")
else()
# FIND BOOST
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
else(WIN32)
LIST_CONTAINS(contains -lboost_program_options ${SWIFTEN_LIBRARY})
if(contains)
message(STATUS "Using non-multithreaded boost")
set(Boost_USE_MULTITHREADED 0)
endif(contains)
set(Boost_FIND_QUIETLY ON)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread-mt signals)
if (NOT Boost_FOUND)
set(Boost_FIND_QUIETLY OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
endif()
endif(WIN32)
message( STATUS "Found Boost: ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
# FIND POPT
if (NOT WIN32)
set(popt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(popt REQUIRED)
endif()
###### Database ######
# FIND SQLITE3
if (NOT CMAKE_COMPILER_IS_GNUCXX)
ADD_SUBDIRECTORY(msvc-deps)
else()
if (WIN32)
ADD_SUBDIRECTORY(msvc-deps/sqlite3)
else()
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(sqlite3)
endif()
if (ENABLE_SQLITE3)
if (NOT CMAKE_COMPILER_IS_GNUCXX)
ADD_SUBDIRECTORY(msvc-deps)
else()
if (WIN32)
ADD_SUBDIRECTORY(msvc-deps/sqlite3)
else()
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(sqlite3)
endif()
endif()
endif()
# FIND MYSQL
set(mysql_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(mysql)
if(ENABLE_MYSQL)
set(mysql_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(mysql)
endif()
# FIND PQXX
if(ENABLE_PQXX)
set(pqxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(pqxx)
endif()
###### Plugins ######
# FIND LIBPURPLE
set(purple_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(purple)
if(ENABLE_PURPLE)
set(purple_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(purple)
if (WIN32)
if (PURPLE_NOT_RUNTIME)
if (WIN32)
if (PURPLE_NOT_RUNTIME)
add_definitions(-DPURPLE_RUNTIME=0)
else(PURPLE_NOT_RUNTIME)
add_definitions(-DPURPLE_RUNTIME=1)
endif(PURPLE_NOT_RUNTIME)
else()
add_definitions(-DPURPLE_RUNTIME=0)
else(PURPLE_NOT_RUNTIME)
add_definitions(-DPURPLE_RUNTIME=1)
endif(PURPLE_NOT_RUNTIME)
else()
add_definitions(-DPURPLE_RUNTIME=0)
endif()
# FIND LIBEVENT
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(event)
endif()
# FIND GLIB
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# set(GLIB2_FOUND TRUE)
# else()
set(glib_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(glib)
# endif()
if(ENABLE_SKYPE OR ENABLE_PURPLE)
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# set(GLIB2_FOUND TRUE)
# else()
set(glib_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(glib)
# endif()
endif()
# FIND LIBXML2
# set(libxml2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
# find_package(libxml2)
# FIND POPT
if (NOT WIN32)
set(popt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(popt)
endif()
# FIND PROTOBUF
set(Protobuf_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Protobuf REQUIRED)
# FIND LIBEVENT
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(event)
if (NOT PROTOBUF_FOUND AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
set(PROTOBUF_FOUND 1)
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
if (PROTOBUF_PROTOC_EXECUTABLE)
else()
set(PROTOBUF_PROTOC_EXECUTABLE protoc)
endif()
message(STATUS "Using protobuf: ${PROTOBUF_INCLUDE_DIRS} ${PROTOBUF_LIBRARY}")
endif()
# FIND SWIFTEN
@ -132,78 +192,58 @@ set(openssl_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(openssl)
endif()
# FIND BOOST
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
else(WIN32)
LIST_CONTAINS(contains -lboost_program_options ${SWIFTEN_LIBRARY})
if(contains)
message(STATUS "Using non-multithreaded boost")
set(Boost_USE_MULTITHREADED 0)
endif(contains)
set(Boost_FIND_QUIETLY ON)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread-mt signals)
if (NOT Boost_FOUND)
set(Boost_FIND_QUIETLY OFF)
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals REQUIRED)
endif()
endif(WIN32)
if(ENABLE_IRC)
set(Communi_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Communi)
message( STATUS "Found Boost: ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
set(Protobuf_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Protobuf)
# FIND PROTOBUF
if (NOT PROTOBUF_FOUND AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
set(PROTOBUF_FOUND 1)
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
if (PROTOBUF_PROTOC_EXECUTABLE)
else()
set(PROTOBUF_PROTOC_EXECUTABLE protoc)
endif()
message(STATUS "Using protobuf: ${PROTOBUF_INCLUDE_DIRS} ${PROTOBUF_LIBRARY}")
endif()
set(Communi_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(Communi)
if(LOG4CXX_INCLUDE_DIR AND LOG4CXX_LIBRARY)
set(LOG4CXX_LIBRARIES ${LOG4CXX_LIBRARY})
set(LOG4CXX_FOUND 1)
message(STATUS "Using log4cxx: ${CPPUNIT_INCLUDE_DIR} ${LOG4CXX_INCLUDE_DIR}")
else()
set(log4cxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(log4cxx)
INCLUDE(FindQt4)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork)
# ADD_DEFINITIONS(${SWIFTEN_CFLAGS})
ADD_DEFINITIONS(-DSUPPORT_LEGACY_CAPS)
# ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=2)
endif()
set(event_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(event)
set(pqxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(pqxx)
if (NOT WIN32)
if (NOT WIN32 AND ENABLE_SKYPE)
set(dbus_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(dbus)
endif()
set(yahoo2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(yahoo2)
#if(ENABLE_YAHOO2)
# set(yahoo2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
# find_package(yahoo2)
#endif()
find_package(Doxygen)
####### Miscallanous ######
INCLUDE(FindQt4)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtNetwork)
if(ENABLE_DOCS)
find_package(Doxygen)
endif()
# ADD_DEFINITIONS(${SWIFTEN_CFLAGS})
ADD_DEFINITIONS(-DSUPPORT_LEGACY_CAPS)
# ADD_DEFINITIONS(-DBOOST_FILESYSTEM_VERSION=2)
if(ENABLE_LOG)
if(LOG4CXX_INCLUDE_DIR AND LOG4CXX_LIBRARY)
set(LOG4CXX_LIBRARIES ${LOG4CXX_LIBRARY})
set(LOG4CXX_FOUND 1)
message(STATUS "Using log4cxx: ${CPPUNIT_INCLUDE_DIR} ${LOG4CXX_INCLUDE_DIR}")
else()
set(log4cxx_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(log4cxx)
endif()
endif()
# FIND CPPUNIT
if(ENABLE_TESTS)
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
find_package(cppunit)
if(NOT CPPUNIT_FOUND AND CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY)
set(CCPUNIT_LIBRARIES ${CPPUNIT_LIBRARY})
set(CPPUNIT_FOUND 1)
message(STATUS "Using cppunit: ${CPPUNIT_INCLUDE_DIR} ${CPPUNIT_LIBRARIES}")
endif()
endif()
message(" Supported features")
message("-----------------------")
@ -234,14 +274,18 @@ if (SQLITE3_FOUND)
include_directories(${SQLITE3_INCLUDE_DIR})
message("SQLite3 : yes")
else (SQLITE3_FOUND)
if (WIN32)
ADD_DEFINITIONS(-DWITH_SQLITE)
include_directories(msvc-deps/sqlite3)
message("SQLite3 : bundled")
else()
set(SQLITE3_LIBRARIES "")
message("SQLite3 : no")
endif()
if (WIN32)
ADD_DEFINITIONS(-DWITH_SQLITE)
include_directories(msvc-deps/sqlite3)
message("SQLite3 : bundled")
else()
set(SQLITE3_LIBRARIES "")
if(ENABLE_SQLITE3)
message("SQLite3 : no (install sqlite3)")
else(ENABLE_SQLITE3)
message("SQLite3 : no (user disabled)")
endif()
endif()
endif (SQLITE3_FOUND)
if (MYSQL_FOUND)
@ -250,7 +294,11 @@ if (MYSQL_FOUND)
message("MySQL : yes")
else (MYSQL_FOUND)
set(MYSQL_LIBRARIES "")
message("MySQL : no (install mysql-devel)")
if(ENABLE_MYSQL)
message("MySQL : no (install mysql-devel)")
else(ENABLE_MYSQL)
message("MySQL : no (user disabled)")
endif()
endif (MYSQL_FOUND)
if (PQXX_FOUND)
@ -260,7 +308,11 @@ if (PQXX_FOUND)
else (PQXX_FOUND)
set(PQXX_LIBRARY "")
set(PQ_LIBRARY "")
message("PostgreSQL : no (install libpqxx-devel)")
if(ENABLE_PQXX)
message("PostgreSQL : no (install libpqxx-devel)")
else(ENABLE_PQXX)
message("PostgreSQL : no (user disabled)")
endif()
endif (PQXX_FOUND)
if (PROTOBUF_FOUND)
@ -273,7 +325,11 @@ if (PROTOBUF_FOUND)
include_directories(${PURPLE_INCLUDE_DIR})
include_directories(${GLIB2_INCLUDE_DIR})
else()
message("Libpurple plugin : no (install libpurple)")
if(ENABLE_PURPLE)
message("Libpurple plugin : no (install libpurple)")
else(ENABLE_PURPLE)
message("Libpurple plugin : no (user disabled)")
endif()
endif()
if (HAVE_EVENT)
@ -281,7 +337,9 @@ if (PROTOBUF_FOUND)
include_directories(${EVENT_INCLUDE_DIRS})
message(" libev eventloop : yes")
else()
message(" libev eventloop : no (install libev-devel)")
if(ENABLE_PURPLE)
message(" libev eventloop : no (install libev-devel)")
endif()
endif()
if(IRC_FOUND)
@ -291,28 +349,44 @@ if (PROTOBUF_FOUND)
include_directories(${IRC_INCLUDE_DIR})
include(${QT_USE_FILE})
else()
message("IRC plugin : no (install libCommuni and libprotobuf-dev)")
if(ENABLE_IRC)
message("IRC plugin : no (install libCommuni and libprotobuf-dev)")
else(ENABLE_IRC)
message("IRC plugin : no (user disabled)")
endif()
endif()
if (NOT WIN32)
message("Frotz plugin : yes")
message("SMSTools3 plugin : yes")
if(${LIBDBUSGLIB_FOUND})
message("Skype plugin : yes")
include_directories(${LIBDBUSGLIB_INCLUDE_DIRS})
if (NOT WIN32)
message("Frotz plugin : yes")
if(ENABLE_SMSTOOLS3)
message("SMSTools3 plugin : yes")
else()
message("SMSTools3 plugin : no")
endif()
if(${LIBDBUSGLIB_FOUND})
message("Skype plugin : yes")
include_directories(${LIBDBUSGLIB_INCLUDE_DIRS})
else()
if(ENABLE_SKYPE)
message("Skype plugin : no (install dbus-glib-devel)")
else(ENABLE_SKYPE)
message("Skype plugin : no (user disabled)")
endif()
endif()
else()
message("Skype plugin : no (install dbus-glib-devel)")
message("Frotz plugin : no")
message("SMSTools3 plugin : no")
message("Skype plugin : no")
endif()
else()
message("Frotz plugin : no")
message("SMSTools3 plugin : no")
message("Skype plugin : no")
endif()
# We have our own copy now...
# if(YAHOO2_FOUND)
if(ENABLE_YAHOO2)
message("Libyahoo2 plugin : yes")
# include_directories(${YAHOO2_INCLUDE_DIR})
else()
message("Libyahoo2 plugin : no")
endif()
# else()
# message("Libyahoo2 plugin : no (install libyahoo2-devel)")
# endif()
@ -336,22 +410,26 @@ if (LOG4CXX_FOUND)
ADD_DEFINITIONS(-DWITH_LOG4CXX)
else()
set(LOG4CXX_LIBRARIES "")
message("Log4cxx : no (install log4cxx-devel)")
if(ENABLE_LOG)
message("Log4cxx : no (install log4cxx-devel)")
else(ENABLE_LOG)
message("Log4cxx : no (user disabled)")
endif()
endif()
if (WIN32)
ADD_DEFINITIONS(-DLOG4CXX_STATIC)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
ADD_DEFINITIONS(-DBOOST_USE_WINDOWS_H)
ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
ADD_DEFINITIONS(-DLOG4CXX_STATIC)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
ADD_DEFINITIONS(-DBOOST_USE_WINDOWS_H)
ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
if (CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-O0)
ADD_DEFINITIONS(-ggdb)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-O0)
ADD_DEFINITIONS(-ggdb)
endif()
ADD_DEFINITIONS(-DDEBUG)
message("Debug : yes")
else(CMAKE_BUILD_TYPE MATCHES Debug)
@ -386,14 +464,31 @@ if (CPPUNIT_FOUND)
message("tests : yes")
include_directories(${CPPUNIT_INCLUDE_DIR})
else()
message("tests : no (install CPPUnit)")
if(ENABLE_TESTS)
message("tests : no (install CPPUnit)")
else(ENABLE_TESTS)
message("tests : no (user disabled)")
endif()
endif()
if(DOXYGEN_FOUND)
message("Docs : yes")
ADD_SUBDIRECTORY(docs)
else(DOXYGEN_FOUND)
message("Docs : no (install doxygen)")
if(ENABLE_DOCS)
message("Docs : no (install doxygen)")
else(ENABLE_DOCS)
message("Docs : no (user disabled)")
endif()
endif(DOXYGEN_FOUND)
message("----------------------")
if(NOT SQLITE3_FOUND AND NOT MYSQL_FOUND AND NOT PQXX_FOUND)
if(ENABLE_SQLITE3 OR ENABLE_MYSQL OR ENABLE_PQXX)
message("Could not find any database - Please install at least one of sqlite3-devel, mysql-devel or pqxx-devel if you want to use transport mode.")
else(ENABLE_SQLITE3 OR ENABLE_MYSQL OR ENABLE_PQXX)
message("Please enable at least one of SQLITE3, MYSQL, PQXX databases to use transport mode.")
endif()
endif()