summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-12-17 20:18:40 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-12-17 20:18:40 +0000
commit81b7aa657110db03ceb861d8206fc6e805ede9c8 (patch)
tree8437f5ce65de3e27e5e02196711bd770aa86b7f5 /src/core
parentfd45a3ad4219bffcf2f68fcc1dce3ff33b531b89 (diff)
Massive cleanup of the CMakeLists.txt files to finalize them.
Edited configuration scripts for *nix and Windows to use CMake as well as support both in-source and out-of-source builds. Changed directory structure for *nix to match Windows to remove some conditionals in both CMake and Anope itself. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1841 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt73
1 files changed, 15 insertions, 58 deletions
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"
)