mirror of
https://github.com/anope/anope.git
synced 2026-07-01 20:26:39 +02:00
da8a1c7b60
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2656 5417fbe8-f217-4b02-8779-1006273d7864
56 lines
2.5 KiB
CMake
56 lines
2.5 KiB
CMake
# Find all the *.c and *.cpp files within the current source directory, and sort the list
|
|
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})
|
|
sort_list(PROTOCOL_SRCS)
|
|
|
|
# If using Windows, add the MODULE_COMPILE define
|
|
if(WIN32)
|
|
add_definitions(-DMODULE_COMPILE)
|
|
endif(WIN32)
|
|
|
|
# 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(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
|
|
|
|
# Create an empty list to store extra include directories
|
|
set(EXTRA_INCLUDES)
|
|
|
|
# Iterate through all the source files
|
|
foreach(SRC ${PROTOCOL_SRCS})
|
|
# Convert the source file extension to have a .so extension
|
|
string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
|
|
# Temporary variable for the current source's include directories
|
|
set(TEMP_INCLUDES)
|
|
# Calculate the header file dependencies for the given source file
|
|
calculate_depends(${SRC} TEMP_INCLUDES)
|
|
# If there were some extra include directories, add them to the list
|
|
if(TEMP_INCLUDES)
|
|
append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES})
|
|
endif(TEMP_INCLUDES)
|
|
# 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)
|
|
set(WIN32_MEMORY)
|
|
endif(MSVC)
|
|
# 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 ${SRC})
|
|
set_target_properties(${SO} PROPERTIES LINKER_LANGUAGE CXX PREFIX "" SUFFIX "" LINK_FLAGS "${LDFLAGS}")
|
|
add_dependencies(${SO} ${PROGRAM_NAME})
|
|
# For Windows only, have the module link to the export library of Anope as well as the wsock32 library (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 ${WIN32_MEMORY})
|
|
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
|
|
endif(WIN32)
|
|
# Set the module to be installed to the module directory under the data directory
|
|
install(TARGETS ${SO}
|
|
DESTINATION data/modules
|
|
)
|
|
endforeach(SRC)
|
|
|
|
# If there were extra include directories, remove the duplicates and add the directories to the include path
|
|
if(EXTRA_INCLUDES)
|
|
remove_list_duplicates(EXTRA_INCLUDES)
|
|
include_directories(${EXTRA_INCLUDES})
|
|
endif(EXTRA_INCLUDES)
|