summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt201
-rw-r--r--src/bin/CMakeLists.txt5
-rw-r--r--src/core/CMakeLists.txt73
-rw-r--r--src/init.c6
-rw-r--r--src/main.c77
-rw-r--r--src/modulemanager.cpp6
-rw-r--r--src/modules.c7
-rw-r--r--src/modules/CMakeLists.txt67
-rw-r--r--src/protocol/CMakeLists.txt67
-rw-r--r--src/tools/CMakeLists.txt68
-rw-r--r--src/win32.rc.cmake6
11 files changed, 161 insertions, 422 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 53b2f10ca..4872e46f2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,196 +1,69 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
-set(SRC_SRCS actions.c base64.c bots.cpp botserv.c channels.c chanserv.c
- commands.c compat.c config.c configreader.cpp datafiles.c encrypt.c events.c
- hashcomp.cpp helpserv.c hostserv.c init.c ircd.c language.c log.c mail.c
- main.c memory.c memoserv.c messages.c misc.c module.cpp modulemanager.cpp
- modules.c news.c nickserv.c operserv.c process.c send.c servers.c sessions.c
- slist.c sockutil.c timeout.c users.c)
-if(WIN32 AND MSVC)
- set(SRC_SRCS ${SRC_SRCS} win32_memory.cpp)
-endif(WIN32 AND MSVC)
+# Find all the *.c and *.cpp files within the current source directory, and sort the list
+file(GLOB SRC_SRCS_C RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
+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)
+endif(NOT MSVC)
list(SORT 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}")
-#add_custom_target(src_srcs DEPENDS ${SRC_SRCS})
-
-set(actions.c_HEADERS services.h)
-set(base64.c_HEADERS services.h)
-set(bots.cpp_HEADERS services.h)
-set(botserv.c_HEADERS services.h pseudo.h)
-set(channels.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
-set(chanserv.c_HEADERS services.h pseudo.h)
-set(commands.c_HEADERS services.h commands.h ${Anope_BINARY_DIR}/lang/language.h)
-set(compat.c_HEADERS services.h)
-set(config.c_HEADERS services.h configreader.h hashcomp.h)
-set(configreader.cpp_HEADERS services.h)
-set(datafiles.c_HEADERS services.h datafiles.h)
-set(encrypt.c_HEADERS services.h encrypt.h)
-set(events.c_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
-set(hashcomp.c_HEADERS hashcomp.h)
-set(helpserv.c_HEADERS services.h pseudo.h)
-set(hostserv.c_HEADERS services.h pseudo.h)
-set(init.c_HEADERS services.h pseudo.h)
-set(ircd.c_HEADERS services.h extern.h)
-set(language.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
-set(log.c_HEADERS services.h pseudo.h)
-set(mail.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h)
-set(main.c_HEADERS services.h timeout.h ${Anope_BINARY_DIR}/include/version.h datafiles.h modules.h)
-set(memory.c_HEADERS services.h)
-set(memoserv.c_HEADERS services.h pseudo.h)
-set(messages.c_HEADERS services.h messages.h ${Anope_BINARY_DIR}/lang/language.h)
-set(misc.c_HEADERS services.h ${Anope_BINARY_DIR}/lang/language.h hashcomp.h)
-set(module.cpp_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
-set(modulemanager.cpp_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
-set(modules.c_HEADERS modules.h ${Anope_BINARY_DIR}/lang/language.h ${Anope_BINARY_DIR}/include/version.h)
-set(news.c_HEADERS services.h pseudo.h)
-set(nickserv.c_HEADERS services.h pseudo.h)
-set(operserv.c_HEADERS services.h pseudo.h)
-set(process.c_HEADERS services.h messages.h modules.h)
-set(send.c_HEADERS services.h)
-set(servers.c_HEADERS services.h)
-set(sessions.c_HEADERS services.h pseudo.h)
-set(slist.c_HEADERS services.h slist.h)
-set(sockutil.c_HEADERS services.h)
-set(timeout.c_HEADERS services.h pseudo.h)
-set(users.c_HEADERS services.h)
-
-set(${PROGRAM_NAME}_HEADERS)
-
+# Iterate through all the source files
foreach(SRC ${SRC_SRCS})
- #string(REGEX REPLACE "\\." "_" SRC_TARGET ${SRC})
- #string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
- #string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
- #string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
- #string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
- #set(SRC_SRCS_FULL ${SRC_SRCS_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
- #set(SRC_OBJS ${SRC_OBJS} ${BUILD_DIR}/${OBJ})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
- # MAIN_DEPENDENCY ${SRC}
- #)
- #add_custom_target(src_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
- #add_custom_target(src_${SRC_TARGET} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
- #add_dependencies(src_srcs src_${SRC_TARGET})
- #set(HEADERS)
- #if(${SRC}_HEADERS)
- # foreach(HEADER ${${SRC}_HEADERS})
- # string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- # string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
- # if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${HEADER})
- # else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- # endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # endforeach(HEADER)
- #endif(${SRC}_HEADERS)
-
- #file(STRINGS ${SRC} INCLUDES REGEX "^[ \t]*#[ \t]*include[ \t]*\".*\"[ \t]*$")
- ##message(STATUS "${SRC}'s includes: ${INCLUDES}")
- ##get_filename_component(HEADER_FILENAME ${HEADER} NAME)
- #set(HEADERS)
- #foreach(INCLUDE ${INCLUDES})
- # string(STRIP ${INCLUDE} INCLUDE)
- # string(REGEX MATCH "\".*\"$" FILENAME ${INCLUDE})
- # string(LENGTH ${FILENAME} FILENAME_LEN)
- # math(EXPR FILENAME_LEN "${FILENAME_LEN} - 2")
- # string(SUBSTRING ${FILENAME} 1 ${FILENAME_LEN} FILENAME)
- # #message(STATUS "INCLUDE FILENAME: ${FILENAME}")
- # #list(APPEND ${HEADER_FILENAME}_HEADERS ${FILENAME})
- # list(APPEND HEADERS ${FILENAME})
- #endforeach(INCLUDE)
- ##message(STATUS "${SRC}'s HEADERS: ${HEADERS}")
- #set(NEW_HEADERS)
- #foreach(HEADER ${HEADERS})
- # #message(STATUS "HEADER: ${HEADER} - ${HEADERS}_HEADERS: ${${HEADERS}_HEADERS}")
- # if(${HEADER}_HEADERS)
- # list(APPEND NEW_HEADERS ${${HEADER}_HEADERS})
- # endif(${HEADER}_HEADERS)
- #endforeach(HEADER)
- #if(NEW_HEADERS)
- # list(APPEND HEADERS ${NEW_HEADERS})
- #endif(NEW_HEADERS)
- #list(REMOVE_DUPLICATES HEADERS)
- #list(SORT HEADERS)
- #if(HEADERS)
- # #message(STATUS "${SRC}'s HEADERS after NEW_HEADERS: ${HEADERS}")
- # set(HEADERS_FULL)
- # foreach(HEADER ${HEADERS})
- # get_filename_component(HEADER_FILENAME ${HEADER} NAME)
- # list(APPEND HEADERS_FULL ${${HEADER_FILENAME}_FULLPATH})
- # endforeach(HEADER)
- # #message(STATUS "${SRC}'s HEADERS_FULL: ${HEADERS_FULL}")
- # set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS_FULL}")
- # list(APPEND ${PROGRAM_NAME}_HEADERS ${HEADERS_FULL})
- #endif(HEADERS)
+ # Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
- get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
- message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
-
endforeach(SRC)
-#add_custom_target(src_srcs DEPENDS ${SRC_SRCS_FULL})
-
-#add_custom_command(OUTPUT ${BUILD_DIR}/services
-# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${SRC_OBJS} -o ${BUILD_DIR}/services
-# DEPENDS ${SRC_OBJS}
-#)
-#add_custom_target(src_services ALL DEPENDS ${BUILD_DIR}/services)
-#add_custom_target(src_services DEPENDS ${BUILD_DIR}/services)
-#add_custom_target(build ALL)
-#add_dependencies(build language headers src_services)
+# Under Windows, we also include a resource file to the build
if(WIN32)
+ # Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc LANGUAGE RC)
- set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
+ # Add the resource file to the list of sources
+ list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
+ # For MinGW, we have to change the compile flags
if(MINGW)
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
- #add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/win32.obj
- # COMMAND ${CMAKE_RC_COMPILER} -DMINGW -I${Anope_SOURCE_DIR}/include -o ${CMAKE_CURRENT_BINARY_DIR}/win32.obj ${CMAKE_CURRENT_BINARY_DIR}/win32.rc
- # MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/win32.rc
- #)
- #set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.obj)
+ set(RC_CFLAGS "-DMINGW -Ocoff -I${Anope_SOURCE_DIR}/include")
+ # If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler
+ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG")
+ endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "${RC_CFLAGS}")
+ # For anything else, assumingly Visual Studio at this point, use a different set of compile flags
else(MINGW)
- #set(SRC_SRCS ${SRC_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/win32.rc)
- #set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc LANGUAGE RC)
- set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "/i${Anope_SOURCE_DIR}/include")
+ set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
endif(MINGW)
- message(STATUS "CMAKE_RC_OUTPUT_EXTENSION: ${CMAKE_RC_OUTPUT_EXTENSION}")
endif(WIN32)
+
+# 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})
-set(SERVICES_LDFLAGS "${LDFLAGS}")
-if(WIN32 AND MSVC)
- set(SERVICES_LDFLAGS "${SERVICES_LDFLAGS} /FIXED:NO")
-endif(WIN32 AND MSVC)
-set_target_properties(${PROGRAM_NAME} PROPERTIES LINK_FLAGS "${SERVICES_LDFLAGS}")
- set_target_properties(${PROGRAM_NAME} PROPERTIES ENABLE_EXPORTS ON)
+set_target_properties(${PROGRAM_NAME} PROPERTIES LINK_FLAGS "${LDFLAGS}" ENABLE_EXPORTS ON)
+# On Windows, also link Anope to the wsock32 library, as well as set the version
if(WIN32)
target_link_libraries(${PROGRAM_NAME} wsock32)
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
-#set_target_properties(services PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
+# Building the Anope executable requires the language files to be compiled first as well as the version.h header to be generated
add_dependencies(${PROGRAM_NAME} language headers)
+# Get the filename of the Anope executable as it is in on this system
get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
-file(RELATIVE_PATH SERVICES_BINARY ${CMAKE_CURRENT_BINARY_DIR} ${SERVICES_BINARY})
- set(SERVICES_BIN "${BINDIR}/${SERVICES_BINARY}")
-message("[in src] SERVICES_BIN: ${SERVICES_BIN}")
+get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
+set(SERVICES_BIN "${SERVICES_BINARY}")
+# Generate sysconf.h from the earlier configuration
configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/include/sysconf.h)
-if(NOT WIN32)
- configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc)
-endif(NOT WIN32)
+# Go into the following directories and run their CMakeLists.txt as well
add_subdirectory(bin)
add_subdirectory(core)
add_subdirectory(modules)
add_subdirectory(protocol)
add_subdirectory(tools)
+# Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME}
- DESTINATION "${BINDIR}"
+ DESTINATION "${INSTDIR}"
)
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
index b587479c6..99a7e5136 100644
--- a/src/bin/CMakeLists.txt
+++ b/src/bin/CMakeLists.txt
@@ -1,9 +1,10 @@
+# If not on Windows, generate anoperc and install it along with mydbgen
if(NOT WIN32)
+ configure_file(${Anope_SOURCE_DIR}/src/bin/anoperc.cmake ${Anope_BINARY_DIR}/src/bin/anoperc)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
- DESTINATION "${BINDIR}"
+ DESTINATION "${INSTDIR}"
)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/mydbgen
DESTINATION "${DATADIR}"
)
endif(NOT WIN32)
-
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 27c9c038e..266b420d5 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -1,75 +1,32 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
+# Find all the *.c and *.cpp files within the current source directory, and sort the list
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})
list(SORT CORE_SRCS)
-#add_custom_target(core ALL)
-#add_custom_target(core)
-#add_dependencies(core build)
-
+# 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(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
-set(cs_set.c_HEADERS encrypt.h)
-set(ns_register.c_HEADERS encrypt.h)
-set(ns_saset.c_HEADERS encrypt.h)
-set(ns_set.c_HEADERS encrypt.h)
-
+# Iterate through all the source files
foreach(SRC ${CORE_SRCS})
- string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
- string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
- string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
- #string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
- string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
- #string(REGEX REPLACE "\\.o" "" SO ${OBJ})
- #string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
- # MAIN_DEPENDENCY ${SRC}
- #)
- #add_custom_target(core_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
- # MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
- #)
- #add_custom_target(core_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
- #add_dependencies(core core_${SO_TARGET})
- #set(HEADERS ${Anope_SOURCE_DIR}/include/module.h)
- #if(${SRC}_HEADERS)
- # foreach(HEADER ${${SRC}_HEADERS})
- # string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- # string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
- # if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${HEADER})
- # else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- # endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # endforeach(HEADER)
- #endif(${SRC}_HEADERS)
- #if(HEADERS)
- # set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
- #endif(HEADERS)
+ # Convert the source file extension to have a .so extension
+ string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
+ # Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
- get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
- message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
- set_source_files_properties(${HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE)
- if(WIN32 AND MSVC)
- set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- endif(WIN32 AND MSVC)
+ # For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
+ if(MSVC)
+ list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
+ 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})
- add_dependencies(${SO} ${PROGRAM_NAME})
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES 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)
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ # Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/init.c b/src/init.c
index 499bede64..ac7fce8f1 100644
--- a/src/init.c
+++ b/src/init.c
@@ -256,7 +256,7 @@ static int parse_options(int ac, char **av)
version_flags, version_build);
fprintf(stdout,
"Anope IRC Services (http://www.anope.org)\n");
- fprintf(stdout, "Usage ./services [options] ...\n");
+ fprintf(stdout, "Usage ./" SERVICES_BIN " [options] ...\n");
fprintf(stdout,
"-remote -remote hostname[:port]\n");
fprintf(stdout, "-local -local hostname[:port]\n");
@@ -352,8 +352,8 @@ int init_primary(int ac, char **av)
parse_options(ac, av);
/* Chdir to Services data directory. */
- if (chdir(services_dir) < 0) {
- fprintf(stderr, "chdir(%s): %s\n", services_dir, strerror(errno));
+ if (chdir(services_dir.c_str()) < 0) {
+ fprintf(stderr, "chdir(%s): %s\n", services_dir.c_str(), strerror(errno));
return -1;
}
diff --git a/src/main.c b/src/main.c
index fa46eb787..8909d435f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,7 @@
/******** Global variables! ********/
/* Command-line options: (note that configuration variables are in config.c) */
-const char *services_dir = SERVICES_DIR; /* -dir dirname */
+std::string services_dir; /* -dir dirname */
const char *log_filename = LOG_FILENAME; /* -log filename */
int debug = 0; /* -debug */
int readonly = 0; /* -readonly */
@@ -46,8 +46,8 @@ int nothird = 0; /* -nothrid */
int noexpire = 0; /* -noexpire */
int protocoldebug = 0; /* -protocoldebug */
+std::string binary_dir; /* Used to store base path for Anope */
#ifdef _WIN32
-char *binary_dir; /* Used to store base path for win32 restart */
#include <process.h>
#define execve _execve
#endif
@@ -184,12 +184,7 @@ static void services_restart()
/* First don't unload protocol module, then do so */
modules_unload_all(true, false);
modules_unload_all(true, true);
-#ifdef _WIN32
- /* This fixes bug #589 - change to binary directory for restart */
- /* -- heinz */
- if (binary_dir)
- chdir(binary_dir);
-#endif
+ chdir(binary_dir.c_str());
execve(SERVICES_BIN, my_av, my_envp);
if (!readonly) {
open_log();
@@ -445,6 +440,45 @@ void sighandler(int signum)
/*************************************************************************/
+/** The following comes from InspIRCd to get the full path of the Anope executable
+ */
+std::string GetFullProgDir(char *argv0)
+{
+ char buffer[PATH_MAX];
+#ifdef _WIN32
+ /* Windows has specific API calls to get the EXE path that never fail.
+ * For once, Windows has something of use, compared to the POSIX code
+ * for this, this is positively neato.
+ */
+ if (GetModuleFileName(NULL, buffer, PATH_MAX))
+ {
+ std::string fullpath = buffer;
+ std::string::size_type n = fullpath.rfind("\\" SERVICES_BIN);
+ return std::string(fullpath, 0, n);
+ }
+#else
+ // Get the current working directory
+ if (getcwd(buffer, PATH_MAX))
+ {
+ std::string remainder = argv0;
+
+ /* Does argv[0] start with /? If so, it's a full path, use it */
+ if (remainder[0] == '/')
+ {
+ std::string::size_type n = remainder.rfind("/" SERVICES_BIN);
+ return std::string(remainder, 0, n);
+ }
+
+ std::string fullpath = static_cast<std::string>(buffer) + "/" + remainder;
+ std::string::size_type n = fullpath.rfind("/" SERVICES_BIN);
+ return std::string(fullpath, 0, n);
+ }
+#endif
+ return "/";
+}
+
+/*************************************************************************/
+
/* Main routine. (What does it look like? :-) ) */
int main(int ac, char **av, char **envp)
@@ -469,20 +503,11 @@ int main(int ac, char **av, char **envp)
" require root privileges to run, and it is discouraged that you run Anope\n");
fprintf(stderr, " as the root superuser.\n");
}
-#else
- /*
- * We need to know which directory we're in for when restart is called.
- * This only affects Windows as a full path is not specified in services_dir.
- * This fixes bug #589.
- * -- heinz
- */
- binary_dir = new char[MAX_PATH];
- if (!getcwd(binary_dir, MAX_PATH)) {
- fprintf(stderr, "error: getcwd() error\n");
- return -1;
- }
#endif
+ binary_dir = GetFullProgDir(av[0]);
+ services_dir = binary_dir + "/data";
+
/* General initialization first */
if ((i = init_primary(ac, av)) != 0)
return i;
@@ -590,12 +615,7 @@ int main(int ac, char **av, char **envp)
ircdproto->SendSquit(ServerName, quitmsg);
disconn(servsock);
close_log();
-#ifdef _WIN32
- /* This fixes bug #589 - change to binary directory for restart */
- /* -- heinz */
- if (binary_dir)
- chdir(binary_dir);
-#endif
+ chdir(binary_dir.c_str());
execve(SERVICES_BIN, av, envp);
if (!readonly) {
open_log();
@@ -612,11 +632,6 @@ int main(int ac, char **av, char **envp)
/* Disconnect and exit */
services_shutdown();
-#ifdef _WIN32
- if (binary_dir)
- delete [] binary_dir;
-#endif
-
return 0;
}
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 672af7bbc..d78052c0c 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -44,7 +44,9 @@ static int moduleCopyFile(const char *name, const char *output)
char input[4096];
int len;
- strncpy(input, MODULE_PATH, 4095); /* Get full path with module extension */
+ strncpy(input, services_dir.c_str(), 4095);
+ len = strlen(input);
+ strncat(input, "/modules/", 4095 - len); /* Get full path with module extension */
len = strlen(input);
strncat(input, name, 4095 - len);
len = strlen(output);
@@ -146,7 +148,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
/* Generate the filename for the temporary copy of the module */
std::string pbuf;
- pbuf = MODULE_PATH;
+ pbuf = services_dir + "/modules/";
#ifndef _WIN32
pbuf += "runtime/";
#else
diff --git a/src/modules.c b/src/modules.c
index 48a01c43a..93983a247 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -1239,12 +1239,7 @@ void ModuleRunTimeDirCleanUp()
char dirbuf[BUFSIZE];
char filebuf[BUFSIZE];
-
-#ifndef _WIN32
- snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir);
-#else
- snprintf(dirbuf, BUFSIZE, "\\%s", "modules/runtime");
-#endif
+ snprintf(dirbuf, BUFSIZE, "%s/modules/runtime", services_dir.c_str());
if (debug) {
alog("debug: Cleaning out Module run time directory (%s) - this may take a moment please wait", dirbuf);
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
index 73d1cad61..300d87050 100644
--- a/src/modules/CMakeLists.txt
+++ b/src/modules/CMakeLists.txt
@@ -1,69 +1,32 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
+# Find all the *.c and *.cpp files within the current source directory, and sort the list
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})
list(SORT MODULES_SRCS)
-#add_custom_target(modules ALL)
-#add_custom_target(modules)
-#add_dependencies(modules build)
-
+# 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_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+# Iterate through all the source files
foreach(SRC ${MODULES_SRCS})
- string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
- string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
- string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
- #string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
- string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
- #string(REGEX REPLACE "\\.o" "" SO ${OBJ})
- #string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
- # MAIN_DEPENDENCY ${SRC}
- #)
- #add_custom_target(modules_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
- # MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
- #)
- #add_custom_target(modules_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
- #add_dependencies(modules modules_${SO_TARGET})
- #set(HEADERS ${Anope_SOURCE_DIR}/include/module.h)
- #if(${SRC}_HEADERS)
- # foreach(HEADER ${${SRC}_HEADERS})
- # string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- # string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
- # if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${HEADER})
- # else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- # endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # endforeach(HEADER)
- #endif(${SRC}_HEADERS)
- #if(HEADERS)
- # set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
- #endif(HEADERS)
+ # Convert the source file extension to have a .so extension
+ string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
+ # Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
- get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
- message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
- if(WIN32 AND MSVC)
- set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- endif(WIN32 AND MSVC)
+ # For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
+ if(MSVC)
+ list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
+ 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})
- add_dependencies(${SO} ${PROGRAM_NAME})
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES 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)
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ # Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt
index f6a039aed..c384f7a31 100644
--- a/src/protocol/CMakeLists.txt
+++ b/src/protocol/CMakeLists.txt
@@ -1,69 +1,32 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
+# 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})
list(SORT PROTOCOL_SRCS)
-#add_custom_target(protocol ALL)
-#add_custom_target(modules)
-#add_dependencies(protocol build)
-
+# 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 "${MODULE_CXXFLAGS}")
+# Iterate through all the source files
foreach(SRC ${PROTOCOL_SRCS})
- string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
- string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
- string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
- #string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
- string(REGEX REPLACE "\\.o" ".so" SO ${OBJ})
- #string(REGEX REPLACE "\\.o" "" SO ${OBJ})
- #string(REGEX REPLACE "\\." "_" SO_TARGET ${SO})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
- # MAIN_DEPENDENCY ${SRC}
- #)
- #add_custom_target(modules_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${SO}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} ${BUILD_DIR}/${OBJ} -o ${BUILD_DIR}/${SO}
- # MAIN_DEPENDENCY ${BUILD_DIR}/${OBJ}
- #)
- #add_custom_target(protocol_${SO_TARGET} DEPENDS ${BUILD_DIR}/${SO})
- #add_dependencies(protocol protocol_${SO_TARGET})
- #set(HEADERS ${Anope_SOURCE_DIR}/include/services.h ${Anope_SOURCE_DIR}/include/pseudo.h)
- #if(${SRC}_HEADERS)
- # foreach(HEADER ${${SRC}_HEADERS})
- # string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- # string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
- # if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${HEADER})
- # else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- # endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # endforeach(HEADER)
- #endif(${SRC}_HEADERS)
- #if(HEADERS)
- # set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
- #endif(HEADERS)
+ # Convert the source file extension to have a .so extension
+ string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC})
+ # Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
- get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
- message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
- if(WIN32 AND MSVC)
- set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- endif(WIN32 AND MSVC)
+ # For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators
+ if(MSVC)
+ list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
+ 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})
- add_dependencies(${SO} ${PROGRAM_NAME})
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "" COMPILE_FLAGS ${CXXFLAGS})
set_target_properties(${SO} PROPERTIES 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)
+ set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
endif(WIN32)
- #set_target_properties(${SO} PROPERTIES PREFIX "" SUFFIX "")
+ # Set the module to be installed to the module directory under the data directory
install(TARGETS ${SO}
DESTINATION "${DATADIR}/modules"
)
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 384755670..17d9b9282 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -1,68 +1,34 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
-set(TOOLS_SRCS anopesmtp.c db-convert.c db-merger.c)
+# Find all the *.c and *.cpp files within the current source directory, and sort the list
+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})
list(SORT 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}")
-set(anopesmtp.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h ${CMAKE_CURRENT_SOURCE_DIR}/smtp.h)
-set(db-convert.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
-set(db-merger.c_HEADERS ${Anope_BINARY_DIR}/include/sysconf.h)
-
+# Iterate through all the source files
foreach(SRC ${TOOLS_SRCS})
- #string(REGEX REPLACE "\\." "_" SRC_TARGET ${SRC})
- string(REGEX REPLACE "\\.cpp$" ".x" SRC_X ${SRC})
- string(REGEX REPLACE "\\.c$" ".o" SRC_O ${SRC_X})
- string(REGEX REPLACE "\\.x$" ".o" OBJ ${SRC_O})
- string(REGEX REPLACE "\\.o$" "" EXE ${OBJ})
- #string(REGEX REPLACE "\\." "_" OBJ_TARGET ${OBJ})
- #set(SRC_OBJS ${SRC_OBJS} ${BUILD_DIR}/${OBJ})
- set(TOOLS ${TOOLS} ${EXE})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${OBJ}
- # COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} -I${Anope_SOURCE_DIR}/include -c ${SRC} -o ${BUILD_DIR}/${OBJ}
- # MAIN_DEPENDENCY ${SRC}
- #)
- #add_custom_target(src_${OBJ_TARGET} DEPENDS ${BUILD_DIR}/${OBJ})
- #add_custom_target(src_${SRC_TARGET} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
- #add_dependencies(src_srcs src_${SRC_TARGET})
- #set(HEADERS)
- #if(${SRC}_HEADERS)
- # foreach(HEADER ${${SRC}_HEADERS})
- # string(SUBSTRING ${HEADER} 0 1 FIRST_CHAR)
- # string(SUBSTRING ${HEADER} 1 1 SECOND_CHAR)
- # if(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${HEADER})
- # else(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # set(HEADERS ${HEADERS} ${Anope_SOURCE_DIR}/include/${HEADER})
- # endif(FIRST_CHAR STREQUAL "/" OR SECOND_CHAR STREQUAL ":")
- # endforeach(HEADER)
- #endif(${SRC}_HEADERS)
- #if(HEADERS)
- # set_source_files_properties(${SRC} PROPERTIES OBJECT_DEPENDS "${HEADERS}")
- #endif(HEADERS)
+ # Convert the source file extension to have no extension
+ string(REGEX REPLACE "\\.(c|cpp)$" "" EXE ${SRC})
+ # Calculate the header file dependencies for the given source file
calculate_depends(${SRC})
- get_source_file_property(HEADERS ${SRC} OBJECT_DEPENDS)
- message(STATUS "${SRC}'s OBJECT_DEPENDS: ${HEADERS}")
+ # Generate the executable and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
add_executable(${EXE} ${SRC})
set_target_properties(${EXE} PROPERTIES LINK_FLAGS "${LDFLAGS}")
add_dependencies(${EXE} ${PROGRAM_NAME})
- #set_target_properties(${EXE} PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
+ # Set the executable to be installed to the tools directory under the bin directory
install(TARGETS ${EXE}
- DESTINATION "${BINDIR}/tools"
+ DESTINATION "${INSTDIR}/tools"
)
endforeach(SRC)
+# Only for Windows, set anopesmtp to require the wsock32 library
if(WIN32)
target_link_libraries(anopesmtp wsock32)
endif(WIN32)
-if(NOT WIN32)
- if(RUNGROUP)
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${BINDIR}/tools\")")
- endif(RUNGROUP)
-endif(NOT WIN32)
+# 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 \"${INSTDIR}/tools\")")
+endif(NOT WIN32 AND RUNGROUP)
diff --git a/src/win32.rc.cmake b/src/win32.rc.cmake
index c428ea2f0..7ec5025e1 100644
--- a/src/win32.rc.cmake
+++ b/src/win32.rc.cmake
@@ -37,7 +37,11 @@ VER_ANOPE VERSIONINFO
#ifndef MINGW
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#endif
- FILEFLAGS @FILEFLAGS@
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
FILEOS VOS_NT
FILETYPE VFT_APP
FILESUBTYPE 0x0L