summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt26
-rw-r--r--src/core/CMakeLists.txt9
-rw-r--r--src/modules/CMakeLists.txt9
-rw-r--r--src/protocol/CMakeLists.txt9
4 files changed, 36 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22a080546..6af01d7c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,34 +63,38 @@ endif(CMAKE244_OR_BETTER)
# Add an optional variable for using run-cc.pl for building, Perl will be checked later regardless of this setting
option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF)
+# Use the following directories as includes
+include_directories(${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/include ${Anope_BINARY_DIR}/lang)
+
+# If using Windows, always add the _WIN32 define
+if(WIN32)
+ add_definitions(-D_WIN32)
+endif(WIN32)
+
# If using Visual Studio, set the C++ flags accordingly
if(MSVC)
# Remove the default exception handling flags, also remove default warning level flag
string(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GX " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
- # Set the compile flags to have warnings on the max setting (but disable a few annoying ones), exception handling turned on, the proper defines, and the include directories
- set(CXXFLAGS "${CXXFLAGS} /W4 /wd4251 /wd4706 /wd4800 /wd4996 /EHs /D_WIN32 /DMSVCPP /D_CRT_SECURE_NO_WARNINGS /I\"${Anope_SOURCE_DIR}/include\" /I\"${Anope_BINARY_DIR}/include\" /I\"${Anope_BINARY_DIR}/lang\"")
- # Set the module-specific compile flags to include a define for module compiling
- set(MODULE_CXXFLAGS "${CXXFLAGS} /DMODULE_COMPILE")
+ # Set the compile flags to have warnings on the max setting (but disable a few annoying ones), exception handling turned on, the proper defines
+ set(CXXFLAGS "${CXXFLAGS} /W4 /wd4251 /wd4706 /wd4800 /wd4996 /EHs")
+ add_definitions(-DMSVCPP -D_CRT_SECURE_NO_WARNINGS)
# Otherwise, we're not using Visual Studio
else(MSVC)
- # Set the compile flags to have all warnings on (including shadowed variables) and the include directories
- set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow -I${Anope_SOURCE_DIR}/include -I${Anope_BINARY_DIR}/include -I${Anope_BINARY_DIR}/lang")
+ # Set the compile flags to have all warnings on (including shadowed variables)
+ set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow")
# If on a *nix system, also set the compile flags to remove GNU extensions (favor ISO C++) as well as reject non-ISO C++ code, also remove all leading underscores in exported symbols
if(UNIX)
set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic -fno-leading-underscore")
# Set the module-specific compile flags to the same setting as the compile flags
set(MODULE_CXXFLAGS "${CXXFLAGS}")
- # If we aren't on a *nix system, set the compile flags to include a define for Windows
+ # If we aren't on a *nix system, we are using MinGW
else(UNIX)
- set(CXXFLAGS "${CXXFLAGS} -D_WIN32")
# Also, if we are building under MinGW, add another define for MinGW
if(MINGW)
- set(CXXFLAGS "${CXXFLAGS} -DMINGW")
+ add_definitions(-DMINGW)
endif(MINGW)
- # Set the module-specific compile flags to include a define for module compiling
- set(MODULE_CXXFLAGS "${CXXFLAGS} -DMODULE_COMPILE")
endif(UNIX)
endif(MSVC)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 7b02ac340..0a3655806 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -6,8 +6,13 @@ if(CMAKE244_OR_BETTER)
list(SORT CORE_SRCS)
endif(CMAKE244_OR_BETTER)
+# 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(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+set_source_files_properties(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Iterate through all the source files
foreach(SRC ${CORE_SRCS})
@@ -18,7 +23,7 @@ foreach(SRC ${CORE_SRCS})
# 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)
append_to_list(SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+ set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
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})
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
index aa04edaa6..0b7017180 100644
--- a/src/modules/CMakeLists.txt
+++ b/src/modules/CMakeLists.txt
@@ -6,8 +6,13 @@ if(CMAKE244_OR_BETTER)
list(SORT MODULES_SRCS)
endif(CMAKE244_OR_BETTER)
+# 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(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+set_source_files_properties(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Iterate through all the source files
foreach(SRC ${MODULES_SRCS})
@@ -18,7 +23,7 @@ foreach(SRC ${MODULES_SRCS})
# 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)
append_to_list(SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+ set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
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})
diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt
index 6fd48290e..fdb16471d 100644
--- a/src/protocol/CMakeLists.txt
+++ b/src/protocol/CMakeLists.txt
@@ -6,8 +6,13 @@ if(CMAKE244_OR_BETTER)
list(SORT PROTOCOL_SRCS)
endif(CMAKE244_OR_BETTER)
+# 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 "${MODULE_CXXFLAGS}")
+set_source_files_properties(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
# Iterate through all the source files
foreach(SRC ${PROTOCOL_SRCS})
@@ -18,7 +23,7 @@ foreach(SRC ${PROTOCOL_SRCS})
# 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)
append_to_list(APPEND SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp)
- set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${MODULE_CXXFLAGS}")
+ set_source_files_properties(${Anope_SOURCE_DIR}/src/win32_memory.cpp LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
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})