summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/Anope.cmake30
-rw-r--r--modules/CMakeLists.txt153
2 files changed, 68 insertions, 115 deletions
diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake
index 7c9781d6f..640f0ef6b 100644
--- a/cmake/Anope.cmake
+++ b/cmake/Anope.cmake
@@ -83,36 +83,6 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS)
endmacro()
###############################################################################
-# check_functions(<source filename> <output variable set to TRUE on success>)
-#
-# This macro is used in most of the module (sub)directories to calculate the
-# function dependencies for the given source file.
-###############################################################################
-macro(check_functions SRC SUCCESS)
- # Default to true
- set(${SUCCESS} TRUE)
- # Check to see if there are any lines matching: /* RequiredFunctions: [something] */
- file(STRINGS ${SRC} REQUIRED_FUNCTIONS REGEX "/\\*[ \t]*RequiredFunctions:[ \t]*.*[ \t]*\\*/")
- # Iterate through those lines
- foreach(REQUIRED_FUNCTION ${REQUIRED_FUNCTIONS})
- # Strip off the /* RequiredFunctions: and */ from the line
- string(REGEX REPLACE "/\\*[ \t]*RequiredFunctions:[ \t]*([^ \t]*)[ \t]*\\*/" "\\1" REQUIRED_FUNCTION ${REQUIRED_FUNCTION})
- # Replace all commas with semicolons
- string(REGEX REPLACE "," ";" REQUIRED_FUNCTION ${REQUIRED_FUNCTION})
- # Iterate through the functions given
- foreach(FUNCTION ${REQUIRED_FUNCTION})
- # Check if the function exists
- check_function_exists(${REQUIRED_FUNCTION} HAVE_${REQUIRED_FUNCTION})
- # If we don't have the function warn the user and set SUCCESS to FALSE
- if(NOT HAVE_${REQUIRED_FUNCTION})
- message("${SRC} needs function ${REQUIRED_FUNCTION} but we were unable to locate that function!")
- set(${SUCCESS} FALSE)
- endif()
- endforeach()
- endforeach()
-endmacro()
-
-###############################################################################
# add_to_cpack_ignored_files(<item> [TRUE])
#
# A macro to update the environment variable CPACK_IGNORED_FILES which
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index 15d5e3780..a8b3d6cc5 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -29,42 +29,35 @@ macro(build_modules SRC)
set(TEMP_DEPENDENCIES)
# Calculate the library dependencies for the given source file
calculate_libraries(${MODULE_SRC} TEMP_LDFLAGS TEMP_DEPENDENCIES)
- # Reset has_function
- set(HAS_FUNCTION)
- # Check the function dependencies for the given source file
- check_functions(${MODULE_SRC} HAS_FUNCTION)
- # Only continue if this module has all of the required functions
- if(HAS_FUNCTION)
- # 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()
- set(WIN32_MEMORY)
- 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 ${MODULE_SRC})
- # Windows requires this because it's weird
- if(WIN32)
- set(WIN32_NO_LIBS "/nodefaultlib:\"libcmt.lib\" /OPT:NOREF")
- else()
- set(WIN32_NO_LIBS)
- endif()
- set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
- add_dependencies(${SO} ${PROGRAM_NAME})
- if(HAVE_LOCALIZATION)
- add_dependencies(${SO} module_language)
- endif()
- target_link_libraries(${SO} ${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(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
- set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
- elseif(APPLE)
- target_link_libraries(${SO} ${PROGRAM_NAME})
- endif()
- # Set the module to be installed to the module directory under the data directory
- install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
+ # 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()
+ set(WIN32_MEMORY)
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 ${MODULE_SRC})
+ # Windows requires this because it's weird
+ if(WIN32)
+ set(WIN32_NO_LIBS "/nodefaultlib:\"libcmt.lib\" /OPT:NOREF")
+ else()
+ set(WIN32_NO_LIBS)
+ endif()
+ set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${TEMP_LDFLAGS} ${WIN32_NO_LIBS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
+ add_dependencies(${SO} ${PROGRAM_NAME})
+ if(HAVE_LOCALIZATION)
+ add_dependencies(${SO} module_language)
+ endif()
+ target_link_libraries(${SO} ${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(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
+ elseif(APPLE)
+ target_link_libraries(${SO} ${PROGRAM_NAME})
+ endif()
+ # Set the module to be installed to the module directory under the data directory
+ install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
endif()
endif()
endforeach()
@@ -81,66 +74,56 @@ macro(build_subdir)
# 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}")
- set(HAS_FUNCTION TRUE)
-
# Iterate through the source files in the subdirectory
foreach(SRC ${MODULES_SUBDIR_SRCS})
- if(HAS_FUNCTION)
- # Reset linker flags
- set(TEMP_LDFLAGS)
- # Reset extra dependencies
- set(TEMP_DEPENDENCIES)
- # Calculate the library dependencies for the given source file
- calculate_libraries(${SRC} SKIP_LIBRARIES MODULE TEMP_LDFLAGS TEMP_DEPENDENCIES)
- # Check the function dependencies for the given source file
- check_functions(${SRC} HAS_FUNCTION)
+ # Reset linker flags
+ set(TEMP_LDFLAGS)
+ # Reset extra dependencies
+ set(TEMP_DEPENDENCIES)
+ # Calculate the library dependencies for the given source file
+ calculate_libraries(${SRC} SKIP_LIBRARIES MODULE TEMP_LDFLAGS TEMP_DEPENDENCIES)
- # Append this source file's linker flags to the subdirectoy's linker flags, if there are any to append
- if(TEMP_DEPENDENCIES)
- list(APPEND SUBDIR_EXTRA_DEPENDS ${TEMP_DEPENDENCIES})
- endif()
+ # Append this source file's linker flags to the subdirectoy's linker flags, if there are any to append
+ if(TEMP_DEPENDENCIES)
+ list(APPEND SUBDIR_EXTRA_DEPENDS ${TEMP_DEPENDENCIES})
endif()
endforeach()
- # Continue if library and function requirements are met
- if(HAS_FUNCTION)
- # Remove duplicates from the linker flags
- if(SUBDIR_LDFLAGS)
- list(REMOVE_DUPLICATES SUBDIR_LDFLAGS)
- endif()
-
- # Remove duplicates from the extra dependencies
- if(SUBDIR_EXTRA_DEPENDS)
- list(REMOVE_DUPLICATES 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()
- set(WIN32_MEMORY)
- endif()
+ # Remove duplicates from the linker flags
+ if(SUBDIR_LDFLAGS)
+ list(REMOVE_DUPLICATES SUBDIR_LDFLAGS)
+ endif()
- # Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
- add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
- set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${SUBDIR_LDFLAGS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
- add_dependencies(${SO} ${PROGRAM_NAME})
- if(HAVE_LOCALIZATION)
- add_dependencies(${SO} module_language)
- 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 it's version
- if(WIN32)
- target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
- set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
- elseif(APPLE)
- target_link_libraries(${SO} ${PROGRAM_NAME})
- endif()
+ # Remove duplicates from the extra dependencies
+ if(SUBDIR_EXTRA_DEPENDS)
+ list(REMOVE_DUPLICATES SUBDIR_EXTRA_DEPENDS)
+ endif()
- # Set the module to be installed to the module directory under the data directory
- install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
+ # 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()
+ set(WIN32_MEMORY)
+ endif()
+ # Generate the module and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
+ add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
+ set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${SUBDIR_LDFLAGS}" INSTALL_RPATH_USE_LINK_PATH ON BUILD_WITH_INSTALL_RPATH ON)
+ add_dependencies(${SO} ${PROGRAM_NAME})
+ if(HAVE_LOCALIZATION)
+ add_dependencies(${SO} module_language)
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 it's version
+ if(WIN32)
+ target_link_libraries(${SO} ${PROGRAM_NAME} wsock32 Ws2_32 ${WIN32_MEMORY})
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
+ elseif(APPLE)
+ target_link_libraries(${SO} ${PROGRAM_NAME})
+ endif()
+
+ # Set the module to be installed to the module directory under the data directory
+ install(TARGETS ${SO} DESTINATION ${LIB_DIR}/modules)
endmacro()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})