diff options
| author | Adam <adam@sigterm.info> | 2015-12-30 21:06:25 -0600 |
|---|---|---|
| committer | Adam <adam@sigterm.info> | 2015-12-30 21:06:25 -0600 |
| commit | 01644e13703f1bed42bcf1497be3c6b43b186ad6 (patch) | |
| tree | 4fba1a0cde055a6aa4ca131ef823f3a587f1f048 | |
| parent | c56a6b03c0d5025935563625c25c6347ed90160a (diff) | |
| parent | 71c2a0a675c7767ff69cc243849da7eb64fe88d7 (diff) | |
Merge pull request #139 from SaberUK/master+cmake-cleanup
Clean up the build system, part 1.
| -rw-r--r-- | CMakeLists.txt | 141 | ||||
| -rwxr-xr-x | Config | 6 | ||||
| -rw-r--r-- | cmake/Anope.cmake | 40 | ||||
| -rw-r--r-- | cmake/FindGettext.cmake | 12 | ||||
| -rw-r--r-- | docs/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | include/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | language/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | modules/CMakeLists.txt | 70 | ||||
| -rw-r--r-- | modules/third/language/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 34 | ||||
| -rw-r--r-- | src/tools/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/win32/Config.cs | 359 |
12 files changed, 157 insertions, 531 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index be2b38261..a0d38c5ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,25 @@ -# This usage of CMake requires at least version 2.8 -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +# This usage of CMake requires at least version 3.0 +cmake_minimum_required(VERSION 3.0 FATAL_ERROR) cmake_policy(SET CMP0003 NEW) if(POLICY CMP0026) cmake_policy(SET CMP0026 OLD) -endif(POLICY CMP0026) +endif() if(POLICY CMP0007) cmake_policy(SET CMP0007 OLD) -endif(POLICY CMP0007) +endif() # Set the project as C++ primarily, but have C enabled for the checks required later project(Anope CXX) enable_language(C) # 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) +list(APPEND CMAKE_MODULE_PATH "${Anope_SOURCE_DIR}/cmake") -include(Anope) +include("Anope") +include("CheckFunctionExists") +include("CheckLibraryExists") +include("CheckCXXCompilerFlag") # 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) @@ -28,35 +31,26 @@ set(ENV{LC_ALL} C) if(NOT MSVC) if(CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - else(CMAKE_BUILD_TYPE) + else() set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - endif(CMAKE_BUILD_TYPE) -endif(NOT MSVC) - -# Include the checking functions used later in this CMakeLists.txt -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckTypeSize) -include(CheckLibraryExists) -include(CheckCXXCompilerFlag) - -if(NOT MSVC) - CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) + endif() + + 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) + endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -endif(NOT MSVC) +endif() # If extra include directories were specified, tell cmake about them. if(EXTRA_INCLUDE) include_directories(${EXTRA_INCLUDE}) -endif(EXTRA_INCLUDE) +endif() # If extra library directories were specified, tell cmake about them. if(EXTRA_LIBS) link_directories(${EXTRA_LIBS}) -endif(EXTRA_LIBS) +endif() # Find gettext find_package(Gettext) @@ -71,7 +65,7 @@ if(WIN32) add_definitions(-D_WIN32) # And include the windows specific folder for our anope_windows.h include_directories(${Anope_SOURCE_DIR}/src/win32) -endif(WIN32) +endif() # If using Visual Studio, set the C++ flags accordingly if(MSVC) @@ -83,26 +77,27 @@ if(MSVC) set(CXXFLAGS "${CXXFLAGS} /W4 /wd4100 /wd4127 /wd4250 /wd4251 /wd4355 /wd4706 /wd4800 /wd4996 /EHs") add_definitions(-DMSVCPP -D_CRT_SECURE_NO_WARNINGS) # Otherwise, we're not using Visual Studio -else(MSVC) +else() # Set the compile flags to have all warnings on (including shadowed variables) set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow") # If on a *nix system, also set the compile flags to remove GNU extensions (favor ISO C++) as well as reject non-ISO C++ code, also remove all leading underscores in exported symbols (only on GNU compiler) if(UNIX) - set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic ${CMAKE_CXX_FLAGS}") - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore") - endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - endif(UNIX) -endif(MSVC) + set(CXXFLAGS "${CXXFLAGS} -pedantic ${CMAKE_CXX_FLAGS}") + if(${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang") + set(CXXFLAGS "${CXXFLAGS} -stdlib=libc++") + set(LDFLAGS "${LDFLAGS} -stdlib=libc++") + endif() + endif() +endif() # 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) list(APPEND LINK_LIBS ${CMAKE_DL_LIBS}) -endif(CMAKE_DL_LIBS) +endif() if(NOT PROGRAM_NAME) set(PROGRAM_NAME anope) -endif(NOT PROGRAM_NAME) +endif() # If we are not using Visual Studio, we'll run the following checks if(NOT MSVC) @@ -111,7 +106,7 @@ if(NOT MSVC) # If the flag was accepted, add it to the list of flags if(HAVE_PIPE_FLAG) set(CXXFLAGS "${CXXFLAGS} -pipe") - endif(HAVE_PIPE_FLAG) + endif() # The following are additional library checks, they are not required for Windows if(NOT WIN32) @@ -119,37 +114,37 @@ if(NOT MSVC) check_library_exists(socket socket "" HAVE_SOCKET_LIB) if(HAVE_SOCKET_LIB) list(APPEND LINK_LIBS socket) - endif(HAVE_SOCKET_LIB) + endif() # 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) list(APPEND LINK_LIBS nsl) - endif(HAVE_NSL_LIB) + endif() # 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) if(HAVE_PTHREAD) if(NOT APPLE) set(LDFLAGS "${LDFLAGS} -pthread") - endif(NOT APPLE) - else(HAVE_PTHREAD) + endif() + else() message(FATAL_ERROR "The pthread library is required to build Anope") - endif(HAVE_PTHREAD) - endif(NOT WIN32) -endif(NOT MSVC) + endif() + endif() +endif() # If DEFUMASK wasn't passed to CMake, set a default depending on if RUNGROUP was passed in or not if(NOT DEFUMASK) if(RUNGROUP) set(DEFUMASK "007") - else(RUNGROUP) + else() set(DEFUMASK "077") - endif(RUNGROUP) -endif(NOT DEFUMASK) + endif() +endif() # Set the DEBUG_BUILD for sysconf.h if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") set(DEBUG_BUILD TRUE) -endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") +endif() # Check for the existance of the following functions check_function_exists(umask HAVE_UMASK) @@ -160,45 +155,43 @@ check_function_exists(kqueue HAVE_KQUEUE) # Strip the leading and trailing spaces from the compile flags if(CXXFLAGS) string(STRIP ${CXXFLAGS} CXXFLAGS) -endif(CXXFLAGS) +endif() # Strip the leading and trailing spaces from the linker flags if(LDFLAGS) string(STRIP ${LDFLAGS} LDFLAGS) -endif(LDFLAGS) +endif() # Search for the following programs find_program(CHGRP chgrp) find_program(CHMOD chmod) -# 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 -if(INSTDIR) - set(CMAKE_INSTALL_PREFIX "${INSTDIR}") -elseif(NOT CMAKE_INSTALL_PREFIX) +# If CMAKE_INSTALL_PREFIX was not passed in to CMake set the default install prefix to the "anope" directory under the user's home directory +if(NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope") -endif(INSTDIR) +endif() # Set default paths for various directories if not already defined if(NOT BIN_DIR) set(BIN_DIR "bin") -endif(NOT BIN_DIR) +endif() if(NOT DB_DIR) set(DB_DIR "data") -endif(NOT DB_DIR) +endif() if(NOT DOC_DIR) set(DOC_DIR "doc") -endif(NOT DOC_DIR) +endif() if(NOT CONF_DIR) set(CONF_DIR "conf") -endif(NOT CONF_DIR) +endif() if(NOT LIB_DIR) set(LIB_DIR "lib") -endif(NOT LIB_DIR) +endif() if(NOT LOCALE_DIR) set(LOCALE_DIR "locale") -endif(NOT LOCALE_DIR) +endif() if(NOT LOGS_DIR) set(LOGS_DIR "logs") -endif(NOT LOGS_DIR) +endif() # Version number processing # Find all lines in src/version.sh that start with VERSION_ @@ -212,8 +205,8 @@ foreach(VERSION_STR ${VERSIONS}) if(${VERSION_LEN} GREATER 1) list(GET VERSION_OUT 1 VERSION_DATA) set(VERSION_${VERSION_TYPE} ${VERSION_DATA}) - endif(${VERSION_LEN} GREATER 1) -endforeach(VERSION_STR ${VERSIONS}) + endif() +endforeach() # Default build version to 0 set(VERSION_BUILD 0) @@ -231,8 +224,8 @@ if(EXISTS "${Anope_SOURCE_DIR}/include/version.h") string(SUBSTRING ${VERSION_STR} 22 ${VERSION_NUM_LEN} VERSION) # Set VERSION_BUILD correctly set(VERSION_BUILD ${VERSION}) - endforeach(VERSION_STR ${VERSIONS}) -endif(EXISTS "${Anope_SOURCE_DIR}/include/version.h") + endforeach() +endif() # Set the version variables based on what was found above set(VERSION_COMMA "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_BUILD}") @@ -245,7 +238,7 @@ set(VERSION_FULL_NOBUILD "${VERSION_DOTTED_NOBUILD}${VERSION_EXTRA}") if(WIN32) # Generate the win32.rc file using the above variables configure_file(${Anope_SOURCE_DIR}/src/win32/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32/win32.rc) -endif(WIN32) +endif() # Add the initial files to ignore which will be ignored regardless of if you are building in-source or out-of-source add_to_cpack_ignored_files(".git\;config.cache\;CMakeFiles\;sysconf.h$\;build" TRUE) @@ -260,8 +253,8 @@ if(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR}) # If using Visual Studio, add these files as well if(MSVC) add_to_cpack_ignored_files(".vcproj$\;.sln$\;.ncb$\;.suo$\;.dir$\;.ilk$\;.exp$\;.pdb$\;.lib$\;/debug$;/release$;/relwithdebinfo$;/minsizerel$" TRUE) - endif(MSVC) -endif(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR}) + endif() +endif() # Go into the following directories and run their CMakeLists.txt as well add_subdirectory(data) @@ -280,13 +273,13 @@ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${DB_D install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${LOGS_DIR}\")") if(WIN32) install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/runtime\")") -endif(WIN32) +endif() # On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory if(NOT WIN32 AND RUNGROUP) install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/\${DB_DIR}/backups\")") install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/\${LOGS_DIR}\")") install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}\")") -endif(NOT WIN32 AND RUNGROUP) +endif() # On Windows platforms, install extra files if(WIN32) install(FILES ${Anope_SOURCE_DIR}/src/win32/anope.bat @@ -296,7 +289,7 @@ if(WIN32) # Package any DLLs in src/win/ file(GLOB EXTRA_DLLS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${Anope_SOURCE_DIR}/src/win32/*.dll") install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) -endif(WIN32) +endif() install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/modules\")") @@ -315,9 +308,9 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") # The following is primarily for NSIS if(WIN32) # By default, do not warn when built on machines using only VS Express: - IF(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) - SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) - ENDIF(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) + endif() # Also for Windows, include installing the MSVCRT library include(InstallRequiredSystemLibraries) set(CPACK_GENERATOR "NSIS") @@ -337,10 +330,10 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") set(CPACK_NSIS_INSTALLED_ICON_NAME "${SERVICES_BINARY}") set(CPACK_NSIS_URL_INFO_ABOUT "http://www.anope.org/") set(CPACK_NSIS_COMPRESSOR "/SOLID lzma") - endif(WIN32) + endif() set(CPACK_SOURCE_PACKAGE_FILE_NAME "anope-${VERSION_FULL_NOBUILD}-source") set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_IGNORE_FILES "$ENV{CPACK_IGNORED_FILES}") set(CPACK_MONOLITHIC_INSTALL TRUE) include(CPack) -endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") +endif() @@ -44,7 +44,7 @@ Run_Build_System () { EXTRA_LIBS="" if [ "$INSTDIR" != "" ] ; then - WITH_INST="-DINSTDIR:STRING=$INSTDIR" + WITH_INST="-DCMAKE_INSTALL_PREFIX:STRING=$INSTDIR" fi if [ "$RUNGROUP" != "" ] ; then @@ -56,9 +56,9 @@ Run_Build_System () { fi if [ "$DEBUG" = "yes" ] ; then - BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=DEBUG" + BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=DEBUG -Wdev" else - BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE" + BUILD_TYPE="-DCMAKE_BUILD_TYPE:STRING=RELEASE -Wno-dev" fi if [ "$EXTRA_INCLUDE_DIRS" != "" ] ; then diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake index 48a57d213..7e125692e 100644 --- a/cmake/Anope.cmake +++ b/cmake/Anope.cmake @@ -16,9 +16,9 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) # Check to see if there are any lines matching: /* RequiredLibraries: [something] */ if(WIN32) file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\*[ \t]*RequiredWindowsLibraries:[ \t]*.*[ \t]*\\*/") - else(WIN32) + else() file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\*[ \t]*RequiredLibraries:[ \t]*.*[ \t]*\\*/") - endif(WIN32) + endif() # Iterate through those lines foreach(REQUIRED_LIBRARY ${REQUIRED_LIBRARIES}) # Strip off the /* RequiredLibraries: and */ from the line @@ -36,36 +36,36 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) if(MSVC) # For Visual Studio, instead of editing the linker flags, we'll add the library to a separate list of extra dependencies list(APPEND EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}") - else(MSVC) + else() # For all others, add the library paths and libraries list(APPEND LIBRARY_PATHS "${LIBRARY_PATH}") list(APPEND LIBRARIES "${LIBRARY}") - endif(MSVC) - else(FOUND_${LIBRARY}_LIBRARY) + endif() + else() # In the case of the library not being found, we fatally error so CMake stops trying to generate message(FATAL_ERROR "${SRC} needs library ${LIBRARY} but we were unable to locate that library! Check that the library is within the search path of your OS.") - endif(FOUND_${LIBRARY}_LIBRARY) - endforeach(LIBRARY) - endforeach(REQUIRED_LIBRARY) + endif() + endforeach() + endforeach() # Remove duplicates from the library paths if(LIBRARY_PATHS) list(REMOVE_DUPLICATES LIBRARY_PATHS) - endif(LIBRARY_PATHS) + endif() # Remove diplicates from the libraries if(LIBRARIES) list(REMOVE_DUPLICATES LIBRARIES) - endif(LIBRARIES) + endif() # Iterate through library paths and add them to the linker flags foreach(LIBRARY_PATH ${LIBRARY_PATHS}) set(THIS_LDFLAGS "${THIS_LDFLAGS} -L${LIBRARY_PATH}") - endforeach(LIBRARY_PATH) + endforeach() # Iterate through libraries and add them to the linker flags foreach(LIBRARY ${LIBRARIES}) list(APPEND EXTRA_DEPENDENCIES "${LIBRARY}") - endforeach(LIBRARY) + endforeach() set(${SRC_LDFLAGS} "${THIS_LDFLAGS}") set(${EXTRA_DEPENDS} "${EXTRA_DEPENDENCIES}") -endmacro(calculate_libraries) +endmacro() ############################################################################### # add_to_cpack_ignored_files(<item> [TRUE]) @@ -80,15 +80,15 @@ macro(add_to_cpack_ignored_files ITEM) # If we have 2+ arguments, assume that the second one was something like TRUE (doesn't matter really) and convert periods so they will be \\. for CPack if(${ARGC} GREATER 1) string(REPLACE "." "\\\\." REAL_ITEM ${REAL_ITEM}) - endif(${ARGC} GREATER 1) + endif() # If the environment variable is already defined, just tack the item to the end if(DEFINED ENV{CPACK_IGNORED_FILES}) set(ENV{CPACK_IGNORED_FILES} "$ENV{CPACK_IGNORED_FILES};${REAL_ITEM}") # Otherwise set the environment variable to the item - else(DEFINED ENV{CPACK_IGNORED_FILES}) + else() set(ENV{CPACK_IGNORED_FILES} "${REAL_ITEM}") - endif(DEFINED ENV{CPACK_IGNORED_FILES}) -endmacro(add_to_cpack_ignored_files) + endif() +endmacro() macro(calculate_dependencies SRC) file(STRINGS ${SRC} REQUIRED_LIBRARIES REGEX "/\\*[ \t]*Dependencies:[ \t]*.*[ \t]*\\*/") @@ -102,7 +102,7 @@ macro(calculate_dependencies SRC) get_filename_component(TARGNAME ${SRC} NAME_WE) target_link_libraries(${TARGNAME} ${LIBRARY}) add_dependencies(${TARGNAME} ${LIBRARY}) - endforeach(LIBRARY) - endforeach(REQUIRED_LIBRARY) -endmacro(calculate_dependencies) + endforeach() + endforeach() +endmacro() diff --git a/cmake/FindGettext.cmake b/cmake/FindGettext.cmake index 975294d21..b0f4f9486 100644 --- a/cmake/FindGettext.cmake +++ b/cmake/FindGettext.cmake @@ -7,20 +7,20 @@ if(NOT WIN32) set(GETTEXT_FOUND TRUE) if(GETTEXT_LIBRARY) set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY}) - endif(GETTEXT_LIBRARY) - endif(GETTEXT_INCLUDE AND GETTEXT_MSGFMT) -else(NOT WIN32) + endif() + endif() +else() 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_program(GETTEXT_MSGFMT msgfmt PATHS ${DEFAULT_INCLUDE_DIRS} ${WSDK_PATH}/bin $ENV{VCINSTALLDIR}/bin gettext/bin ${EXTRA_INCLUDE}) if(GETTEXT_INCLUDE AND GETTEXT_LIBRARY AND GETTEXT_MSGFMT) set(GETTEXT_FOUND TRUE) set(GETTEXT_LIBRARIES ${GETTEXT_LIBRARY}) - endif(GETTEXT_INCLUDE AND GETTEXT_LIBRARY AND GETTEXT_MSGFMT) -endif(NOT WIN32) + endif() +endif() # If we found everything we need set variables correctly for lang/CMakeLists.txt to use if(GETTEXT_FOUND) include_directories("${GETTEXT_INCLUDE}") set(GETTEXT_MSGFMT_EXECUTABLE ${GETTEXT_MSGFMT}) -endif(GETTEXT_FOUND) +endif() diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 082b1da0e..fd93e81c0 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -6,10 +6,10 @@ if(WIN32) if(IN_SOURCE) # Add README.txt to list of files for CPack to ignore add_to_cpack_ignored_files("README.txt$" TRUE) - endif(IN_SOURCE) + endif() set(DOCS Changes Changes.conf DEFCON FAQ INSTALL LANGUAGE MODULES NEWS ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt) install(FILES ${DOCS} DESTINATION ${DOC_DIR} ) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/README.txt") -endif(WIN32) +endif() diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 72bfdfba1..f4ed6a0a4 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -16,7 +16,7 @@ add_to_cpack_ignored_files("${version_BINARY}$" TRUE) if(NOT WIN32) add_to_cpack_ignored_files("version.h$" TRUE) add_to_cpack_ignored_files("build.h$" TRUE) -endif(NOT WIN32) +endif() # Add a custom target to the above file add_custom_target(headers DEPENDS version ${CMAKE_CURRENT_BINARY_DIR}/version_build) diff --git a/language/CMakeLists.txt b/language/CMakeLists.txt index ff5ae2b8f..a5135a273 100644 --- a/language/CMakeLists.txt +++ b/language/CMakeLists.txt @@ -26,12 +26,12 @@ if(GETTEXT_FOUND) # Add to cpack ignored files if not on Windows. if(NOT WIN32) add_to_cpack_ignored_files("${LANG_MO}") - endif(NOT WIN32) + endif() # Install the new language file install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS}) - endforeach(LANG_PO) + endforeach() # Generate languages, depends on the mo files add_custom_target(language DEPENDS ${LANG_SRCS_MO}) -endif(GETTEXT_FOUND) +endif() diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 68a2a89b0..1851f47b9 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,17 +1,17 @@ # If using Windows, add the MODULE_COMPILE define if(WIN32) add_definitions(-DMODULE_COMPILE) -endif(WIN32) +endif() macro(build_modules SRC) if(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt") add_subdirectory("${SRC}") - else(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt") + else() file(GLOB MODULES_SRCS "${SRC}/*") foreach(MODULE_SRC ${MODULES_SRCS}) if(IS_DIRECTORY "${MODULE_SRC}") build_modules("${MODULE_SRC}") - else(IS_DIRECTORY "${MODULE_SRC}") + else() string(REGEX MATCH "\\.cpp$" CPP ${MODULE_SRC}) if(CPP) set_source_files_properties(${MODULE_SRC} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") @@ -23,9 +23,9 @@ macro(build_modules SRC) file(RELATIVE_PATH DEST "${Anope_SOURCE_DIR}/modules" ${SRC}) if(DEST) set(TARG "module_${DEST}.${SO}") - else(DEST) + else() set(TARG "module_${SO}") - endif(DEST) + endif() # Reset linker flags set(TEMP_LDFLAGS) @@ -36,53 +36,51 @@ macro(build_modules SRC) # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators if(MSVC) set(WIN32_MEMORY win32_memory) - else(MSVC) + else() set(WIN32_MEMORY) - endif(MSVC) + endif() # Generate the module and set its linker flags, also set it to depend on the main Anope executable to be built beforehand add_library(${TARG} MODULE ${MODULE_SRC}) # Windows requires this because it's weird if(WIN32) set(WIN32_NO_LIBS "/nodefaultlib:\"libcmt.lib\" /OPT:NOREF") - else(WIN32) + else() set(WIN32_NO_LIBS) - endif(WIN32) + endif() set_target_properties(${TARG} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON OUTPUT_NAME "${SO}") add_dependencies(${TARG} ${PROGRAM_NAME}) if(GETTEXT_FOUND) add_dependencies(${TARG} module_language) - endif(GETTEXT_FOUND) + endif() target_link_libraries(${TARG} ${TEMP_DEPENDENCIES}) # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set its version if(WIN32) target_link_libraries(${TARG} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY}) set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") - else(WIN32) - if(APPLE) - target_link_libraries(${TARG} ${PROGRAM_NAME}) - endif(APPLE) - endif(WIN32) + elseif(APPLE) + target_link_libraries(${TARG} ${PROGRAM_NAME}) + endif() calculate_dependencies(${MODULE_SRC}) # Set the module to be installed to the module directory under the data directory install(TARGETS ${TARG} DESTINATION ${LIB_DIR}/modules/${DEST}) - endif(CPP) - endif(IS_DIRECTORY "${MODULE_SRC}") - endforeach(MODULE_SRC ${MODULES_SRCS}) - endif(NOT ${SRC} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR} AND EXISTS "${SRC}/CMakeLists.txt") -endmacro(build_modules) + endif() + endif() + endforeach() + endif() +endmacro() macro(build_subdir) file(GLOB_RECURSE MODULES_SUBDIR_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") list(SORT MODULES_SUBDIR_SRCS) file(RELATIVE_PATH DEST "${Anope_SOURCE_DIR}/modules" ${CMAKE_CURRENT_SOURCE_DIR}) - GET_FILENAME_COMPONENT(DIR_NAME ${DEST} DIRECTORY) - GET_FILENAME_COMPONENT(FOLDER_NAME ${DEST} NAME) + get_filename_component(DIR_NAME ${DEST} DIRECTORY) + get_filename_component(FOLDER_NAME ${DEST} NAME) if(DIR_NAME) set(SO "${DIR_NAME}.${FOLDER_NAME}") - else(DIR_NAME) + else() set(SO "${FOLDER_NAME}") - endif(DIR_NAME) + endif() # Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) set_source_files_properties(${MODULES_SUBDIR_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") @@ -100,25 +98,25 @@ macro(build_subdir) # Append this source file's linker flags to the subdirectoy's linker flags, if there are any to append if(TEMP_DEPENDENCIES) append_to_list(SUBDIR_EXTRA_DEPENDS ${TEMP_DEPDENCIES}) - endif(TEMP_DEPENDENCIES) - endforeach(SRC ${MODULES_SUBDIR_SRCS}) + endif() + endforeach() # Remove duplicates from the linker flags if(SUBDIR_LDFLAGS) list(REMOVE_DUPLICATES SUBDIR_LDFLAGS) - endif(SUBDIR_LDFLAGS) + endif() # Remove duplicates from the extra dependencies if(SUBDIR_EXTRA_DEPENDS) list(REMOVE_DUPLICATES SUBDIR_EXTRA_DEPENDS) - endif(SUBDIR_EXTRA_DEPENDS) + endif() # For Visual Studio only, include win32_memory static library, required to override Visual Studio's overrides of the new/delete operators if(MSVC) set(WIN32_MEMORY win32_memory) - else(MSVC) + else() set(WIN32_MEMORY) - endif(MSVC) + endif() # Generate the module and set its linker flags, also set it to depend on the main Anope executable to be built beforehand add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS}) @@ -126,20 +124,18 @@ macro(build_subdir) add_dependencies(${SO} ${PROGRAM_NAME}) if(GETTEXT_FOUND) add_dependencies(${SO} module_language) - endif(GETTEXT_FOUND) + endif() target_link_libraries(${SO} ${SUBDIR_EXTRA_DEPENDS}) # For Windows only, have the module link to the export library of Anope as well as wsock32 and Ws2_32 libraries (most of the modules probably don't need this, but this is to be on the safe side), also set its version if(WIN32) target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY}) set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") - else(WIN32) - if(APPLE) - target_link_libraries(${SO} ${PROGRAM_NAME}) - endif(APPLE) - endif(WIN32) + elseif(APPLE) + target_link_libraries(${SO} ${PROGRAM_NAME}) + endif() install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules/${DIR_NAME}) -endmacro(build_subdir) +endmacro() build_modules(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/modules/third/language/CMakeLists.txt b/modules/third/language/CMakeLists.txt index c46544836..6a7891475 100644 --- a/modules/third/language/CMakeLists.txt +++ b/modules/third/language/CMakeLists.txt @@ -26,13 +26,13 @@ if(GETTEXT_FOUND) # Add to cpack ignored files if not on Windows. if(NOT WIN32) add_to_cpack_ignored_files("${LANG_MO}") - endif(NOT WIN32) + endif() # Install the new language file - install(CODE "FILE(MAKE_DIRECTORY ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/)") + install(CODE "file(MAKE_DIRECTORY ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/)") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS}) - endforeach(LANG_PO) + endforeach() # Generate languages, depends on the mo files add_custom_target(module_language DEPENDS ${LANG_SRCS_MO}) -endif(GETTEXT_FOUND) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b32c1d9c0..373677fe7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,21 +8,17 @@ if(WIN32) list(APPEND SRC_SRCS win32/dl/dl.cpp) list(APPEND SRC_SRCS win32/pipe/pipe.cpp) list(APPEND SRC_SRCS win32/sigaction/sigaction.cpp) -endif(WIN32) +endif() if(HAVE_EPOLL) list(APPEND SRC_SRCS socketengines/socketengine_epoll.cpp) -else(HAVE_EPOLL) - if(HAVE_KQUEUE) - list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp) - else(HAVE_KQUEUE) - if(HAVE_POLL) - list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp) - else(HAVE_POLL) - list(APPEND SRC_SRCS socketengines/socketengine_select.cpp) - endif(HAVE_POLL) - endif(HAVE_KQUEUE) -endif(HAVE_EPOLL) +elseif(HAVE_KQUEUE) + list(APPEND SRC_SRCS socketengines/socketengine_kqueue.cpp) +elseif(HAVE_POLL) + list(APPEND SRC_SRCS socketengines/socketengine_poll.cpp) +else() + list(APPEND SRC_SRCS socketengines/socketengine_select.cpp) +endif() list(SORT SRC_SRCS) @@ -36,7 +32,7 @@ if(WIN32) # Add the resource file to the list of sources list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"") -endif(WIN32) +endif() # If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators if(MSVC) @@ -44,9 +40,9 @@ if(MSVC) add_library(win32_memory STATIC win32/win32_memory.cpp) set(WIN32_MEMORY win32_memory) set(EXTRA_LDFLAGS "/OPT:NOREF") # https://sourceware.org/bugzilla/show_bug.cgi?id=12633 -else(MSVC) +else() set(WIN32_MEMORY) -endif(MSVC) +endif() # Generate the Anope executable and set it's linker flags, also set it to export it's symbols even though it's not a module add_executable(${PROGRAM_NAME} ${SRC_SRCS}) @@ -55,15 +51,15 @@ set_target_properties(${PROGRAM_NAME} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS if(WIN32) target_link_libraries(${PROGRAM_NAME} wsock32 Ws2_32 ${LINK_LIBS} ${GETTEXT_LIBRARIES} ${WIN32_MEMORY}) set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") -else(WIN32) +else() target_link_libraries(${PROGRAM_NAME} ${LINK_LIBS} ${GETTEXT_LIBRARIES}) -endif(WIN32) +endif() # Building the Anope executable requires the version.h header to be generated add_dependencies(${PROGRAM_NAME} headers) # Also require the language files if we have gettext if(GETTEXT_FOUND) add_dependencies(${PROGRAM_NAME} language) -endif(GETTEXT_FOUND) +endif() # Get the filename of the Anope executable as it is in on this system get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION) @@ -77,7 +73,7 @@ configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/i # Go into the following directories and run their CMakeLists.txt as well if(NOT DISABLE_TOOLS) add_subdirectory(tools) -endif(NOT DISABLE_TOOLS) +endif() # Set Anope to be installed to the bin directory install(TARGETS ${PROGRAM_NAME} diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index d970d93b0..4d64f6fd9 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -21,7 +21,7 @@ foreach(SRC ${TOOLS_SRCS}) get_target_property(EXE_BINARY ${EXE} LOCATION) get_filename_component(EXE_BINARY ${EXE_BINARY} NAME) add_to_cpack_ignored_files("${EXE_BINARY}$" TRUE) -endforeach(SRC) +endforeach() # If not on Windows, generate anoperc and install it along with mydbgen if(NOT WIN32) @@ -32,9 +32,9 @@ if(NOT WIN32) install (PROGRAMS geoipupdate.sh DESTINATION ${BIN_DIR} ) -endif(NOT WIN32) +endif() # On non-Windows platforms, if RUNGROUP is set, change the permissions of the tools directory if(NOT WIN32 AND RUNGROUP) install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin\")") -endif(NOT WIN32 AND RUNGROUP) +endif() diff --git a/src/win32/Config.cs b/src/win32/Config.cs deleted file mode 100644 index ea94e338a..000000000 --- a/src/win32/Config.cs +++ /dev/null @@ -1,359 +0,0 @@ -/*
- * Config.cs - Windows Configuration
- *
- * (C) 2003-2014 Anope Team
- * Contact us at team@anope.org
- *
- * This program is free but copyrighted software; see the file COPYING for
- * details.
- *
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
- *
- * Written by Scott <stealtharcher.scott@gmail.com>
- * Written by Adam <Adam@anope.org>
- * Cleaned up by Naram Qashat <cyberbotx@anope.org>
- *
- * Compile with: csc /out:../../Config.exe /win32icon:anope-icon.ico Config.cs
- */
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-
-namespace Config
-{
- class Config
- {
- static string ExecutablePath, InstallDirectory, ExtraIncludeDirs, ExtraLibDirs, ExtraArguments;
- static bool UseNMake = true, BuildDebug = false;
-
- static bool CheckResponse(string InstallerResponse)
- {
- return string.Compare(InstallerResponse, "yes", true) == 0 || string.Compare(InstallerResponse, "y", true) == 0;
- }
-
- static bool LoadCache()
- {
- try
- {
- string[] cache = File.ReadAllLines(string.Format(@"{0}\config.cache", ExecutablePath));
- if (cache.Length > 0)
- Console.WriteLine("Using defaults from config.cache");
- foreach (string line in cache)
- {
- int e = line.IndexOf('=');
- string name = line.Substring(0, e);
- string value = line.Substring(e + 1);
-
- if (name == "INSTDIR")
- InstallDirectory = value;
- else if (name == "DEBUG")
- BuildDebug = CheckResponse(value);
- else if (name == "USENMAKE")
- UseNMake = CheckResponse(value);
- else if (name == "EXTRAINCLUDE")
- ExtraIncludeDirs = value;
- else if (name == "EXTRALIBS")
- ExtraLibDirs = value;
- else if (name == "EXTRAARGS")
- ExtraArguments = value;
- }
-
- return true;
- }
- catch (Exception)
- {
- }
-
- return false;
- }
-
- static void SaveCache()
- {
- using (TextWriter tw = new StreamWriter(string.Format(@"{0}\config.cache", ExecutablePath)))
- {
- tw.WriteLine("INSTDIR={0}", InstallDirectory);
- tw.WriteLine("DEBUG={0}", BuildDebug ? "yes" : "no");
- tw.WriteLine("USENMAKE={0}", UseNMake ? "yes" : "no");
- tw.WriteLine("EXTRAINCLUDE={0}", ExtraIncludeDirs);
- tw.WriteLine("EXTRALIBS={0}", ExtraLibDirs);
- tw.WriteLine("EXTRAARGS={0}", ExtraArguments);
- }
- }
-
- static string HandleCache(int i)
- {
- switch (i)
- {
- case 0:
- Console.Write("[{0}] ", InstallDirectory);
- return InstallDirectory;
- case 1:
- Console.Write("[{0}] ", UseNMake ? "yes" : "no");
- return UseNMake ? "yes" : "no";
- case 2:
- Console.Write("[{0}] ", BuildDebug ? "yes" : "no");
- return BuildDebug ? "yes" : "no";
- case 3:
- Console.Write("[{0}] ", ExtraIncludeDirs);
- return ExtraIncludeDirs;
- case 4:
- Console.Write("[{0}] ", ExtraLibDirs);
- return ExtraLibDirs;
- case 5:
- Console.Write("[{0}] ", ExtraArguments);
- return ExtraArguments;
- default:
- break;
- }
-
- return null;
- }
-
- static string FindAnopeVersion()
- {
- if (!File.Exists(string.Format(@"{0}\src\version.sh", ExecutablePath)))
- return "Unknown";
-
- Dictionary<string, string> versions = new Dictionary<string, string>();
- string[] versionfile = File.ReadAllLines(string.Format(@"{0}\src\version.sh", ExecutablePath));
- foreach (string line in versionfile)
- if (line.StartsWith("VERSION_"))
- {
- string key = line.Split('_')[1].Split('=')[0];
- if (!versions.ContainsKey(key))
- versions.Add(key, line.Split('=')[1].Replace("\"", "").Replace("\'", ""));
- }
-
- try
- {
- if (versions.ContainsKey("BUILD"))
- return string.Format("{0}.{1}.{2}.{3}{4}", versions["MAJOR"], versions["MINOR"], versions["PATCH"], versions["BUILD"], versions["EXTRA"]);
- else
- return string.Format("{0}.{1}.{2}{3}", versions["MAJOR"], versions["MINOR"], versions["PATCH"], versions["EXTRA"]);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- return "Unknown";
- }
- }
-
- static void RunCMake(string cMake)
- {
- Console.WriteLine("cmake {0}", cMake);
- try
- {
- ProcessStartInfo processStartInfo = new ProcessStartInfo("cmake")
- {
- RedirectStandardError = true,
- RedirectStandardOutput = true,
- UseShellExecute = false,
- Arguments = cMake
- };
- Process pCMake = Process.Start(processStartInfo);
- StreamReader stdout = pCMake.StandardOutput, stderr = pCMake.StandardError;
- string stdoutr, stderrr;
- List<string> errors = new List<string>();
- while (!pCMake.HasExited)
- {
- if ((stdoutr = stdout.ReadLine()) != null)
- Console.WriteLine(stdoutr);
- if ((stderrr = stderr.ReadLine()) != null)
- errors.Add(stderrr);
- }
- foreach (string error in errors)
- Console.WriteLine(error);
- Console.WriteLine();
- if (pCMake.ExitCode == 0)
- {
- if (UseNMake)
- Console.WriteLine("To compile Anope, run 'nmake'. To install, run 'nmake install'");
- else
- Console.WriteLine("To compile Anope, open Anope.sln and build the solution. To install, do a build on the INSTALL project");
- }
- else
- Console.WriteLine("There was an error attempting to run CMake! Check the above error message, and contact the Anope team if you are unsure how to proceed.");
- }
- catch (Exception e)
- {
- Console.WriteLine();
- Console.WriteLine(DateTime.UtcNow + " UTC: " + e.Message);
- Console.WriteLine("There was an error attempting to run CMake! Check the above error message, and contact the Anope team if you are unsure how to proceed.");
- }
- }
-
- static int Main(string[] args)
- {
- bool IgnoreCache = false, NoIntro = false, DoQuick = false;
-
- if (args.Length > 0)
- {
- if (args[0] == "--help")
- {
- Console.WriteLine("Config utility for Anope");
- Console.WriteLine("------------------------");
- Console.WriteLine("Syntax: .\\Config.exe [options]");
- Console.WriteLine("-nocache Ignore settings saved in config.cache");
- Console.WriteLine("-nointro Skip intro (disclaimer, etc)");
- Console.WriteLine("-quick or -q Skip questions, go straight to cmake");
- return 0;
- }
- else if (args[0] == "-nocache")
- IgnoreCache = true;
- else if (args[0] == "-nointro")
- NoIntro = true;
- else if (args[0] == "-quick" || args[0] == "-q")
- DoQuick = true;
- }
-
- ExecutablePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
-
- string AnopeVersion = FindAnopeVersion();
-
- if (!NoIntro && File.Exists(string.Format(@"{0}\.BANNER", ExecutablePath)))
- Console.WriteLine(File.ReadAllText(string.Format(@"{0}\.BANNER", ExecutablePath)).Replace("CURVER", AnopeVersion).Replace("For more options type SOURCE_DIR/Config --help", ""));
-
- Console.WriteLine("Press Enter to begin");
- Console.WriteLine();
- Console.ReadKey();
-
- bool UseCache = false;
-
- if (DoQuick || !IgnoreCache)
- {
- UseCache = LoadCache();
- if (DoQuick && !UseCache)
- {
- Console.WriteLine("Can't find cache file (config.cache), aborting...");
- return 1;
- }
- }
-
- if (!DoQuick)
- {
- List<string> InstallerQuestions = new List<string>()
- {
- "Where do you want Anope to be installed?",
- "Would you like to build using NMake instead of using Visual Studio? [y/n]",
- "Would you like to build a debug version of Anope? [y/n]",
- "Are there any extra include directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra include directories, enter NONE in all caps.",
- "Are there any extra library directories you wish to use?\nYou may only need to do this if CMake is unable to locate missing dependencies without hints.\nSeparate directories with semicolons and use slashes (aka /) instead of backslashes (aka \\).\nIf you need no extra library directories, enter NONE in all caps.",
- "Are there any extra arguments you wish to pass to CMake?\nIf you need no extra arguments to CMake, enter NONE in all caps."
- };
-
- for (int i = 0; i < InstallerQuestions.Count; ++i)
- {
- Console.WriteLine(InstallerQuestions[i]);
- string CacheResponse = null;
- if (UseCache)
- CacheResponse = HandleCache(i);
- string InstallerResponse = Console.ReadLine();
- Console.WriteLine();
-
- if (!string.IsNullOrWhiteSpace(CacheResponse) && string.IsNullOrWhiteSpace(InstallerResponse))
- InstallerResponse = CacheResponse;
-
- // Question 4+ are optional
- if (i < 3 && string.IsNullOrWhiteSpace(InstallerResponse))
- {
- Console.WriteLine("Invalid option");
- --i;
- continue;
- }
-
- switch (i)
- {
- case 0:
- if (!Directory.Exists(InstallerResponse))
- {
- Console.WriteLine("Directory does not exist! Creating directory.");
- Console.WriteLine();
- try
- {
- Directory.CreateDirectory(InstallerResponse);
- InstallDirectory = InstallerResponse;
- }
- catch (Exception e)
- {
- Console.WriteLine("Unable to create directory: " + e.Message);
- --i;
- }
- }
- else if (File.Exists(InstallerResponse + @"\include\services.h"))
- {
- Console.WriteLine("You cannot use the Anope source directory as the target directory!");
- --i;
- }
- else
- InstallDirectory = InstallerResponse;
- break;
- case 1:
- UseNMake = CheckResponse(InstallerResponse);
- break;
- case 2:
- BuildDebug = CheckResponse(InstallerResponse);
- break;
- case 3:
- if (InstallerResponse == "NONE")
- ExtraIncludeDirs = null;
- else
- ExtraIncludeDirs = InstallerResponse;
- break;
- case 4:
- if (InstallerResponse == "NONE")
- ExtraLibDirs = null;
- else
- ExtraLibDirs = InstallerResponse;
- break;
- case 5:
- if (InstallerResponse == "NONE")
- ExtraArguments = null;
- else
- ExtraArguments = InstallerResponse;
- break;
- default:
- break;
- }
- }
- }
-
- Console.WriteLine("Anope will be compiled with the following options:");
- Console.WriteLine("Install directory: {0}", InstallDirectory);
- Console.WriteLine("Generator: {0}", UseNMake ? "nmake" : "Visual Studio");
- Console.WriteLine("Build debug: {0}", BuildDebug ? "Yes" : "No");
- Console.WriteLine("Anope Version: {0}", AnopeVersion);
- Console.WriteLine("Extra Include Directories: {0}", ExtraIncludeDirs);
- Console.WriteLine("Extra Library Directories: {0}", ExtraLibDirs);
- Console.WriteLine("Extra Arguments: {0}", ExtraArguments);
- Console.WriteLine("Press Enter to continue...");
- Console.ReadKey();
-
- SaveCache();
-
- if (!string.IsNullOrWhiteSpace(ExtraIncludeDirs))
- ExtraIncludeDirs = string.Format("-DEXTRA_INCLUDE:STRING={0} ", ExtraIncludeDirs);
- else
- ExtraIncludeDirs = "";
- if (!string.IsNullOrWhiteSpace(ExtraLibDirs))
- ExtraLibDirs = string.Format("-DEXTRA_LIBS:STRING={0} ", ExtraLibDirs);
- else
- ExtraLibDirs = "";
- if (!string.IsNullOrWhiteSpace(ExtraArguments))
- ExtraArguments += " ";
- else
- ExtraArguments = "";
-
- InstallDirectory = "-DINSTDIR:STRING=\"" + InstallDirectory.Replace('\\', '/') + "\" ";
- string Generator = UseNMake ? "-G\"NMake Makefiles\" " : "-G \"Visual Studio 11\" ";
- string Debug = "-DCMAKE_BUILD_TYPE:STRING=" + (BuildDebug ? "DEBUG" : "RELEASE") + " ";
- string cMake = InstallDirectory + Generator + Debug + ExtraIncludeDirs + ExtraLibDirs + ExtraArguments + "\"" + ExecutablePath.Replace('\\', '/') + "\"";
- RunCMake(cMake);
-
- return 0;
- }
- }
-}
|
