summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-22 22:25:15 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2009-02-22 22:25:15 +0000
commit9123489c32e24ed7fc21c7753ca92aaece452961 (patch)
tree61847686a8c33a55e8d61a27cca83f083d6a98c8
parentfa0d664063d479759073629f5d183a6266a428f0 (diff)
Added Anope.cmake, moving all my CMake macros into it.
Fixed CMake error when CMake older than 2.4.8 is used, there is no 'touch' command in cmake -E, spotted by Adam. Fixed Config to auto-detect CMake and revert to configure if CMake isn't found. Fixed install.js on Windows to show errors in running CMake and detect if there were errors. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2125 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--Anope.cmake219
-rw-r--r--CMakeLists.txt229
-rwxr-xr-xConfig10
-rw-r--r--empty.c0
-rw-r--r--install.js131
5 files changed, 340 insertions, 249 deletions
diff --git a/Anope.cmake b/Anope.cmake
new file mode 100644
index 000000000..6ea65a7e7
--- /dev/null
+++ b/Anope.cmake
@@ -0,0 +1,219 @@
+###############################################################################
+# append_to_list(<list> <args>...)
+#
+# 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(<list> <value> <output variable>)
+#
+# A macro to handle searching within a list, will store the result in the
+# given <output variable>, 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(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
+ # For CMake 2.6.x or better (as well as CMake 2.4.8 or better), we can use the FIND sub-command of list()
+ list(FIND ${LIST} ${ITEM_TO_FIND} ITEM_FOUND)
+ else(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
+ # 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(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
+ # Set the given FOUND variable to the result
+ set(${FOUND} ${ITEM_FOUND})
+endmacro(find_in_list)
+
+###############################################################################
+# remove_list_duplicates(<list>)
+#
+# 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)
+
+###############################################################################
+# read_from_file(<filename> <regex> <output variable>)
+#
+# 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.
+###############################################################################
+macro(read_from_file FILE REGEX STRINGS)
+ if(CMAKE26_OR_BETTER)
+ # For CMake 2.6.x or better, we can just use this function to get the lines that match the given regular expression
+ file(STRINGS ${FILE} RESULT REGEX ${REGEX})
+ else(CMAKE26_OR_BETTER)
+ # For CMake 2.4.x, we need to do this manually, firstly we read the file in
+ file(READ ${FILE} ALL_STRINGS)
+ # Next we replace all newlines with semicolons
+ string(REGEX REPLACE "\n" ";" ALL_STRINGS ${ALL_STRINGS})
+ # 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(CMAKE26_OR_BETTER)
+ # Set the given STRINGS variable to the result
+ set(${STRINGS} ${RESULT})
+endmacro(read_from_file)
+
+###############################################################################
+# extract_include_filename(<line> <output variable> [<optional output variable of quote type>])
+#
+# This function will take a #include line and extract the filename.
+###############################################################################
+macro(extract_include_filename INCLUDE FILENAME)
+ # Detect if there is any trailing whitespace (basically see if the last character is a space or a tab)
+ string(LENGTH ${INCLUDE} INCLUDE_LEN)
+ math(EXPR LAST_CHAR_POS "${INCLUDE_LEN} - 1")
+ string(SUBSTRING ${INCLUDE} ${LAST_CHAR_POS} 1 LAST_CHAR)
+ # Only strip if the last character was a space or a tab
+ if(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
+ # Strip away trailing whitespace from the line
+ string(REGEX REPLACE "[ \t]*$" "" INCLUDE_STRIPPED ${INCLUDE})
+ else(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
+ # Just copy INCLUDE to INCLUDE_STRIPPED so the below code doesn't complain about a lack of INCLUDE_STRIPPED
+ set(INCLUDE_STRIPPED ${INCLUDE})
+ endif(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
+ # Find the filename including the quotes or angle brackets, it should be at the end of the line after whitespace was stripped
+ string(REGEX MATCH "[\"<].*[\">]$" 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)
+ # Get the length of the filename with quotes or angle brackets
+ string(LENGTH ${FILE} FILENAME_LEN)
+ # Subtract 2 from this length, for the quotes or angle brackets
+ math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2")
+ # Overwrite the filename with a version sans quotes or angle brackets
+ string(SUBSTRING ${FILE} 1 ${FILENAME_LEN} FILE)
+ # Set the filename to the the given variable
+ set(${FILENAME} "${FILE}")
+endmacro(extract_include_filename)
+
+###############################################################################
+# calculate_depends(<source filename>)
+#
+# This function is used in most of the src (sub)directories to calculate the
+# header file dependencies for the given source file.
+###############################################################################
+macro(calculate_depends SRC)
+ # Find all the lines in the given source file that have any form of #include on them, regardless of whitespace
+ read_from_file(${SRC} "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$" 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)
+ # Append the filename to the list of headers
+ append_to_list(HEADERS ${FILENAME})
+ endforeach(INCLUDE)
+ # Set the list of new headers to empty (this will store all the headers that the above list depends on)
+ set(NEW_HEADERS)
+ # Iterate through the list of headers
+ foreach(HEADER ${HEADERS})
+ # If the current header has it's own headers to depend on, append those to the list of new headers
+ if(${HEADER}_HEADERS)
+ append_to_list(NEW_HEADERS ${${HEADER}_HEADERS})
+ endif(${HEADER}_HEADERS)
+ endforeach(HEADER)
+ # If there were new headers, append them to the list of headers
+ if(NEW_HEADERS)
+ append_to_list(HEADERS ${NEW_HEADERS})
+ endif(NEW_HEADERS)
+ # If after all the above there is a list of header, we'll process them, converting them to full paths
+ if(HEADERS)
+ # Remove duplicate headers from the list and sort the list
+ remove_list_duplicates(HEADERS)
+ if(CMAKE244_OR_BETTER)
+ list(SORT HEADERS)
+ endif(CMAKE244_OR_BETTER)
+ # Set the list of full path headers to empty
+ set(HEADERS_FULL)
+ # Iterate through the list of headers
+ foreach(HEADER ${HEADERS})
+ # Append the full path of the header to the full path headers list
+ append_to_list(HEADERS_FULL ${${HEADER}_FULLPATH})
+ endforeach(HEADER)
+ # Set the given source file to depend on the headers given
+ set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS_FULL}")
+ endif(HEADERS)
+endmacro(calculate_depends)
+
+###############################################################################
+# add_to_cpack_ignored_files(<item> [TRUE])
+#
+# A macro to update the environment variable CPACK_IGNORED_FILES which
+# contains a list of files for CPack to ignore. If the optional 2nd argument
+# of TRUE is given, periods will be converted to \\. for CPack.
+###############################################################################
+macro(add_to_cpack_ignored_files ITEM)
+ # Temporary copy of the orignal item
+ set(REAL_ITEM "${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)
+ # 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})
+ set(ENV{CPACK_IGNORED_FILES} "${REAL_ITEM}")
+ endif(DEFINED ENV{CPACK_IGNORED_FILES})
+endmacro(add_to_cpack_ignored_files)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32f66158e..f6bc6eb93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,60 +13,32 @@ endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR} AND NOT W
project(Anope CXX)
enable_language(C)
-# A macro to handle appending to lists
-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)
-
-# A macro to handle searching within a list
-macro(find_in_list LIST ITEM_TO_FIND FOUND)
- if(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
- # For CMake 2.6.x or better (as well as CMake 2.4.8 or better), we can use the FIND sub-command of list()
- list(FIND ${LIST} ${ITEM_TO_FIND} ITEM_FOUND)
- else(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
- # 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 that we a temporary boolean
- 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})
- math(EXPR POS "${POS} + 1")
- endforeach(ITEM)
- endif(CMAKE26_OR_BETTER OR ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.7)
- # Set the given FOUND variable to the result
- set(${FOUND} ${ITEM_FOUND})
-endmacro(find_in_list)
-
-# A macro to handle removing duplicates from a list
-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)
+# Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does
+if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
+ set(CMAKE26_OR_BETTER TRUE)
+ set(CMAKE244_OR_BETTER TRUE)
+ set(CMAKE242_OR_BETTER TRUE)
+else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
+ set(CMAKE26_OR_BETTER FALSE)
+ # Also detect if we are using CMake 2.4.4 or better, the CheckCXXCompilerFlag module is non-existant in earlier versions
+ if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.3)
+ set(CMAKE244_OR_BETTER TRUE)
+ set(CMAKE242_OR_BETTER TRUE)
+ else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.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(CMAKE_PATCH_VERSION GREATER 1)
+ set(CMAKE242_OR_BETTER TRUE)
+ else(CMAKE_PATCH_VERSION GREATER 1)
+ set(CMAKE242_OR_BETTER FALSE)
+ endif(CMAKE_PATCH_VERSION GREATER 1)
+ endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.3)
+endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.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})
+
+include(Anope)
# Start with empty defaults for library and include directories, to be used by GNU compilers only
set(DEFAULT_LIBRARY_DIRS)
@@ -97,10 +69,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# Remove duplicate entries from the list
remove_list_duplicates(DEFAULT_LIBRARY_DIRS)
# Next, we look for the compiler's default include directories
- # Create an empty temporary file
- execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/empty.c)
# Run the command to find the default include directories
- execute_process(COMMAND ${CMAKE_C_COMPILER} -v -x c++ -E ${CMAKE_CURRENT_BINARY_DIR}/empty.c ERROR_VARIABLE LINES OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -v -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/empty.c ERROR_VARIABLE LINES OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE)
# Convert the new lines to semicolons
string(REGEX REPLACE "\n" ";" LINES ${LINES})
# Temporary variable saying if we are in the search list or not
@@ -127,8 +97,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endforeach(LINE)
# Remove duplicate entries from the list
remove_list_duplicates(DEFAULT_INCLUDE_DIRS)
- # Delete the temporary file
- execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/empty.c)
endif(CMAKE_COMPILER_IS_GNUCXX)
# 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
@@ -162,28 +130,6 @@ if(MSVC)
endif(WSDK2008_PATH STREQUAL "/registry")
endif(MSVC)
-# Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does
-if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
- set(CMAKE26_OR_BETTER TRUE)
- set(CMAKE244_OR_BETTER TRUE)
- set(CMAKE242_OR_BETTER TRUE)
-else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
- set(CMAKE26_OR_BETTER FALSE)
- # Also detect if we are using CMake 2.4.4 or better, the CheckCXXCompilerFlag module is non-existant in earlier versions
- if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.3)
- set(CMAKE244_OR_BETTER TRUE)
- set(CMAKE242_OR_BETTER TRUE)
- else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.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(CMAKE_PATCH_VERSION GREATER 1)
- set(CMAKE242_OR_BETTER TRUE)
- else(CMAKE_PATCH_VERSION GREATER 1)
- set(CMAKE242_OR_BETTER FALSE)
- endif(CMAKE_PATCH_VERSION GREATER 1)
- endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} GREATER 2.4.3)
-endif(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
-
# 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 prior to calling PROJECT()
@@ -342,32 +288,6 @@ if(CMAKE26_OR_BETTER)
endif(LDFLAGS)
endif(CMAKE26_OR_BETTER)
-# A macro to handle reading specific lines from a file
-macro(read_from_file FILE REGEX STRINGS)
- if(CMAKE26_OR_BETTER)
- # For CMake 2.6.x or better, we can just use this function to get the lines that match the given regular expression
- file(STRINGS ${FILE} RESULT REGEX ${REGEX})
- else(CMAKE26_OR_BETTER)
- # For CMake 2.4.x, we need to do this manually, firstly we read the file in
- file(READ ${FILE} ALL_STRINGS)
- # Next we replace all newlines with semicolons
- string(REGEX REPLACE "\n" ";" ALL_STRINGS ${ALL_STRINGS})
- # 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(CMAKE26_OR_BETTER)
- # Set the given STRINGS variable to the result
- set(${STRINGS} ${RESULT})
-endmacro(read_from_file)
-
# Search for the following programs
find_program(GREP grep)
find_program(SH sh)
@@ -440,32 +360,6 @@ if(CMAKE244_OR_BETTER)
list(SORT ALL_HEADERS)
endif(CMAKE244_OR_BETTER)
-# This function will take a #include line and extract the filename minus the quotes
-macro(extract_include_filename INCLUDE FILENAME)
- # Detect if there is any trailing whitespace (basically see if the last character is a space or a tab)
- string(LENGTH ${INCLUDE} INCLUDE_LEN)
- math(EXPR LAST_CHAR_POS "${INCLUDE_LEN} - 1")
- string(SUBSTRING ${INCLUDE} ${LAST_CHAR_POS} 1 LAST_CHAR)
- # Only strip if the last character was a space or a tab
- if(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- # Strip away trailing whitespace from the line
- string(REGEX REPLACE "[ \t]*$" "" INCLUDE_STRIPPED ${INCLUDE})
- else(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- # Just copy INCLUDE to INCLUDE_STRIPPED so the below code doesn't complain about a lack of INCLUDE_STRIPPED
- set(INCLUDE_STRIPPED ${INCLUDE})
- endif(LAST_CHAR STREQUAL " " OR LAST_CHAR STREQUAL "\t")
- # Find the filename including the quotes, it should be at the end of the line after whitespace was stripped
- string(REGEX MATCH "\".*\"$" FILE ${INCLUDE_STRIPPED})
- # Get the length of the filename with quotes
- string(LENGTH ${FILE} FILENAME_LEN)
- # Subtract 2 from this length, for the quotes
- math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2")
- # Overwrite the filename with a version sans quotes
- string(SUBSTRING ${FILE} 1 ${FILENAME_LEN} FILE)
- # Set the filename to the the given variable
- set(${FILENAME} "${FILE}")
-endmacro(extract_include_filename)
-
# Preparse step 1: get filenames sans paths
# Iterate through the headers
foreach(HEADER ${ALL_HEADERS})
@@ -527,68 +421,6 @@ set(language.h_FULLPATH ${Anope_BINARY_DIR}/lang/language.h)
set(sysconf.h_FULLPATH ${Anope_BINARY_DIR}/include/sysconf.h)
set(version.h_FULLPATH ${Anope_BINARY_DIR}/include/version.h)
-# This function is used in most of the src (sub)directories to calculate the header file dependencies for the given source file
-macro(calculate_depends SRC)
- # Find all the lines in the given source file that have any form of #include on them, regardless of whitespace
- read_from_file(${SRC} "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$" 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)
- # Append the filename to the list of headers
- append_to_list(HEADERS ${FILENAME})
- endforeach(INCLUDE)
- # Set the list of new headers to empty (this will store all the headers that the above list depends on)
- set(NEW_HEADERS)
- # Iterate through the list of headers
- foreach(HEADER ${HEADERS})
- # If the current header has it's own headers to depend on, append those to the list of new headers
- if(${HEADER}_HEADERS)
- append_to_list(NEW_HEADERS ${${HEADER}_HEADERS})
- endif(${HEADER}_HEADERS)
- endforeach(HEADER)
- # If there were new headers, append them to the list of headers
- if(NEW_HEADERS)
- append_to_list(HEADERS ${NEW_HEADERS})
- endif(NEW_HEADERS)
- # If after all the above there is a list of header, we'll process them, converting them to full paths
- if(HEADERS)
- # Remove duplicate headers from the list and sort the list
- remove_list_duplicates(HEADERS)
- if(CMAKE244_OR_BETTER)
- list(SORT HEADERS)
- endif(CMAKE244_OR_BETTER)
- # Set the list of full path headers to empty
- set(HEADERS_FULL)
- # Iterate through the list of headers
- foreach(HEADER ${HEADERS})
- # Append the full path of the header to the full path headers list
- append_to_list(HEADERS_FULL ${${HEADER}_FULLPATH})
- endforeach(HEADER)
- # Set the given source file to depend on the headers given
- set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS_FULL}")
- endif(HEADERS)
-endmacro(calculate_depends)
-
-# A macro to update the environment variable CPACK_IGNORED_FILES which contains a list of files for CPack to ignore
-macro(add_to_cpack_ignored_files ITEM)
- # Temporary copy of the orignal item
- set(REAL_ITEM "${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)
- # 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})
- set(ENV{CPACK_IGNORED_FILES} "${REAL_ITEM}")
- endif(DEFINED ENV{CPACK_IGNORED_FILES})
-endmacro(add_to_cpack_ignored_files)
-
# 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\;.svn\;CMakeFiles\;sysconf.h$\;Makefile.inc$\;config.log\;config.status\;build\;autom4te.cache" TRUE)
# Add the files we don't want the periods converted for
@@ -639,8 +471,6 @@ endif(WIN32)
# Only process the CPack section if we have CPack
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
- # Override the module include path to include our directory, as we are using our own version of the NSIS template
- set(CMAKE_MODULE_PATH ${Anope_SOURCE_DIR})
# Various options for CPack
set(CPACK_PACKAGE_NAME "Anope IRC Services")
set(CPACK_PACKAGE_VENDOR "Anope Team")
@@ -663,17 +493,18 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
"bin\\\\anope.bat\\\" \\\"-debug -nofork" "Anope IRC Services (Debug and Window Logging)"
"bin\\\\anope.bat\\\" \\\"-nofork" "Anope IRC Services (Window Logging)"
"bin\\\\anope.bat\\\" \\\"-nothird" "Anope IRC Services (No Third Party Modules)"
- "http://www.anope.org" "Anope Web Site"
+ "http://www.anope.org/" "Anope Web Site"
)
# The following doesn't work, but a bug report has been filed about it
#set(CPACK_CREATE_DESKTOP_LINK_${SERVICES_BINARY} TRUE)
set(CPACK_NSIS_MUI_ICON "${Anope_SOURCE_DIR}/src\\\\anope-icon.ico")
set(CPACK_NSIS_MUI_UNIICON "${Anope_SOURCE_DIR}/src\\\\anope-icon.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME "${SERVICES_BINARY}")
- set(CPACK_NSIS_URL_INFO_ABOUT "http://www.anope.org")
+ set(CPACK_NSIS_URL_INFO_ABOUT "http://www.anope.org/")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")
endif(WIN32)
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)
diff --git a/Config b/Config
index 9ac194e65..1c3058d0b 100755
--- a/Config
+++ b/Config
@@ -157,6 +157,11 @@ USE_RUN_CC_PL="no"
CAN_QUICK="no"
SOURCE_DIR=`dirname $0`
+which cmake > /dev/null
+if [ $? -ne 0 ] ; then
+ BUILD_SYSTEM="configure"
+fi
+
###########################################################################
# Check out the options
###########################################################################
@@ -248,6 +253,11 @@ done
BUILD_SYSTEM=$INPUT
echo ""
+if [ "$SOURCE_DIR" != "." -a "$BUILD_SYSTEM" = "configure" ] ; then
+ echo "You can not use configure unless you are in the same folder as Config!"
+ exit 0
+fi
+
ok=0
echo "In what directory do you want the binaries to be installed?"
while [ $ok -eq 0 ] ; do
diff --git a/empty.c b/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/empty.c
diff --git a/install.js b/install.js
index 455d75e4b..608dcd6a1 100644
--- a/install.js
+++ b/install.js
@@ -26,25 +26,27 @@ var installerQuestions = [
'short' : 'Install directory:',
'default_answer' : '',
'store_answer' : function(answer) {
- if (!answer) {
+ if (!answer)
+ {
WScript.Echo("You must give a directory!\n");
return false;
}
- if (!fso.FolderExists(answer)) {
- if (fso.FileExists(answer)) {
+ if (!fso.FolderExists(answer))
+ {
+ if (fso.FileExists(answer))
+ {
WScript.Echo(answer + " exists, but is not a directory!\n");
return false;
}
WScript.Echo(answer + " does not exist. Create it ([yes]/no)?\n");
var inputValue = InstallerInput().toLowerCase();
- if (!inputValue) {
+ if (!inputValue)
inputValue = 'yes';
- }
- if (inputValue != 'no') {
+ if (inputValue != 'no')
fso.CreateFolder(answer);
- }
}
- else if (fso.FileExists(answer + '\\include\\services.h')) {
+ else if (fso.FileExists(answer + '\\include\\services.h'))
+ {
WScript.Echo("You cannot use the Anope source directory as a target directory.\n");
return false;
}
@@ -75,8 +77,10 @@ var installerQuestions = [
return true;
},
'cmake_argument' : function() {
- if (installerResponses['Use NMake'] == 'yes') return '-G"NMake Makefiles"';
- else return '';
+ if (installerResponses['Use NMake'] == 'yes')
+ return '-G"NMake Makefiles"';
+ else
+ return '';
}
},
{
@@ -94,9 +98,12 @@ var installerQuestions = [
return true;
},
'cmake_argument' : function() {
- if (installerResponses['Debug'] == 'msvc') return '';
- else if (installerResponses['Debug'] == 'yes') return '-DCMAKE_BUILD_TYPE:STRING=DEBUG';
- else return '-DCMAKE_BUILD_TYPE:STRING=RELEASE';
+ if (installerResponses['Debug'] == 'msvc')
+ return '';
+ else if (installerResponses['Debug'] == 'yes')
+ return '-DCMAKE_BUILD_TYPE:STRING=DEBUG';
+ else
+ return '-DCMAKE_BUILD_TYPE:STRING=RELEASE';
}
},
{
@@ -115,8 +122,10 @@ var installerQuestions = [
return true;
},
'cmake_argument' : function() {
- if (installerResponses['Visual Studio 2008'] == 'yes') return '-G"Visual Studio 9 2008"';
- else return '';
+ if (installerResponses['Visual Studio 2008'] == 'yes')
+ return '-G"Visual Studio 9 2008"';
+ else
+ return '';
}
},
];
@@ -137,71 +146,78 @@ var ScriptPath = WScript.ScriptFullName.substr(0, WScript.ScriptFullName.length
var fso = WScript.CreateObject('Scripting.FileSystemObject');
var x, y, z;
-if (fso.FileExists(ScriptPath + '.BANNER')) {
+if (fso.FileExists(ScriptPath + '.BANNER'))
+{
var bannerStream = fso.OpenTextFile(ScriptPath + '.BANNER');
var bannerText = bannerStream.ReadAll();
bannerStream.close();
- for (x in bannerReplacements) {
+ for (x in bannerReplacements)
+ {
var thisReplacement = bannerReplacements[x];
bannerText = bannerText.replace(thisReplacement['findtext'], thisReplacement['replacement']);
}
WScript.Echo(bannerText + "\n");
}
-else {
+else
WScript.Echo("ERROR: Cannot find banner file!\n");
-}
WScript.Echo('Press Enter to Begin...');
InstallerInput();
WScript.Echo('');
-for (x in installerQuestions) {
+for (x in installerQuestions)
+{
var thisQuestion = installerQuestions[x];
var validResponse = false;
var validOpts = new Array();
- if (thisQuestion.short == 'Build debug?' && installerResponses['Use NMake'] == 'no') {
+ if (thisQuestion.short == 'Build debug?' && installerResponses['Use NMake'] == 'no')
+ {
installerResponses['Debug'] = 'msvc';
continue;
}
- if (thisQuestion.short == 'Using Visual Studio 2008?' && installerResponses['Debug'] != 'msvc') {
+ if (thisQuestion.short == 'Using Visual Studio 2008?' && installerResponses['Debug'] != 'msvc')
+ {
installerResponses['Visual Studio 2008'] = 'no';
continue;
}
- while (!validResponse) {
- for (y in thisQuestion.question) {
+ while (!validResponse)
+ {
+ for (y in thisQuestion.question)
+ {
var qLine = thisQuestion.question[y];
WScript.Echo(qLine);
}
WScript.Echo('');
var choiceLine = '';
- if (thisQuestion.options) {
- for (y in thisQuestion.options) {
+ if (thisQuestion.options)
+ {
+ for (y in thisQuestion.options)
+ {
choiceLine += thisQuestion.options[y] + ', ';
validOpts[thisQuestion.options[y]] = true;
}
choiceLine = choiceLine.substring(0, choiceLine.length - 2);
WScript.Echo('Available Options: ' + choiceLine);
}
- if (thisQuestion.default_answer) WScript.Echo('Default Answer: ' + thisQuestion.default_answer + "\n");
+ if (thisQuestion.default_answer)
+ WScript.Echo('Default Answer: ' + thisQuestion.default_answer + "\n");
WScript.Echo(thisQuestion.short);
var inputValue = InstallerInput().toLowerCase();
- if (!inputValue) {
+ if (!inputValue)
inputValue = thisQuestion.default_answer;
- }
- if (choiceLine && !validOpts[inputValue]) {
+ if (choiceLine && !validOpts[inputValue])
WScript.Echo("ERROR: Invalid option '" + inputValue + "'\n");
- }
- else if (thisQuestion.store_answer(inputValue)) {
+ else if (thisQuestion.store_answer(inputValue))
validResponse = true;
- }
}
WScript.Echo('');
}
WScript.Echo("\nAnope will be compiled with the following options:\n");
-for (x in installerResponses) {
+for (x in installerResponses)
+{
var thisResponse = installerResponses[x];
WScript.Echo("\t" + x + ":\t\t[" + thisResponse.toUpperCase() + "]");
}
@@ -210,7 +226,8 @@ WScript.Echo("\nTo continue, please press Enter...");
InstallerInput();
var cmake = 'cmake';
-for (x in installerQuestions) {
+for (x in installerQuestions)
+{
var thisQuestion = installerQuestions[x];
cmake += ' ' + thisQuestion.cmake_argument();
}
@@ -220,50 +237,64 @@ WScript.Echo(cmake + "\n");
var shell = WScript.CreateObject('WScript.Shell');
var cmake_shell = shell.exec('%comspec% /c ' + cmake);
-while (!cmake_shell.StdOut.AtEndOfStream) {
- var strLine = cmake_shell.StdOut.ReadLine();
- WScript.Echo(strLine);
+while (!cmake_shell.Status)
+{
+ if (!cmake_shell.StdOut.AtEndOfStream)
+ WScript.Echo(cmake_shell.StdOut.ReadLine());
+ else if (!cmake_shell.StdErr.AtEndOfStream)
+ WScript.Echo(cmake_shell.StdErr.ReadLine());
}
-if (installerResponses['Use NMake'] == 'yes') WScript.Echo("\nTo compile Anope, run 'nmake'. To install, run 'nmake install'.\n");
-else WScript.Echo("\nTo compile Anope, open Anope.sln and build the solution. To install,\ndo a build on the INSTALL project.\n");
-WScript.Echo("If you update Anope, you should run this script again to ensure\nall available options are set.\n");
+if (cmake_shell.ExitCode == 0)
+{
+ if (installerResponses['Use NMake'] == 'yes') WScript.Echo("\nTo compile Anope, run 'nmake'. To install, run 'nmake install'.\n");
+ else WScript.Echo("\nTo compile Anope, open Anope.sln and build the solution. To install,\ndo a build on the INSTALL project.\n");
+ WScript.Echo("If you update Anope, you should run this script again to ensure\nall available options are set.\n");
+}
+else
+ WScript.Echo("\nThere was an error attempting to run CMake! Check the above error message,\nand contact the Anope team if you are unsure how to proceed.\n");
// -----------------------------------------------------------------
// Functions
function FindAnopeVersion() {
- if (!fso.FileExists(ScriptPath + 'version.log')) {
+ if (!fso.FileExists(ScriptPath + 'version.log'))
+ {
anopeVersion = 'Unknown';
return;
}
var versionLog = fso.OpenTextFile(ScriptPath + 'version.log');
- while (!versionLog.atEndOfStream) {
+ while (!versionLog.atEndOfStream)
+ {
var versionLine = versionLog.readline();
var thisMatch = versionLine.replace('\n', '');
- while (thisMatch.match(/\"/g)) {
+ while (thisMatch.match(/\"/g))
thisMatch = thisMatch.replace('"', '');
- }
versionLine = thisMatch;
- if (versionLine.match(/VERSION_MAJOR=/g)) {
+ if (versionLine.match(/VERSION_MAJOR=/g))
+ {
vMaj = versionLine.replace('VERSION_MAJOR=', '');
continue;
}
- if (versionLine.match(/VERSION_MINOR=/g)) {
+ if (versionLine.match(/VERSION_MINOR=/g))
+ {
vMin = versionLine.replace('VERSION_MINOR=', '');
continue;
}
- if (versionLine.match(/VERSION_PATCH=/g)) {
+ if (versionLine.match(/VERSION_PATCH=/g))
+ {
vPat = versionLine.replace('VERSION_PATCH=', '');
continue;
}
- if (versionLine.match(/VERSION_EXTRA=/g)) {
+ if (versionLine.match(/VERSION_EXTRA=/g))
+ {
vExtra = versionLine.replace('VERSION_EXTRA=', '');
continue;
}
- if (versionLine.match(/VERSION_BUILD=/g)) {
+ if (versionLine.match(/VERSION_BUILD=/g))
+ {
vBuild = versionLine.replace('VERSION_BUILD=', '');
continue;
}