diff options
-rw-r--r-- | Anope.cmake | 238 | ||||
-rw-r--r-- | CMakeLists.txt | 54 | ||||
-rw-r--r-- | ReadFile.cmake | 6 | ||||
-rw-r--r-- | lang/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 8 | ||||
-rw-r--r-- | src/core/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/modules/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/protocol/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/tools/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/win32_memory.cpp | 4 |
10 files changed, 209 insertions, 121 deletions
diff --git a/Anope.cmake b/Anope.cmake index 68eae0453..271d40fda 100644 --- a/Anope.cmake +++ b/Anope.cmake @@ -11,22 +11,33 @@ macro(strip_string INPUT_STRING OUTPUT_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 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") + # 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) @@ -101,12 +112,78 @@ macro(remove_list_duplicates LIST) append_to_list(NEW_LIST ${ITEM}) endif(FOUND_ITEM EQUAL -1) endforeach(ITEM) - # replace the old list with the new list + # Replace the old list with the new list set(${LIST} ${NEW_LIST}) endif(CMAKE26_OR_BETTER) endmacro(remove_list_duplicates) ############################################################################### +# remove_item_from_list(<list> <value>) +# +# A macro to handle removing a value from a list, uses list(REMOVE_ITEM) if +# using CMake 2.4.2 or better, otherwise it uses a slower method of creating +# a temporary list and adding every item except the one given. +############################################################################### +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'll create a temporary list + set(NEW_LIST) + # Iterate through the old list + foreach(ITEM ${${LIST}}) + # Check if the current item is the same as the item we are removing, and if it isn't, append it to the list + if(NOT ITEM STREQUAL ${VALUE}) + append_to_list(NEW_LIST ${ITEM}) + endif(NOT ITEM STREQUAL ${VALUE}) + endforeach(ITEM) + # Replace the old list with the new list + set(${LIST} ${NEW_LIST}) + endif(CMAKE242_OR_BETTER) +endmacro(remove_item_from_list) + +############################################################################### +# sort_list(<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) + 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(<filename> <regex> <output variable>) # # A macro to handle reading specific lines from a file, uses file(STRINGS) if @@ -125,7 +202,7 @@ macro(read_from_file FILE REGEX STRINGS) endif(REGEX STREQUAL "") 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) + execute_process(COMMAND ${CMAKE_COMMAND} -DFILE:STRING=${FILE} -P ${Anope_SOURCE_DIR}/ReadFile.cmake ERROR_VARIABLE ALL_STRINGS) # Next we replace all newlines with semicolons string(REGEX REPLACE "\n" ";" ALL_STRINGS ${ALL_STRINGS}) if(REGEX STREQUAL "") @@ -157,19 +234,24 @@ endmacro(read_from_file) macro(extract_include_filename INCLUDE FILENAME) # Strip the leading and trailing spaces from the include line strip_string(${INCLUDE} INCLUDE_STRIPPED) - # 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}") + # 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) @@ -215,48 +297,56 @@ macro(find_includes SRC INCLUDES) else(${DEFINE}) set(VALID_LINE FALSE) endif(${DEFINE}) - # If we found a #ifndef on the line, the same thing as #ifdef is done, except with the checks in the opposite direction - elseif(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(NOT ${DEFINE}) - set(VALID_LINE TRUE) - else(NOT ${DEFINE}) - set(VALUE_LINE FALSE) - endif(NOT ${DEFINE}) - # If we found a #else on the line, we check the last define in the opposite direction - elseif(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(NOT ${LAST_DEF}) - set(VALID_LINE TRUE) - else(NOT ${LAST_DEF}) - set(VALID_LINE FALSE) - endif(NOT ${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}) + 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(NOT ${DEFINE}) set(VALID_LINE TRUE) - else(${LAST_DEF}) - set(VALID_LINE FALSE) - endif(${LAST_DEF}) - endif(LAST_CHECK) - # 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 - elseif(FOUND_ENDIF) - set(VALID_LINE TRUE) - # If we found a #include on the line, add the entire line to the list of includes unless the line isn't valid - elseif(FOUND_INCLUDE) - if(VALID_LINE) - append_to_list(INCLUDES_LIST "${LINE}") - endif(VALID_LINE) + else(NOT ${DEFINE}) + set(VALUE_LINE FALSE) + endif(NOT ${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(NOT ${LAST_DEF}) + set(VALID_LINE TRUE) + else(NOT ${LAST_DEF}) + set(VALID_LINE FALSE) + endif(NOT ${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}) @@ -327,9 +417,7 @@ macro(calculate_depends SRC) 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) + sort_list(HEADERS) # Set the list of full path headers to empty set(HEADERS_FULL) # Iterate through the list of headers diff --git a/CMakeLists.txt b/CMakeLists.txt index b6c8ec2bd..6af50021f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,17 +14,17 @@ project(Anope CXX) enable_language(C) # 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) +if(CMAKE_MINOR_VERSION GREATER 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) +else(CMAKE_MINOR_VERSION GREATER 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) + if(CMAKE_PATCH_VERSION GREATER 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) + else(CMAKE_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(CMAKE_PATCH_VERSION GREATER 1) @@ -32,8 +32,8 @@ else(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) 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) + endif(CMAKE_PATCH_VERSION GREATER 3) +endif(CMAKE_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}) @@ -85,19 +85,23 @@ if(CMAKE_COMPILER_IS_GNUCXX) # 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) - # If the line has the following on it, we hit the end of the list - elseif(LINE STREQUAL "End of search list.") - set(IN_SEARCH FALSE) - # If we are within the block between the above two lines... - elseif(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) - # 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}) + 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) + # 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 @@ -359,10 +363,10 @@ foreach(HEADER ${ALL_HEADERS}) endif(NOT HEADER MATCHES ".*obsolete.*") endforeach(HEADER) # Set the list of headers to be all the non-obsolete ones, then sort the list -set(ALL_HEADERS ${TMP_HEADERS}) -if(CMAKE244_OR_BETTER) - list(SORT ALL_HEADERS) -endif(CMAKE244_OR_BETTER) +if(TMP_HEADERS) + set(ALL_HEADERS ${TMP_HEADERS}) + sort_list(ALL_HEADERS) +endif(TMP_HEADERS) # Preparse step 1: get filenames sans paths # Iterate through the headers @@ -411,9 +415,7 @@ foreach(HEADER ${ALL_HEADERS}) endwhile(HEADERS) # OLD_HEADERS will now contain all headers that the current header relies on, remove duplicate headers from the list and sort the list remove_list_duplicates(OLD_HEADERS) - if(CMAKE244_OR_BETTER) - list(SORT OLD_HEADERS) - endif(CMAKE244_OR_BETTER) + sort_list(OLD_HEADERS) # Set the current header's list of headers to the cleaned up list from above set(${HEADER_FILENAME}_HEADERS ${OLD_HEADERS}) endif(${HEADER_FILENAME}_HEADERS) diff --git a/ReadFile.cmake b/ReadFile.cmake new file mode 100644 index 000000000..205764d01 --- /dev/null +++ b/ReadFile.cmake @@ -0,0 +1,6 @@ +# 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/lang/CMakeLists.txt b/lang/CMakeLists.txt index 5390e6904..46114cafc 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -53,9 +53,7 @@ add_to_cpack_ignored_files("${index_RELATIVE}$") # Find all the *.l files within the current source directory, and sort the list file(GLOB LANG_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.l") -if(CMAKE244_OR_BETTER) - list(SORT LANG_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(LANG_SRCS) # Iterate through the language files foreach(LANG_L ${LANG_SRCS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1cc3d832..9641a4ad2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,15 +4,13 @@ file(GLOB SRC_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(SRC_SRCS ${SRC_SRCS_C} ${SRC_SRCS_CPP}) # If not using Visual Studio, don't include win32_memory.cpp, it's only required by Visual Studio to override it's override of the new/delete operators if(NOT MSVC) - list(REMOVE_ITEM SRC_SRCS win32_memory.cpp) + remove_item_from_list(SRC_SRCS win32_memory.cpp) endif(NOT MSVC) # If not using Windows, don't include windows.cpp, as it's Windows-specific if(NOT WIN32) - list(REMOVE_ITEM SRC_SRCS windows.cpp) + remove_item_from_list(SRC_SRCS windows.cpp) endif(NOT WIN32) -if(CMAKE244_OR_BETTER) - list(SORT SRC_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(SRC_SRCS) # 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(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ba1032f72..7aa474743 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -2,9 +2,7 @@ file(GLOB CORE_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") file(GLOB CORE_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(CORE_SRCS ${CORE_SRCS_C} ${CORE_SRCS_CPP}) -if(CMAKE244_OR_BETTER) - list(SORT CORE_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(CORE_SRCS) # If using Windows, add the MODULE_COMPILE define if(WIN32) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 65959b174..21b35c0b3 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -2,9 +2,7 @@ file(GLOB MODULES_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") file(GLOB MODULES_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(MODULES_SRCS ${MODULES_SRCS_C} ${MODULES_SRCS_CPP}) -if(CMAKE244_OR_BETTER) - list(SORT MODULES_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(MODULES_SRCS) # If using Windows, add the MODULE_COMPILE define if(WIN32) diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt index c903545c3..fda2a9d90 100644 --- a/src/protocol/CMakeLists.txt +++ b/src/protocol/CMakeLists.txt @@ -2,9 +2,7 @@ file(GLOB PROTOCOL_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") file(GLOB PROTOCOL_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(PROTOCOL_SRCS ${PROTOCOL_SRCS_C} ${PROTOCOL_SRCS_CPP}) -if(CMAKE244_OR_BETTER) - list(SORT PROTOCOL_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(PROTOCOL_SRCS) # If using Windows, add the MODULE_COMPILE define if(WIN32) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 6ac5d76a9..286b11945 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -2,9 +2,7 @@ file(GLOB TOOLS_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") file(GLOB TOOLS_SRCS_CPP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") set(TOOLS_SRCS ${TOOLS_SRCS_C} ${TOOLS_SRCS_CPP}) -if(CMAKE244_OR_BETTER) - list(SORT TOOLS_SRCS) -endif(CMAKE244_OR_BETTER) +sort_list(TOOLS_SRCS) # Set all the files to use C++ as well as set their compile flags set_source_files_properties(${TOOLS_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") diff --git a/src/win32_memory.cpp b/src/win32_memory.cpp index ba7826240..9da1b7812 100644 --- a/src/win32_memory.cpp +++ b/src/win32_memory.cpp @@ -11,6 +11,8 @@ * --------------------------------------------------- */ +#ifdef _WIN32 + #include <windows.h> #include <exception> #include <new> @@ -55,3 +57,5 @@ void operator delete[](void *ptr) { HeapFree(GetProcessHeap(), 0, ptr); } + +#endif |