From 44637154da89028a99920bd6ead5d917d8a894a4 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 1 Apr 2014 22:24:50 -0400 Subject: Require cmake 2.8 and C++11 support --- CMakeLists.txt | 235 +-------- Config | 38 +- Config.exe | Bin 19968 -> 18432 bytes cmake/Anope.cmake | 473 +---------------- cmake/FindGettext.cmake | 12 +- cmake/ReadFile.cmake | 5 - cmake/run-cc.pl | 226 ++++++++ include/CMakeLists.txt | 44 +- include/access.h | 7 +- include/account.h | 9 +- include/anope.h | 11 +- include/base.h | 5 +- include/bots.h | 4 +- include/channels.h | 4 +- include/commands.h | 4 +- include/config.h | 4 +- include/extensible.h | 20 +- include/hashcomp.h | 19 +- include/lists.h | 5 +- include/logger.h | 5 +- include/mail.h | 6 +- include/memo.h | 6 +- include/messages.h | 41 +- include/modes.h | 17 +- include/module.h | 4 +- include/modules.h | 7 +- include/modules/dns.h | 2 +- include/modules/os_session.h | 4 +- include/modules/sasl.h | 4 +- include/modules/sql.h | 10 +- include/opertype.h | 4 +- include/protocol.h | 4 +- include/pstdint.h | 800 ----------------------------- include/regchannel.h | 8 +- include/regexpr.h | 5 +- include/serialize.h | 4 +- include/servers.h | 4 +- include/service.h | 7 +- include/services.h | 16 +- include/socketengine.h | 4 +- include/sockets.h | 22 +- include/sysconf.h.cmake | 41 +- include/threadengine.h | 4 +- include/timers.h | 4 +- include/uplink.h | 11 +- include/users.h | 6 +- include/xline.h | 6 +- language/CMakeLists.txt | 2 +- modules/CMakeLists.txt | 194 +++---- modules/bs_autoassign.cpp | 2 +- modules/commands/bs_assign.cpp | 16 +- modules/commands/bs_badwords.cpp | 22 +- modules/commands/bs_bot.cpp | 4 +- modules/commands/bs_botlist.cpp | 4 +- modules/commands/bs_control.cpp | 8 +- modules/commands/bs_info.cpp | 6 +- modules/commands/bs_kick.cpp | 68 +-- modules/commands/bs_set.cpp | 16 +- modules/commands/cs_access.cpp | 28 +- modules/commands/cs_akick.cpp | 10 +- modules/commands/cs_ban.cpp | 6 +- modules/commands/cs_clone.cpp | 4 +- modules/commands/cs_drop.cpp | 4 +- modules/commands/cs_enforce.cpp | 4 +- modules/commands/cs_entrymsg.cpp | 10 +- modules/commands/cs_flags.cpp | 12 +- modules/commands/cs_getkey.cpp | 4 +- modules/commands/cs_info.cpp | 4 +- modules/commands/cs_invite.cpp | 4 +- modules/commands/cs_kick.cpp | 4 +- modules/commands/cs_list.cpp | 10 +- modules/commands/cs_log.cpp | 14 +- modules/commands/cs_mode.cpp | 40 +- modules/commands/cs_register.cpp | 4 +- modules/commands/cs_seen.cpp | 26 +- modules/commands/cs_set.cpp | 92 ++-- modules/commands/cs_set_misc.cpp | 14 +- modules/commands/cs_status.cpp | 4 +- modules/commands/cs_suspend.cpp | 18 +- modules/commands/cs_sync.cpp | 4 +- modules/commands/cs_topic.cpp | 14 +- modules/commands/cs_unban.cpp | 4 +- modules/commands/cs_updown.cpp | 8 +- modules/commands/cs_xop.cpp | 16 +- modules/commands/gl_global.cpp | 4 +- modules/commands/greet.cpp | 18 +- modules/commands/help.cpp | 2 +- modules/commands/hs_del.cpp | 8 +- modules/commands/hs_group.cpp | 10 +- modules/commands/hs_list.cpp | 4 +- modules/commands/hs_off.cpp | 4 +- modules/commands/hs_on.cpp | 4 +- modules/commands/hs_request.cpp | 18 +- modules/commands/hs_set.cpp | 8 +- modules/commands/ms_cancel.cpp | 4 +- modules/commands/ms_check.cpp | 4 +- modules/commands/ms_del.cpp | 6 +- modules/commands/ms_ignore.cpp | 4 +- modules/commands/ms_info.cpp | 4 +- modules/commands/ms_list.cpp | 6 +- modules/commands/ms_read.cpp | 6 +- modules/commands/ms_rsend.cpp | 4 +- modules/commands/ms_send.cpp | 4 +- modules/commands/ms_sendall.cpp | 4 +- modules/commands/ms_set.cpp | 4 +- modules/commands/ms_staff.cpp | 4 +- modules/commands/ns_access.cpp | 6 +- modules/commands/ns_ajoin.cpp | 8 +- modules/commands/ns_alist.cpp | 4 +- modules/commands/ns_cert.cpp | 28 +- modules/commands/ns_drop.cpp | 4 +- modules/commands/ns_getemail.cpp | 4 +- modules/commands/ns_getpass.cpp | 4 +- modules/commands/ns_group.cpp | 16 +- modules/commands/ns_identify.cpp | 8 +- modules/commands/ns_info.cpp | 12 +- modules/commands/ns_list.cpp | 14 +- modules/commands/ns_logout.cpp | 4 +- modules/commands/ns_recover.cpp | 12 +- modules/commands/ns_register.cpp | 20 +- modules/commands/ns_resetpass.cpp | 6 +- modules/commands/ns_set.cpp | 104 ++-- modules/commands/ns_set_misc.cpp | 14 +- modules/commands/ns_status.cpp | 4 +- modules/commands/ns_suspend.cpp | 16 +- modules/commands/ns_update.cpp | 4 +- modules/commands/os_akill.cpp | 8 +- modules/commands/os_chankill.cpp | 4 +- modules/commands/os_config.cpp | 4 +- modules/commands/os_defcon.cpp | 20 +- modules/commands/os_dns.cpp | 20 +- modules/commands/os_forbid.cpp | 24 +- modules/commands/os_ignore.cpp | 20 +- modules/commands/os_info.cpp | 10 +- modules/commands/os_jupe.cpp | 4 +- modules/commands/os_kick.cpp | 4 +- modules/commands/os_kill.cpp | 4 +- modules/commands/os_list.cpp | 8 +- modules/commands/os_login.cpp | 14 +- modules/commands/os_logsearch.cpp | 4 +- modules/commands/os_mode.cpp | 8 +- modules/commands/os_modinfo.cpp | 8 +- modules/commands/os_module.cpp | 12 +- modules/commands/os_news.cpp | 22 +- modules/commands/os_noop.cpp | 6 +- modules/commands/os_oline.cpp | 4 +- modules/commands/os_oper.cpp | 6 +- modules/commands/os_reload.cpp | 4 +- modules/commands/os_session.cpp | 36 +- modules/commands/os_set.cpp | 4 +- modules/commands/os_shutdown.cpp | 12 +- modules/commands/os_stats.cpp | 6 +- modules/commands/os_svs.cpp | 12 +- modules/commands/os_sxline.cpp | 16 +- modules/commands/os_update.cpp | 4 +- modules/cs_statusupdate.cpp | 4 +- modules/database/db_flatfile.cpp | 20 +- modules/database/db_old.cpp | 4 +- modules/database/db_redis.cpp | 34 +- modules/database/db_sql.cpp | 26 +- modules/database/db_sql_live.cpp | 18 +- modules/encryption/enc_bcrypt.cpp | 6 +- modules/encryption/enc_md5.cpp | 14 +- modules/encryption/enc_none.cpp | 6 +- modules/encryption/enc_old.cpp | 8 +- modules/encryption/enc_sha1.cpp | 14 +- modules/encryption/enc_sha256.cpp | 14 +- modules/extra/m_ldap.cpp | 18 +- modules/extra/m_ldap_authentication.cpp | 22 +- modules/extra/m_ldap_oper.cpp | 10 +- modules/extra/m_mysql.cpp | 18 +- modules/extra/m_regex_pcre.cpp | 2 +- modules/extra/m_regex_posix.cpp | 2 +- modules/extra/m_regex_tre.cpp | 2 +- modules/extra/m_sasl_dh-aes.cpp | 4 +- modules/extra/m_sasl_dh-blowfish.cpp | 4 +- modules/extra/m_sql_authentication.cpp | 10 +- modules/extra/m_sql_log.cpp | 4 +- modules/extra/m_sql_oper.cpp | 8 +- modules/extra/m_sqlite.cpp | 6 +- modules/extra/m_ssl_gnutls.cpp | 20 +- modules/extra/m_ssl_openssl.cpp | 20 +- modules/extra/stats/cs_fantasy_stats.cpp | 6 +- modules/extra/stats/cs_fantasy_top.cpp | 6 +- modules/extra/stats/irc2sql/irc2sql.h | 46 +- modules/extra/stats/m_chanstats.cpp | 38 +- modules/fantasy.cpp | 6 +- modules/m_dns.cpp | 38 +- modules/m_dnsbl.cpp | 6 +- modules/m_helpchan.cpp | 2 +- modules/m_httpd.cpp | 22 +- modules/m_proxyscan.cpp | 26 +- modules/m_redis.cpp | 26 +- modules/m_rewrite.cpp | 8 +- modules/m_sasl.cpp | 26 +- modules/m_xmlrpc.cpp | 6 +- modules/m_xmlrpc_main.cpp | 8 +- modules/ns_maxemail.cpp | 2 +- modules/protocol/bahamut.cpp | 68 +-- modules/protocol/charybdis.cpp | 72 +-- modules/protocol/hybrid.cpp | 86 ++-- modules/protocol/inspircd12.cpp | 116 ++--- modules/protocol/inspircd20.cpp | 100 ++-- modules/protocol/ngircd.cpp | 64 +-- modules/protocol/plexus.cpp | 62 +-- modules/protocol/ratbox.cpp | 52 +- modules/protocol/unreal.cpp | 126 ++--- modules/pseudoclients/botserv.cpp | 22 +- modules/pseudoclients/chanserv.cpp | 44 +- modules/pseudoclients/global.cpp | 12 +- modules/pseudoclients/hostserv.cpp | 12 +- modules/pseudoclients/memoserv.cpp | 22 +- modules/pseudoclients/nickserv.cpp | 48 +- modules/pseudoclients/operserv.cpp | 50 +- modules/third/language/CMakeLists.txt | 2 +- modules/webcpanel/pages/chanserv/access.h | 4 +- modules/webcpanel/pages/chanserv/akick.h | 4 +- modules/webcpanel/pages/chanserv/drop.h | 2 +- modules/webcpanel/pages/chanserv/info.h | 2 +- modules/webcpanel/pages/chanserv/modes.h | 4 +- modules/webcpanel/pages/chanserv/set.h | 4 +- modules/webcpanel/pages/confirm.h | 2 +- modules/webcpanel/pages/hostserv/request.h | 2 +- modules/webcpanel/pages/index.cpp | 4 +- modules/webcpanel/pages/index.h | 2 +- modules/webcpanel/pages/logout.h | 2 +- modules/webcpanel/pages/memoserv/memos.h | 2 +- modules/webcpanel/pages/nickserv/access.h | 2 +- modules/webcpanel/pages/nickserv/alist.h | 2 +- modules/webcpanel/pages/nickserv/cert.h | 2 +- modules/webcpanel/pages/nickserv/info.h | 2 +- modules/webcpanel/pages/operserv/akill.h | 2 +- modules/webcpanel/pages/register.h | 2 +- modules/webcpanel/static_fileserver.h | 2 +- modules/webcpanel/webcpanel.cpp | 2 +- modules/webcpanel/webcpanel.h | 2 +- run-cc.pl | 226 -------- src/CMakeLists.txt | 58 +-- src/main.cpp | 4 +- src/tools/CMakeLists.txt | 45 +- src/win32/Config.cs | 79 +-- src/win32/anope_windows.h | 7 + 242 files changed, 1941 insertions(+), 3697 deletions(-) delete mode 100644 cmake/ReadFile.cmake create mode 100755 cmake/run-cc.pl delete mode 100644 include/pstdint.h delete mode 100755 run-cc.pl diff --git a/CMakeLists.txt b/CMakeLists.txt index f1fbb1bb1..70ad660bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,5 @@ -# This usage of CMake requires at least version 2.4 (checks are made to determine what to use when certain versions lack functions) -cmake_minimum_required(VERSION 2.4 FATAL_ERROR) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif(COMMAND cmake_policy) +# This usage of CMake requires at least version 2.8 +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) # If the Source dir and the Binary dir are the same, we are building in-source, which we will disallow due to Autotools being there (but only on non-Windows) if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} AND NOT WIN32) @@ -13,60 +10,6 @@ endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} AND NOT W project(Anope CXX) enable_language(C) -# Detect the version of CMake for the later conditional checks -execute_process(COMMAND ${CMAKE_COMMAND} --version OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -string(REGEX REPLACE "cmake version 2\\.(.*)" "\\1" ONLY_VERSION "${VERSION}") -string(REGEX MATCH "-patch .*$" HAS_PATCH "${ONLY_VERSION}") -if(HAS_PATCH) - string(REGEX REPLACE "(.*)-patch .*" "\\1" MINOR_VERSION "${ONLY_VERSION}") - string(REGEX REPLACE ".*-patch (.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}") -else(HAS_PATCH) - string(REGEX MATCH "\\." HAS_DOT "${ONLY_VERSION}") - if(HAS_DOT) - string(REGEX REPLACE "(.*)\\..*" "\\1" MINOR_VERSION "${ONLY_VERSION}") - string(REGEX REPLACE ".*\\.(.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}") - else(HAS_DOT) - string(REGEX REPLACE "(.*)-beta" "\\1" MINOR_VERSION "${ONLY_VERSION}") - if(MINOR_VERSION STREQUAL "4-1\n") - set(PATCH_VERSION 1) - else(MINOR_VERSION STREQUAL "4-1\n") - set(PATCH_VERSION 0) - endif(MINOR_VERSION STREQUAL "4-1\n") - set(MINOR_VERSION 4) - endif(HAS_DOT) -endif(HAS_PATCH) - -# Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does -if(MINOR_VERSION GREATER 5) - set(CMAKE26_OR_BETTER TRUE) - set(CMAKE248_OR_BETTER TRUE) - set(CMAKE244_OR_BETTER TRUE) - set(CMAKE242_OR_BETTER TRUE) -else(MINOR_VERSION GREATER 5) - set(CMAKE26_OR_BETTER FALSE) - # Also detect if we are using CMake 2.4.8 or better, the FIND sub-command of list() is non-existant in earlier versions - if(PATCH_VERSION GREATER 7) - set(CMAKE248_OR_BETTER TRUE) - set(CMAKE244_OR_BETTER TRUE) - set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 7) - set(CMAKE248_OR_BETTER FALSE) - # Also detect if we are using CMake 2.4.4 or better, the CheckCXXCompilerFlag module and SORT sub-command of list() are non-existant in earlier versions - if(PATCH_VERSION GREATER 3) - set(CMAKE244_OR_BETTER TRUE) - set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 3) - set(CMAKE244_OR_BETTER FALSE) - # ALSO detect if we are using CMake 2.4.2 or better, the APPEND sub-command of list() is non-existant in earlier versions - if(PATCH_VERSION GREATER 1) - set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 1) - set(CMAKE242_OR_BETTER FALSE) - endif(PATCH_VERSION GREATER 1) - endif(PATCH_VERSION GREATER 3) - endif(PATCH_VERSION GREATER 7) -endif(MINOR_VERSION GREATER 5) - # Override the module include path to include our directory, for our Anope.cmake, as well as we are using our own version of the NSIS template set(CMAKE_MODULE_PATH ${Anope_SOURCE_DIR}/cmake) @@ -75,110 +18,6 @@ include(Anope) # Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language set(ENV{LC_ALL} C) -# Start with empty defaults for library and include directories, to be used by GNU compilers only -set(DEFAULT_LIBRARY_DIRS) -set(DEFAULT_INCLUDE_DIRS) - -# If we are using a GNU compiler (have to use CXX because it seems to fail on C), we will be able to determine it's default paths for libraries and includes -if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # First look for the compiler's default library directories - execute_process(COMMAND ${CMAKE_C_COMPILER} -print-search-dirs OUTPUT_VARIABLE LINES OUTPUT_STRIP_TRAILING_WHITESPACE) - # Find only the part after "libraries: " - string(REGEX REPLACE ".*\nlibraries: (.*)$" "\\1" LINE "${LINES}") - # Replace the colons in the list with semicolons (only when not on MinGW, which uses semicolons already), and if on MinGW, just copy the line - if(NOT MINGW) - string(REGEX REPLACE ":" ";" LIBRARIES ${LINE}) - else(NOT MINGW) - set(LIBRARIES "${LINE}") - endif(NOT MINGW) - # Iterate through the libraries - foreach(LIBRARY ${LIBRARIES}) - # Check if the first character is an equal sign, and skip that library directory as it is (I believe) the primary default and shows up later in the list anyways - string(SUBSTRING ${LIBRARY} 0 1 FIRST_CHAR) - if(NOT FIRST_CHAR STREQUAL "=") - # If the directory had no = in front of it, make sure it's absolute and add it to the list of default library directories - get_filename_component(LIBRARY ${LIBRARY} ABSOLUTE) - append_to_list(DEFAULT_LIBRARY_DIRS ${LIBRARY}) - endif(NOT FIRST_CHAR STREQUAL "=") - endforeach(LIBRARY) - # Remove duplicate entries from the list - if(DEFAULT_LIBRARY_DIRS) - remove_list_duplicates(DEFAULT_LIBRARY_DIRS) - endif(DEFAULT_LIBRARY_DIRS) - # Create a temporary file to test for the default include directories - FILE(WRITE empty.cpp "") - # Next, we look for the compiler's default include directories - # Run the command to find the default include directories - execute_process(COMMAND ${CMAKE_C_COMPILER} -v -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp ERROR_VARIABLE LINES OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) - # Remove the empty file, it is no longer needed - FILE(REMOVE empty.cpp) - # Convert the new lines to semicolons - string(REGEX REPLACE "\n" ";" LINES ${LINES}) - # Temporary variable saying if we are in the search list or not - set(IN_SEARCH_LIST FALSE) - # Iterate through the lines - foreach(LINE ${LINES}) - # If the line has the following on it, the next lines will contain directory names - if(LINE STREQUAL "#include <...> search starts here:") - set(IN_SEARCH TRUE) - else(LINE STREQUAL "#include <...> search starts here:") - # If the line has the following on it, we hit the end of the list - if(LINE STREQUAL "End of search list.") - set(IN_SEARCH FALSE) - else(LINE STREQUAL "End of search list.") - # If we are within the block between the above two lines... - if(IN_SEARCH) - # Get everything but the first character of the line - string(LENGTH ${LINE} LINE_LENGTH) - math(EXPR LINE_LENGTH "${LINE_LENGTH} - 1") - string(SUBSTRING ${LINE} 1 ${LINE_LENGTH} INCLUDE) - # For systems like Mac OS X, look for include paths that say " (framework directory)" at the end of them and strip that off - string(REGEX REPLACE " \\(framework directory\\)$" "" INCLUDE ${INCLUDE}) - # Convert the path to an absolute one, just in case it wasn't - get_filename_component(INCLUDE ${INCLUDE} ABSOLUTE) - # Add that directory to the list of default include directories - append_to_list(DEFAULT_INCLUDE_DIRS ${INCLUDE}) - endif(IN_SEARCH) - endif(LINE STREQUAL "End of search list.") - endif(LINE STREQUAL "#include <...> search starts here:") - endforeach(LINE) - # Remove duplicate entries from the list - if(DEFAULT_INCLUDE_DIRS) - remove_list_duplicates(DEFAULT_INCLUDE_DIRS) - endif(DEFAULT_INCLUDE_DIRS) -endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - -# If we are using Visual Studio, locate the path of the Windows Server 2008 SDK or Windows Server 2003 Platform SDK, depending on which is installed -if(MSVC) - # If the path comes up as "/registry" from any of these, the path wasn't found, otherwise, we'll set WSDK_PATH to the corresponding path - # Look for the 2008 SDK under HKLM first - get_filename_component(WSDK2008_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE) - if(WSDK2008_PATH STREQUAL "/registry") - # If not found, look for the 2003 SDK under HKLM - get_filename_component(WSDK2003_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1;Install Dir]" ABSOLUTE CACHE) - if(WSDK2003_PATH STREQUAL "/registry") - # If not found, look for the 2008 SDK under HKCU - get_filename_component(WSDK2008_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE) - if(WSDK2008_PATH STREQUAL "/registry") - # If not found, look for the 2003 SDK under HKCU - get_filename_component(WSDK2003_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\MicrosoftSDK\\InstalledSDKs\\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1;Install Dir]" ABSOLUTE CACHE) - if(WSDK2003_PATH STREQUAL "/registry") - # The SDK was never found, set the path to nothing - set(WSDK_PATH "") - else(WSDK2003_PATH STREQUAL "/registry") - set(WSDK_PATH "${WSDK2003_PATH}") - endif(WSDK2003_PATH STREQUAL "/registry") - else(WSDK2008_PATH STREQUAL "/registry") - set(WSDK_PATH "${WSDK2008_PATH}") - endif(WSDK2008_PATH STREQUAL "/registry") - else(WSDK2003_PATH STREQUAL "/registry") - set(WSDK_PATH "${WSDK2003_PATH}") - endif(WSDK2003_PATH STREQUAL "/registry") - else(WSDK2008_PATH STREQUAL "/registry") - set(WSDK_PATH "${WSDK2008_PATH}") - endif(WSDK2008_PATH STREQUAL "/registry") -endif(MSVC) - # If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition # and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE # to Debug @@ -191,23 +30,20 @@ if(NOT MSVC) endif(CMAKE_BUILD_TYPE) endif(NOT MSVC) -# If running under MinGW, we have to force the resource compiler settings (hopefully this will be fixed in a later version of CMake) -if(MINGW) - set(CMAKE_RC_COMPILER_INIT windres) - enable_language(RC) - set(CMAKE_RC_COMPILE_OBJECT " -o ") -endif(MINGW) - # Include the checking functions used later in this CMakeLists.txt include(CheckFunctionExists) include(CheckIncludeFile) include(CheckTypeSize) include(CheckLibraryExists) -if(CMAKE244_OR_BETTER) - include(CheckCXXCompilerFlag) -else(CMAKE244_OR_BETTER) - include(TestCXXAcceptsFlag) -endif(CMAKE244_OR_BETTER) +include(CheckCXXCompilerFlag) + +if(NOT MSVC) + CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + if(NOT COMPILER_SUPPORTS_CXX11) + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a newer compiler.") + endif(NOT COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +endif(NOT MSVC) # If extra include directories were specified, tell cmake about them. if(EXTRA_INCLUDE) @@ -224,7 +60,6 @@ find_package(Gettext) # Add an optional variable for using run-cc.pl for building, Perl will be checked later regardless of this setting option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF) -option(USE_PCH "Use precompiled headers" OFF) # Use the following directories as includes # Note that it is important the binary include directory comes before the @@ -257,25 +92,14 @@ else(MSVC) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore") endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # If we aren't on a *nix system, we are using MinGW - else(UNIX) - # Also, if we are building under MinGW, add another define for MinGW - if(MINGW) - add_definitions(-DMINGW) - endif(MINGW) endif(UNIX) endif(MSVC) # If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags if(CMAKE_DL_LIBS) - append_to_list(LINK_LIBS ${CMAKE_DL_LIBS}) + list(APPEND LINK_LIBS ${CMAKE_DL_LIBS}) endif(CMAKE_DL_LIBS) -# Under MinGW, the -shared flag isn't properly set in the module-specific linker flags, add it from the C flags for shared libraries -if(MINGW) - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") -endif(MINGW) - # Under Windows, we set the executable name for Anope to be anope if(WIN32) set(PROGRAM_NAME anope) @@ -287,13 +111,7 @@ endif(WIN32) # If we are not using Visual Studio, we'll run the following checks if(NOT MSVC) # Check if the C++ compiler can accept the -pipe flag, and add it to the compile flags if it works - if(CMAKE244_OR_BETTER) - # If using CMake 2.4.4 or better, we can use check_cxx_compiler_flag - check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG) - else(CMAKE244_OR_BETTER) - # If using CMake 2.4.3 or older, we will use check_cxx_accepts_flags instead - check_cxx_accepts_flag(-pipe HAVE_PIPE_FLAG) - endif(CMAKE244_OR_BETTER) + check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG) # If the flag was accepted, add it to the list of flags if(HAVE_PIPE_FLAG) set(CXXFLAGS "${CXXFLAGS} -pipe") @@ -304,12 +122,12 @@ if(NOT MSVC) # Check if socket is within the socket library (if the library exists), and add it to the linker flags if needed check_library_exists(socket socket "" HAVE_SOCKET_LIB) if(HAVE_SOCKET_LIB) - append_to_list(LINK_LIBS socket) + list(APPEND LINK_LIBS socket) endif(HAVE_SOCKET_LIB) # Check if inet_addr is within the nsl library (if the library exists), and add it to the linker flags if needed check_library_exists(nsl inet_addr "" HAVE_NSL_LIB) if(HAVE_NSL_LIB) - append_to_list(LINK_LIBS nsl) + list(APPEND LINK_LIBS nsl) endif(HAVE_NSL_LIB) # Check if pthread_create is within the pthread library (if the library exists), and add it to the linker flags if needed check_library_exists(pthread pthread_create "" HAVE_PTHREAD) @@ -337,14 +155,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINF set(DEBUG_BUILD TRUE) endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") -# Check for the existance of the following include files -check_include_file(cstdint HAVE_CSTDINT) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(strings.h HAVE_STRINGS_H) - # Check for the existance of the following functions -check_function_exists(strcasecmp HAVE_STRCASECMP) -check_function_exists(stricmp HAVE_STRICMP) check_function_exists(umask HAVE_UMASK) check_function_exists(epoll_wait HAVE_EPOLL) check_function_exists(poll HAVE_POLL) @@ -352,25 +163,23 @@ check_function_exists(kqueue HAVE_KQUEUE) # Strip the leading and trailing spaces from the compile flags if(CXXFLAGS) - strip_string(${CXXFLAGS} CXXFLAGS) + string(STRIP ${CXXFLAGS} CXXFLAGS) endif(CXXFLAGS) # Strip the leading and trailing spaces from the linker flags if(LDFLAGS) - strip_string(${LDFLAGS} LDFLAGS) + string(STRIP ${LDFLAGS} LDFLAGS) endif(LDFLAGS) # Search for the following programs -find_program(GREP grep) -find_program(SH sh) find_program(CHGRP chgrp) find_program(CHMOD chmod) find_program(PERL perl) # If perl is included on the system and the user wants to use run-cc.pl, change the commands for compiling and linking if(PERL AND USE_RUN_CC_PL) - set(CMAKE_CXX_COMPILE_OBJECT "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_COMPILE_OBJECT}") - set(CMAKE_CXX_LINK_EXECUTABLE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_LINK_EXECUTABLE}") - set(CMAKE_CXX_CREATE_SHARED_MODULE "${PERL} ${Anope_SOURCE_DIR}/run-cc.pl -q ${CMAKE_CXX_CREATE_SHARED_MODULE}") + set(CMAKE_CXX_COMPILE_OBJECT "${PERL} ${Anope_SOURCE_DIR}/cmake/run-cc.pl -q ${CMAKE_CXX_COMPILE_OBJECT}") + set(CMAKE_CXX_LINK_EXECUTABLE "${PERL} ${Anope_SOURCE_DIR}/cmake/run-cc.pl -q ${CMAKE_CXX_LINK_EXECUTABLE}") + set(CMAKE_CXX_CREATE_SHARED_MODULE "${PERL} ${Anope_SOURCE_DIR}/cmake/run-cc.pl -q ${CMAKE_CXX_CREATE_SHARED_MODULE}") endif(PERL AND USE_RUN_CC_PL) # If a INSTDIR was passed in to CMake, use it as the install prefix, otherwise set the default install prefix to the services directory under the user's home directory @@ -405,7 +214,7 @@ endif(NOT LOGS_DIR) # Version number processing # Find all lines in src/version.sh that start with VERSION_ -read_from_file(${Anope_SOURCE_DIR}/src/version.sh "^VERSION_" VERSIONS) +file(STRINGS ${Anope_SOURCE_DIR}/src/version.sh VERSIONS REGEX "^VERSION_") # Iterate through the strings found foreach(VERSION_STR ${VERSIONS}) # Get the length of the string @@ -426,7 +235,7 @@ set(VERSION_BUILD 0) # Only change the build number if version.h exists if(EXISTS "${Anope_SOURCE_DIR}/include/version.h") # Attempt to read the build number from include/version.h - read_from_file(${Anope_SOURCE_DIR}/include/version.h "^#define VERSION_BUILD" VERSIONS) + file(STRINGS ${Anope_SOURCE_DIR}/include/version.h VERSIONS REGEX "^#defineVERSION_BUILD") foreach(VERSION_STR ${VERSIONS}) # Get the length of the string string(LENGTH ${VERSION_STR} VERSION_LEN) diff --git a/Config b/Config index 3db854172..65dcc4585 100755 --- a/Config +++ b/Config @@ -42,7 +42,6 @@ Run_Build_System () { WITH_PERM="" EXTRA_INCLUDE="" EXTRA_LIBS="" - GEN_TYPE="" if [ "$INSTDIR" != "" ] ; then WITH_INST="-DINSTDIR:STRING=$INSTDIR" @@ -68,12 +67,6 @@ Run_Build_System () { RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=OFF" fi - if [ "$USE_PCH" = "yes" ] ; then - PCH="-DUSE_PCH:BOOLEAN=ON" - else - PCH="-DUSE_PCH:BOOLEAN=OFF" - fi - if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then EXTRA_INCLUDE="-DEXTRA_INCLUDE:STRING=$EXTRA_INCLUDE_DIRS" fi @@ -82,12 +75,6 @@ Run_Build_System () { EXTRA_LIBS="-DEXTRA_LIBS:STRING=$EXTRA_LIB_DIRS" fi - case `uname -s` in - MINGW*) - GEN_TYPE="-G\"MSYS Makefiles\"" - ;; - esac - if [ "$SOURCE_DIR" = "." ] ; then pwdsave=`pwd` test -d build || mkdir build @@ -97,9 +84,9 @@ Run_Build_System () { REAL_SOURCE_DIR="$SOURCE_DIR" fi - echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR" + echo "cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR" - cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $PCH $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR + cmake $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $EXTRA_INCLUDE $EXTRA_LIBS $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR echo "" if [ "$SOURCE_DIR" = "." ] ; then @@ -132,7 +119,6 @@ RUNGROUP= UMASK= DEBUG="no" USE_RUN_CC_PL="no" -USE_PCH="no" EXTRA_INCLUDE_DIRS= EXTRA_LIB_DIRS= EXTRA_CONFIG_ARGS= @@ -378,25 +364,6 @@ echo "" #### -TEMP_YN="n" -if [ "$USE_PCH" = "yes" ] ; then - TEMP_YN="y" -fi -echo "Do you want to build using precompiled headers? This can speed up" -echo "the build, but uses more disk space." -echo2 "[$TEMP_YN] " -read YN -if [ "$YN" ] ; then - if [ "$YN" = "y" ] ; then - USE_PCH="yes" - else - USE_PCH="no" - fi -fi -echo "" - -#### - echo "Are there any extra include directories you wish to use?" echo "You may only need to do this if CMake is unable to locate" echo "missing dependencies without hints." @@ -460,7 +427,6 @@ RUNGROUP="$RUNGROUP" UMASK=$UMASK DEBUG="$DEBUG" USE_RUN_CC_PL="$USE_RUN_CC_PL" -USE_PCH="$USE_PCH" EXTRA_INCLUDE_DIRS="$EXTRA_INCLUDE_DIRS" EXTRA_LIB_DIRS="$EXTRA_LIB_DIRS" EXTRA_CONFIG_ARGS="$EXTRA_CONFIG_ARGS" diff --git a/Config.exe b/Config.exe index e9393e089..3be910bb0 100644 Binary files a/Config.exe and b/Config.exe differ diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake index 587e32980..aeeb9eb27 100644 --- a/cmake/Anope.cmake +++ b/cmake/Anope.cmake @@ -1,421 +1,3 @@ -############################################################################### -# strip_string( ) -# -# A macro to handle stripping the leading and trailing spaces from a string, -# uses string(STRIP) if using CMake 2.6.x or better, otherwise uses -# string(REGEX REPLACE). -############################################################################### -macro(strip_string INPUT_STRING OUTPUT_STRING) - if(CMAKE26_OR_BETTER) - # For CMake 2.6.x or better, we can just use the STRIP sub-command of string() - string(STRIP ${INPUT_STRING} ${OUTPUT_STRING}) - else(CMAKE26_OR_BETTER) - # For CMake 2.4.x, we will have to use the REGEX REPLACE sub-command of string() instead - # First check if the input string is empty or not - if (${INPUT_STRING} STREQUAL "") - set(${OUTPUT_STRING} "") - else(${INPUT_STRING} STREQUAL "") - # Determine if the string is entirely empty or not - string(REGEX MATCH "^[ \t]*$" EMPTY_STRING "${INPUT_STRING}") - if(EMPTY_STRING) - set(${OUTPUT_STRING} "") - else(EMPTY_STRING) - # We detect if there is any leading whitespace and remove any if there is - string(SUBSTRING "${INPUT_STRING}" 0 1 FIRST_CHAR) - if(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t") - string(REGEX REPLACE "^[ \t]+" "" TEMP_STRING "${INPUT_STRING}") - else(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t") - set(TEMP_STRING "${INPUT_STRING}") - endif(FIRST_CHAR STREQUAL " " OR FIRST_CHAR STREQUAL "\t") - # Next we detect if there is any trailing whitespace and remove any if there is - string(LENGTH "${TEMP_STRING}" STRING_LEN) - math(EXPR STRING_LEN "${STRING_LEN} - 1") - string(SUBSTRING "${TEMP_STRING}" ${STRING_LEN} 1 LAST_CHAR) - if(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t") - string(REGEX REPLACE "[ \t]+$" "" ${OUTPUT_STRING} "${TEMP_STRING}") - else(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t") - set(${OUTPUT_STRING} "${TEMP_STRING}") - endif(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t") - endif(EMPTY_STRING) - endif(${INPUT_STRING} STREQUAL "") - endif(CMAKE26_OR_BETTER) -endmacro(strip_string) - -############################################################################### -# append_to_list( ...) -# -# A macro to handle appending to lists, uses list(APPEND) if using CMake 2.4.2 -# or better, otherwise uses set() instead. -############################################################################### -macro(append_to_list LIST) - if(CMAKE242_OR_BETTER) - # For CMake 2.4.2 or better, we can just use the APPEND sub-command of list() - list(APPEND ${LIST} ${ARGN}) - else(CMAKE242_OR_BETTER) - # For CMake 2.4.x before 2.4.2, we have to do this manually use set() instead - set(${LIST} ${${LIST}} ${ARGN}) - endif(CMAKE242_OR_BETTER) -endmacro(append_to_list) - -############################################################################### -# find_in_list( ) -# -# A macro to handle searching within a list, will store the result in the -# given , uses list(FIND) if using CMake 2.6.x or better -# (or CMake 2.4.8 or better), otherwise it iterates through the list to find -# the item. -############################################################################### -macro(find_in_list LIST ITEM_TO_FIND FOUND) - if(CMAKE248_OR_BETTER) - # For CMake 2.4.8 or better, we can use the FIND sub-command of list() - list(FIND ${LIST} ${ITEM_TO_FIND} ITEM_FOUND) - else(CMAKE248_OR_BETTER) - # For CMake 2.4.x before 2.4.8, we have to do this ourselves (NOTE: This is very slow due to a lack of break() as well) - # Firstly we set the position to -1 indicating nothing found, we also use a temporary position - set(ITEM_FOUND -1) - set(POS 0) - # Iterate through the list - foreach(ITEM ${${LIST}}) - # If the item we are looking at is the item we are trying to find, set that we've found the item - if(${ITEM} STREQUAL ${ITEM_TO_FIND}) - set(ITEM_FOUND ${POS}) - endif(${ITEM} STREQUAL ${ITEM_TO_FIND}) - # Increase the position value by 1 - math(EXPR POS "${POS} + 1") - endforeach(ITEM) - endif(CMAKE248_OR_BETTER) - # Set the given FOUND variable to the result - set(${FOUND} ${ITEM_FOUND}) -endmacro(find_in_list) - -############################################################################### -# remove_list_duplicates() -# -# A macro to handle removing duplicates from a list, uses -# list(REMOVE_DUPLICATES) if using CMake 2.6.x or better, otherwise it uses -# a slower method of creating a temporary list and only adding to it when -# a duplicate item hasn't been found. -############################################################################### -macro(remove_list_duplicates LIST) - if(CMAKE26_OR_BETTER) - # For CMake 2.6.x or better, this can be done automatically - list(REMOVE_DUPLICATES ${LIST}) - else(CMAKE26_OR_BETTER) - # For CMake 2.4.x, we have to do this ourselves, firstly we'll clear a temporary list - set(NEW_LIST) - # Iterate through the old list - foreach(ITEM ${${LIST}}) - # Check if the item is in the new list - find_in_list(NEW_LIST ${ITEM} FOUND_ITEM) - if(FOUND_ITEM EQUAL -1) - # If the item was not found, append it to the list - append_to_list(NEW_LIST ${ITEM}) - endif(FOUND_ITEM EQUAL -1) - endforeach(ITEM) - # Replace the old list with the new list - set(${LIST} ${NEW_LIST}) - endif(CMAKE26_OR_BETTER) -endmacro(remove_list_duplicates) - -############################################################################### -# remove_item_from_list( ) -# -# A macro to handle removing a value from a list, uses list(REMOVE_ITEM) in -# both cases, but can remove the value itself using CMake 2.4.2 or better, -# while older versions use a slower method of iterating the list to find the -# index of the value to remove. -############################################################################### -macro(remove_item_from_list LIST VALUE) - if(CMAKE242_OR_BETTER) - # For CMake 2.4.2 or better, this can be done automatically - list(REMOVE_ITEM ${LIST} ${VALUE}) - else(CMAKE242_OR_BETTER) - # For CMake 2.4.x before 2.4.2, we have to do this ourselves, firstly we set the index and a variable to indicate if the item was found - set(INDEX 0) - set(FOUND FALSE) - # Iterate through the old list - foreach(ITEM ${${LIST}}) - # If the item hasn't been found yet, but the current item is the same, remove it - if(NOT FOUND) - if(ITEM STREQUAL ${VALUE}) - set(FOUND TRUE) - list(REMOVE_ITEM ${LIST} ${INDEX}) - endif(ITEM STREQUAL ${VALUE}) - endif(NOT FOUND) - # Increase the index value by 1 - math(EXPR INDEX "${INDEX} + 1") - endforeach(ITEM) - endif(CMAKE242_OR_BETTER) -endmacro(remove_item_from_list) - -############################################################################### -# sort_list() -# -# A macro to handle sorting a list, uses list(SORT) if using CMake 2.4.4 or -# better, otherwise it uses a slower method of creating a temporary list and -# adding elements in alphabetical order. -############################################################################### -macro(sort_list LIST) - if(CMAKE244_OR_BETTER) - # For CMake 2.4.4 or better, this can be done automatically - list(SORT ${LIST}) - else(CMAKE244_OR_BETTER) - # For CMake 2.4.x before 2.4.4, we have to do this ourselves, firstly we'll create a teporary list - set(NEW_LIST) - # Iterate through the old list - foreach(ITEM ${${LIST}}) - # Temporary index position for the new list, as well as temporary value to store if the item was ever found - set(INDEX 0) - set(FOUND FALSE) - # Iterate through the new list - foreach(NEW_ITEM ${NEW_LIST}) - # Compare the items, only if nothing was found before - if(NOT FOUND) - if(NEW_ITEM STRGREATER "${ITEM}") - set(FOUND TRUE) - list(INSERT NEW_LIST ${INDEX} ${ITEM}) - endif(NEW_ITEM STRGREATER "${ITEM}") - endif(NOT FOUND) - # Increase the index value by 1 - math(EXPR INDEX "${INDEX} + 1") - endforeach(NEW_ITEM) - # If the item was never found, just append it to the end - if(NOT FOUND) - append_to_list(NEW_LIST ${ITEM}) - endif(NOT FOUND) - endforeach(ITEM) - # Replace the old list with the new list - set(${LIST} ${NEW_LIST}) - endif(CMAKE244_OR_BETTER) -endmacro(sort_list) - -############################################################################### -# read_from_file( ) -# -# A macro to handle reading specific lines from a file, uses file(STRINGS) if -# using CMake 2.6.x or better, otherwise we read in the entire file and -# perform a string(REGEX MATCH) on each line of the file instead. This -# macro can also be used to read in all the lines of a file if REGEX is set -# to "". -############################################################################### -macro(read_from_file FILE REGEX STRINGS) - if(CMAKE26_OR_BETTER) - # For CMake 2.6.x or better, we can just use the STRINGS sub-command to get the lines that match the given regular expression (if one is given, otherwise get all lines) - if(REGEX STREQUAL "") - file(STRINGS ${FILE} RESULT) - else(REGEX STREQUAL "") - file(STRINGS ${FILE} RESULT REGEX ${REGEX}) - endif(REGEX STREQUAL "") - else(CMAKE26_OR_BETTER) - # For CMake 2.4.x, we need to do this manually, firstly we read the file in - execute_process(COMMAND ${CMAKE_COMMAND} -DFILE:STRING=${FILE} -P ${Anope_SOURCE_DIR}/cmake/ReadFile.cmake ERROR_VARIABLE ALL_STRINGS) - # Next we replace all newlines with semicolons - string(REGEX REPLACE "\n" ";" ALL_STRINGS ${ALL_STRINGS}) - if(REGEX STREQUAL "") - # For no regular expression, just set the result to all the lines - set(RESULT ${ALL_STRINGS}) - else(REGEX STREQUAL "") - # Clear the result list - set(RESULT) - # Iterate through all the lines of the file - foreach(STRING ${ALL_STRINGS}) - # Check for a match against the given regular expression - string(REGEX MATCH ${REGEX} STRING_MATCH ${STRING}) - # If we had a match, append the match to the list - if(STRING_MATCH) - append_to_list(RESULT ${STRING}) - endif(STRING_MATCH) - endforeach(STRING) - endif(REGEX STREQUAL "") - endif(CMAKE26_OR_BETTER) - # Set the given STRINGS variable to the result - set(${STRINGS} ${RESULT}) -endmacro(read_from_file) - -############################################################################### -# extract_include_filename( []) -# -# This macro will take a #include line and extract the filename. -############################################################################### -macro(extract_include_filename INCLUDE FILENAME) - # Strip the leading and trailing spaces from the include line - strip_string(${INCLUDE} INCLUDE_STRIPPED) - # Make sure to only do the following if there is a string - if(INCLUDE_STRIPPED STREQUAL "") - set(FILE "") - else(INCLUDE_STRIPPED STREQUAL "") - # Extract the filename including the quotes or angle brackets - string(REGEX REPLACE "^.*([\"<].*[\">]).*$" "\\1" FILE "${INCLUDE_STRIPPED}") - # If an optional 3rd argument is given, we'll store if the quote style was quoted or angle bracketed - if(${ARGC} GREATER 2) - string(SUBSTRING ${FILE} 0 1 QUOTE) - if(QUOTE STREQUAL "<") - set(${ARGV2} "angle brackets") - else(QUOTE STREQUAL "<") - set(${ARGV2} "quotes") - endif(QUOTE STREQUAL "<") - endif(${ARGC} GREATER 2) - # Now remove the quotes or angle brackets - string(REGEX REPLACE "^[\"<](.*)[\">]$" "\\1" FILE "${FILE}") - endif(INCLUDE_STRIPPED STREQUAL "") - # Set the filename to the the given variable - set(${FILENAME} "${FILE}") -endmacro(extract_include_filename) - -############################################################################### -# find_includes( ) -# -# This macro will search through a file for #include lines, regardless of -# whitespace, but only returns the lines that are valid for the current -# platform CMake is running on. -############################################################################### -macro(find_includes SRC INCLUDES) - # Read all lines from the file that start with #, regardless of whitespace before the # - read_from_file(${SRC} "^[ \t]*#.*$" LINES) - # Set that any #include lines found are valid, and create temporary variables for the last found #ifdef/#ifndef - set(VALID_LINE TRUE) - set(LAST_DEF) - set(LAST_CHECK) - # Create an empty include list - set(INCLUDES_LIST) - # Iterate through all the # lines - foreach(LINE ${LINES}) - # Search for #ifdef, #ifndef, #else, #endif, and #include - string(REGEX MATCH "^[ \t]*#[ \t]*ifdef[ \t]*.*$" FOUND_IFDEF ${LINE}) - string(REGEX MATCH "^[ \t]*#[ \t]*ifndef[ \t]*.*$" FOUND_IFNDEF ${LINE}) - string(REGEX MATCH "^[ \t]*#[ \t]*else.*$" FOUND_ELSE ${LINE}) - string(REGEX MATCH "^[ \t]*#[ \t]*endif.*$" FOUND_ENDIF ${LINE}) - string(REGEX MATCH "^[ \t]*#[ \t]*include[ \t]*[\"<].*[\">][\ t]*.*$" FOUND_INCLUDE ${LINE}) - # If we found a #ifdef on the line, extract the data after the #ifdef and set if the lines after it are valid based on the variables in CMake - if(FOUND_IFDEF) - # Extract the define - string(REGEX REPLACE "^[ \t]*#[ \t]*ifdef[ \t]*(.*)$" "\\1" DEFINE ${LINE}) - # Replace _WIN32 with WIN32, so we can check if the WIN32 variable of CMake is set instead of _WIN32 - if(DEFINE STREQUAL "_WIN32") - set(DEFINE WIN32) - endif(DEFINE STREQUAL "_WIN32") - # Set the last define to this one, and set the last check to true, so when #else is encountered, we can do an opposing check - set(LAST_DEF ${DEFINE}) - set(LAST_CHECK TRUE) - # If the define is true (it either exists or is a non-false result), the lines following will be checked, otherwise they will be skipped - if(${DEFINE}) - set(VALID_LINE TRUE) - else(${DEFINE}) - set(VALID_LINE FALSE) - endif(${DEFINE}) - else(FOUND_IFDEF) - # If we found a #ifndef on the line, the same thing as #ifdef is done, except with the checks in the opposite direction - if(FOUND_IFNDEF) - # Extract the define - string(REGEX REPLACE "^[ \t]*#[ \t]*ifndef[ \t]*(.*)$" "\\1" DEFINE ${LINE}) - # Replace _WIN32 with WIN32, so we can check if the WIN32 variable of CMake is set instead of _WIN32 - if(DEFINE STREQUAL "_WIN32") - set(DEFINE WIN32) - endif(DEFINE STREQUAL "_WIN32") - # Set the last define to this one, and set the last check to false, so when #else is encountered, we can do an opposing check - set(LAST_DEF ${DEFINE}) - set(LAST_CHECK FALSE) - # If the define is not true (it either doesn't exists or is a false result), the lines following will be checked, otherwise they will be skipped - if(${DEFINE}) - set(VALID_LINE FALSE) - else(${DEFINE}) - set(VALUE_LINE TRUE) - endif(${DEFINE}) - else(FOUND_IFNDEF) - # If we found a #else on the line, we check the last define in the opposite direction - if(FOUND_ELSE) - # When LAST_CHECK is true, we were inside a #ifdef, now act as if we are entering a #ifndef section by doing an opposing check - if(LAST_CHECK) - if(${LAST_DEF}) - set(VALID_LINE FALSE) - else(${LAST_DEF}) - set(VALID_LINE TRUE) - endif(${LAST_DEF}) - # When LAST_CHECK is false, we were inside a #ifndef, now act as if we are entering a #ifdef section by doing an opposing check - else(LAST_CHECK) - if(${LAST_DEF}) - set(VALID_LINE TRUE) - else(${LAST_DEF}) - set(VALID_LINE FALSE) - endif(${LAST_DEF}) - endif(LAST_CHECK) - else(FOUND_ELSE) - # If we found a #endif on the line, we'll assume everything following the line is valid until we meet another one of the above lines - if(FOUND_ENDIF) - set(VALID_LINE TRUE) - else(FOUND_ENDIF) - # If we found a #include on the line, add the entire line to the list of includes unless the line isn't valid - if(FOUND_INCLUDE) - if(VALID_LINE) - append_to_list(INCLUDES_LIST "${LINE}") - endif(VALID_LINE) - endif(FOUND_INCLUDE) - endif(FOUND_ENDIF) - endif(FOUND_ELSE) - endif(FOUND_IFNDEF) - endif(FOUND_IFDEF) - endforeach(LINE) - set(${INCLUDES} ${INCLUDES_LIST}) -endmacro(find_includes) - -############################################################################### -# calculate_depends( []) -# -# This macro is used in most of the src (sub)directories to calculate the -# header file dependencies for the given source file. -############################################################################### -macro(calculate_depends SRC) - # Temporarily set that we didn't get a 3rd argument before we actually check if we did get one or not - set(CHECK_ANGLE_INCLUDES FALSE) - # Check for a third argument - if(${ARGC} GREATER 1) - set(CHECK_ANGLE_INCLUDES TRUE) - endif(${ARGC} GREATER 1) - # Find all the lines in the given source file that have any form of #include on them, regardless of whitespace, but only if they are valid for the platform we are on - find_includes(${SRC} INCLUDES) - # Reset the list of headers to empty - set(HEADERS) - # Iterate through the strings containing #include (if any) - foreach(INCLUDE ${INCLUDES}) - # Extract the filename from the #include line - extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE) - if(QUOTE_TYPE STREQUAL "angle brackets") - # The following checks will only be done if there was a request for angle includes to be checked - if(CHECK_ANGLE_INCLUDES) - # Find the path of the include file - if(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_path(FOUND_${FILENAME}_INCLUDE NAMES ${FILENAME} PATHS ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/include $ENV{VCINSTALLDIR}/include ${EXTRA_INCLUDE}) - else(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_path(FOUND_${FILENAME}_INCLUDE NAMES ${FILENAME} ${EXTRA_INCLUDE}) - endif(DEFAULT_INCLUDE_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - # If the include file was found, add it's path to the list of include paths, but only if it doesn't already exist and isn't in the defaults for the compiler - if(FOUND_${FILENAME}_INCLUDE) - # This used to be find_in_list, but it was changed to this loop to do a find on each default include directory, this fixes Mac OS X trying to get it's framework directories in here - set(FOUND_IN_DEFAULTS -1) - foreach(DEFAULT_INCLUDE_DIR ${DEFAULT_INCLUDE_DIRS}) - string(REGEX REPLACE "\\+" "\\\\+" DEFAULT_INCLUDE_DIR ${DEFAULT_INCLUDE_DIR}) - string(REGEX MATCH ${DEFAULT_INCLUDE_DIR} FOUND_DEFAULT ${FOUND_${FILENAME}_INCLUDE}) - if(FOUND_DEFAULT) - set(FOUND_IN_DEFAULTS 0) - endif(FOUND_DEFAULT) - endforeach(DEFAULT_INCLUDE_DIR) - if(FOUND_IN_DEFAULTS EQUAL -1) - find_in_list(${ARGV1} "${FOUND_${FILENAME}_INCLUDE}" FOUND_IN_INCLUDES) - if(FOUND_IN_INCLUDES EQUAL -1) - append_to_list(${ARGV1} "${FOUND_${FILENAME}_INCLUDE}") - endif(FOUND_IN_INCLUDES EQUAL -1) - endif(FOUND_IN_DEFAULTS EQUAL -1) - else(FOUND_${FILENAME}_INCLUDE) - # XXX - if(NOT ${FILENAME} STREQUAL "libintl.h") - message(FATAL_ERROR "${SRC} needs header file ${FILENAME} but we were unable to locate that header file! Check that the header file is within the search path of your OS.") - endif(NOT ${FILENAME} STREQUAL "libintl.h") - endif(FOUND_${FILENAME}_INCLUDE) - endif(CHECK_ANGLE_INCLUDES) - endif(QUOTE_TYPE STREQUAL "angle brackets") - endforeach(INCLUDE) -endmacro(calculate_depends) - ############################################################################### # calculate_libraries( ) # @@ -432,7 +14,7 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) # Reset libraries set(LIBRARIES) # Check to see if there are any lines matching: /* RequiredLibraries: [something] */ - read_from_file(${SRC} "/\\\\*[ \t]*RequiredLibraries:[ \t]*.*[ \t]*\\\\*/" REQUIRED_LIBRARIES) + file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\\\*[ \t]*RequiredLibraries:[ \t]*.*[ \t]*\\\\*/") # Iterate through those lines foreach(REQUIRED_LIBRARY ${REQUIRED_LIBRARIES}) # Strip off the /* RequiredLibraries: and */ from the line @@ -442,22 +24,18 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) # Iterate through the libraries given foreach(LIBRARY ${REQUIRED_LIBRARY}) # Locate the library to see if it exists - if(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS}) - else(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${EXTRA_INCLUDE} ${EXTRA_LIBS}) - endif(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) + find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS}) # If the library was found, we will add it to the linker flags if(FOUND_${LIBRARY}_LIBRARY) # Get the path only of the library, to add it to linker flags get_filename_component(LIBRARY_PATH ${FOUND_${LIBRARY}_LIBRARY} PATH) if(MSVC) # For Visual Studio, instead of editing the linker flags, we'll add the library to a separate list of extra dependencies - append_to_list(EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}") + list(APPEND EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}") else(MSVC) # For all others, add the library paths and libraries - append_to_list(LIBRARY_PATHS "${LIBRARY_PATH}") - append_to_list(LIBRARIES "${LIBRARY}") + list(APPEND LIBRARY_PATHS "${LIBRARY_PATH}") + list(APPEND LIBRARIES "${LIBRARY}") endif(MSVC) else(FOUND_${LIBRARY}_LIBRARY) # In the case of the library not being found, we fatally error so CMake stops trying to generate @@ -467,57 +45,24 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) endforeach(REQUIRED_LIBRARY) # Remove duplicates from the library paths if(LIBRARY_PATHS) - remove_list_duplicates(LIBRARY_PATHS) + list(REMOVE_DUPLICATES LIBRARY_PATHS) endif(LIBRARY_PATHS) # Remove diplicates from the libraries if(LIBRARIES) - remove_list_duplicates(LIBRARIES) + list(REMOVE_DUPLICATES LIBRARIES) endif(LIBRARIES) # Iterate through library paths and add them to the linker flags foreach(LIBRARY_PATH ${LIBRARY_PATHS}) - find_in_list(DEFAULT_LIBRARY_DIRS "${LIBRARY_PATH}" FOUND_IN_DEFAULTS) - if(FOUND_IN_DEFAULTS EQUAL -1) - set(THIS_LDFLAGS "${THIS_LDFLAGS} -L${LIBRARY_PATH}") - endif(FOUND_IN_DEFAULTS EQUAL -1) + set(THIS_LDFLAGS "${THIS_LDFLAGS} -L${LIBRARY_PATH}") endforeach(LIBRARY_PATH) # Iterate through libraries and add them to the linker flags foreach(LIBRARY ${LIBRARIES}) - append_to_list(EXTRA_DEPENDENCIES "${LIBRARY}") + list(APPEND EXTRA_DEPENDENCIES "${LIBRARY}") endforeach(LIBRARY) set(${SRC_LDFLAGS} "${THIS_LDFLAGS}") set(${EXTRA_DEPENDS} "${EXTRA_DEPENDENCIES}") endmacro(calculate_libraries) -############################################################################### -# check_functions( ) -# -# This macro is used in most of the module (sub)directories to calculate the -# fcuntion dependencies for the given source file. -############################################################################### -macro(check_functions SRC SUCCESS) - # Default to true - set(${SUCCESS} TRUE) - # Check to see if there are any lines matching: /* RequiredFunctions: [something] */ - read_from_file(${SRC} "/\\\\*[ \t]*RequiredFunctions:[ \t]*.*[ \t]*\\\\*/" REQUIRED_FUNCTIONS) - # Iterate through those lines - foreach(REQUIRED_FUNCTION ${REQUIRED_FUNCTIONS}) - # Strip off the /* RequiredFunctions: and */ from the line - string(REGEX REPLACE "/\\*[ \t]*RequiredFunctions:[ \t]*([^ \t]*)[ \t]*\\*/" "\\1" REQUIRED_FUNCTION ${REQUIRED_FUNCTION}) - # Replace all commas with semicolons - string(REGEX REPLACE "," ";" REQUIRED_FUNCTION ${REQUIRED_FUNCTION}) - # Iterate through the functions given - foreach(FUNCTION ${REQUIRED_FUNCTION}) - # Check if the function exists - check_function_exists(${REQUIRED_FUNCTION} HAVE_${REQUIRED_FUNCTION}) - # If we don't have the function warn the user and set SUCCESS to FALSE - if(NOT HAVE_${REQUIRED_FUNCTION}) - message("${SRC} needs function ${REQUIRED_FUNCTION} but we were unable to locate that function!") - set(${SUCCESS} FALSE) - endif(NOT HAVE_${REQUIRED_FUNCTION}) - endforeach(FUNCTION) - endforeach(REQUIRED_FUNCTION) -endmacro(check_functions) - ############################################################################### # add_to_cpack_ignored_files( [TRUE]) # diff --git a/cmake/FindGettext.cmake b/cmake/FindGettext.cmake index e97bfef36..e3279a8b8 100644 --- a/cmake/FindGettext.cmake +++ b/cmake/FindGettext.cmake @@ -8,12 +8,12 @@ if(NOT WIN32) set(GETTEXT_FOUND TRUE) endif(GETTEXT_INCLUDE AND GETTEXT_MSGFMT) else(NOT WIN32) - find_path(GETTEXT_INCLUDE libintl.h ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/include $ENV{VCINSTALLDIR}/include gettext/include ${EXTRA_INCLUDE}) - find_library(GETTEXT_LIBRARY libintl PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) - find_library(ICONV_LIBRARY libiconv PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) - find_library(MINGWEX_LIBRARY libmingwex PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) - find_library(GCC_LIBRARY libgcc PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) - find_program(GETTEXT_MSGFMT msgfmt PATHS ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/bin $ENV{VCINSTALLDIR}/bin gettext/bin ${EXTRA_INCLUDE}) + find_path(GETTEXT_INCLUDE libintl.h $ENV{VCINSTALLDIR}/include gettext/include ${EXTRA_INCLUDE}) + find_library(GETTEXT_LIBRARY libintl PATHS $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) + find_library(ICONV_LIBRARY libiconv PATHS $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) + find_library(MINGWEX_LIBRARY libmingwex PATHS $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) + find_library(GCC_LIBRARY libgcc PATHS $ENV{VCINSTALLDIR}/lib gettext/lib ${EXTRA_LIBS}) + find_program(GETTEXT_MSGFMT msgfmt PATHS $ENV{VCINSTALLDIR}/bin gettext/bin ${EXTRA_INCLUDE}) if(GETTEXT_INCLUDE AND GETTEXT_MSGFMT AND ICONV_LIBRARY AND MINGWEX_LIBRARY AND GCC_LIBRARY) set(GETTEXT_FOUND TRUE) endif(GETTEXT_INCLUDE AND GETTEXT_MSGFMT AND ICONV_LIBRARY AND MINGWEX_LIBRARY AND GCC_LIBRARY) diff --git a/cmake/ReadFile.cmake b/cmake/ReadFile.cmake deleted file mode 100644 index be60f1fa7..000000000 --- a/cmake/ReadFile.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# This file is external to the read_from_file macro in Anope.cmake in order to -# get around a possible memory leak in older versions of CMake. - -file(READ "${FILE}" RESULT) -message("${RESULT}") diff --git a/cmake/run-cc.pl b/cmake/run-cc.pl new file mode 100755 index 000000000..fe28dee10 --- /dev/null +++ b/cmake/run-cc.pl @@ -0,0 +1,226 @@ +#!/usr/bin/env perl + +### THIS IS DESIGNED TO BE RUN BY MAKE! DO NOT RUN FROM THE SHELL (because it MIGHT sigterm the shell)! ### + +use strict; +use warnings FATAL => qw(all); + +use POSIX (); + +# Runs the compiler, passing it the given arguments. +# Filters select output from the compiler's standard error channel and +# can take different actions as a result. + +# NOTE: this is *NOT* a hash (sadly: a hash would stringize all the regexes and thus render them useless, plus you can't index a hash based on regexes anyway) +# even though we use the => in it. + +# The subs are passed the message, and anything the regex captured. + +my $flag = shift(@ARGV); +my $quiet = 0; +my $cc; +if ($flag eq "-q") { + $quiet = 1; + $cc = shift(@ARGV); +} +else { + $cc = $flag; +} + +my $showncmdline = 0; + +# GCC's "location of error stuff", which accumulates the "In file included from" include stack +my $location = ""; + +my @msgfilters = ( + [ qr/^(.*) warning: cannot pass objects of non-POD type `(.*)' through `\.\.\.'; call will abort at runtime/ => sub { + my ($msg, $where, $type) = @_; + my $errstr = $location . "$where error: cannot pass objects of non-POD type `$type' through `...'\n"; + $location = ""; + if ($type =~ m/::(basic_)?string/) { + $errstr .= "$where (Did you forget to call c_str()?)\n"; + } + die $errstr; + } ], + + # Start of an include stack. + [ qr/^In file included from .*[,:]$/ => sub { + my ($msg) = @_; + $location = "$msg\n"; + return undef; + } ], + + # Continuation of an include stack. + [ qr/^ from .*[,:]$/ => sub { + my ($msg) = @_; + $location .= "$msg\n"; + return undef; + } ], + + # A function, method, constructor, or destructor is the site of a problem + [ qr/In ((con|de)structor|(member )?function)/ => sub { + my ($msg) = @_; + # If a complete location string is waiting then probably we dropped an error, so drop the location for a new one. + if ($location =~ m/In ((con|de)structor|(member )?function)/) { + $location = "$msg\n"; + } else { + $location .= "$msg\n"; + } + return undef; + } ], + + [ qr/^.* warning: / => sub { + my ($msg) = @_; + my $str = $location . "\e[33;1m$msg\e[0m\n"; + $showncmdline = 1; + $location = ""; + return $str; + } ], + + [ qr/^.* error: / => sub { + my ($msg) = @_; + my $str = ""; + $str = "An error occured when executing:\e[37;1m $cc " . join(' ', @ARGV) . "\n" unless $showncmdline; + $showncmdline = 1; + $str .= $location . "\e[31;1m$msg\e[0m\n"; + $location = ""; + return $str; + } ], + + [ qr/./ => sub { + my ($msg) = @_; + $msg = $location . $msg; + $location = ""; + $msg =~ s/std::basic_string\, std::allocator\ \>(\s+|)/std::string/g; + $msg =~ s/std::basic_string\ \>(\s+|)/irc::string/g; + $msg =~ s/std::basic_string\ \>(\s+|)/ci::string/g; + for my $stl (qw(deque vector list)) { + $msg =~ s/std::$stl\<(\S+), std::allocator\<\1\> \>/std::$stl\<$1\>/g; + $msg =~ s/std::$stl\<(std::pair\<\S+, \S+\>), std: