1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 17:24:49 +02:00

Even more build system cleanup.

This commit is contained in:
Sadie Powell
2025-11-18 05:04:12 +00:00
parent c5e03de667
commit cadeac2dea
11 changed files with 69 additions and 1014 deletions
+17 -43
View File
@@ -4,11 +4,6 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
# Set the project as C++ primarily # Set the project as C++ primarily
project(Anope CXX) project(Anope CXX)
# Override the module include path to include our directory, for our Anope.cmake, as well as we are using our own version of the NSIS template
set(CMAKE_MODULE_PATH ${Anope_SOURCE_DIR}/cmake)
include(Anope)
# Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language # Force the locale to C for later uses of things like gcc so the messages come up in English, not the user's default language
set(ENV{LC_ALL} C) set(ENV{LC_ALL} C)
@@ -54,6 +49,7 @@ find_package(Intl)
if(GETTEXT_FOUND AND Intl_FOUND) if(GETTEXT_FOUND AND Intl_FOUND)
set(HAVE_LOCALIZATION ON) set(HAVE_LOCALIZATION ON)
include_directories(${Intl_INCLUDE_DIRS}) include_directories(${Intl_INCLUDE_DIRS})
link_libraries(${Intl_LIBRARY})
else() else()
message("Unable to find gettext and libintl; disabling localization") message("Unable to find gettext and libintl; disabling localization")
set(HAVE_LOCALIZATION OFF) set(HAVE_LOCALIZATION OFF)
@@ -73,29 +69,33 @@ endif()
# If using Visual Studio, set the C++ flags accordingly # If using Visual Studio, set the C++ flags accordingly
if(MSVC) if(MSVC)
# Remove the default exception handling flags, also remove default warning level flag # Set the compile flags to have warnings on the max setting (but disable a few annoying ones), exception handling turned on
string(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /wd4100 /wd4127 /wd4250 /wd4251 /wd4267 /wd4275 /wd4355 /wd4706 /wd4800 /wd4996 /EHs")
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
set(CXXFLAGS "${CXXFLAGS} /W4 /wd4100 /wd4127 /wd4250 /wd4251 /wd4267 /wd4275 /wd4355 /wd4706 /wd4800 /wd4996 /EHs")
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Otherwise, we're not using Visual Studio # Otherwise, we're not using Visual Studio
else() else()
# Set the compile flags to have all warnings on (including shadowed variables) # Set the compile flags to have all warnings on (including shadowed variables)
set(CXXFLAGS "${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wformat=2 -Wmissing-format-attribute -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wformat=2 -Wmissing-format-attribute -Wpedantic")
set(CXXFLAGS "${CXXFLAGS} -Wno-format-nonliteral -Wno-format-y2k -Wno-format-zero-length -Wno-date-time -Wno-unused-parameter ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format-nonliteral -Wno-format-y2k -Wno-format-zero-length -Wno-date-time -Wno-unused-parameter")
endif() endif()
# If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags # If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags
if(CMAKE_DL_LIBS) if(CMAKE_DL_LIBS)
list(APPEND LINK_LIBS ${CMAKE_DL_LIBS}) link_libraries(${CMAKE_DL_LIBS})
endif() endif()
# Find the linker flags required for using threads. # Find the linker flags required for using threads.
find_package("Threads" REQUIRED) find_package("Threads" REQUIRED)
if(CMAKE_THREAD_LIBS_INIT) if(CMAKE_THREAD_LIBS_INIT)
list(APPEND LINK_LIBS ${CMAKE_THREAD_LIBS_INIT}) link_libraries(${CMAKE_THREAD_LIBS_INIT})
endif()
# On Windows, also link Anope to the memory library and Winsock.
if(WIN32)
link_libraries("Ws2_32")
if(MSVC)
link_libraries("win32_memory")
endif()
endif() endif()
if(NOT PROGRAM_NAME) if(NOT PROGRAM_NAME)
@@ -108,7 +108,7 @@ if(NOT MSVC)
check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG) check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG)
# If the flag was accepted, add it to the list of flags # If the flag was accepted, add it to the list of flags
if(HAVE_PIPE_FLAG) if(HAVE_PIPE_FLAG)
set(CXXFLAGS "${CXXFLAGS} -pipe") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe")
endif() endif()
endif() endif()
@@ -134,15 +134,6 @@ check_function_exists(epoll_wait HAVE_EPOLL)
check_function_exists(poll HAVE_POLL) check_function_exists(poll HAVE_POLL)
check_function_exists(kqueue HAVE_KQUEUE) check_function_exists(kqueue HAVE_KQUEUE)
# Strip the leading and trailing spaces from the compile flags
if(CXXFLAGS)
string(STRIP ${CXXFLAGS} CXXFLAGS)
endif()
# Strip the leading and trailing spaces from the linker flags
if(LDFLAGS)
string(STRIP ${LDFLAGS} LDFLAGS)
endif()
# Search for the following programs # Search for the following programs
if(NOT WIN32 AND RUNGROUP) if(NOT WIN32 AND RUNGROUP)
find_program(CHGRP "chgrp" REQUIRED) find_program(CHGRP "chgrp" REQUIRED)
@@ -153,7 +144,7 @@ endif()
if(INSTDIR) if(INSTDIR)
set(CMAKE_INSTALL_PREFIX "${INSTDIR}") set(CMAKE_INSTALL_PREFIX "${INSTDIR}")
elseif(NOT CMAKE_INSTALL_PREFIX) elseif(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope-@VERSION_MAJOR@-@VERSION_MINOR@") set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope-${VERSION_MAJOR}-${VERSION_MINOR}")
endif() endif()
# Set default paths for various directories if not already defined # Set default paths for various directories if not already defined
@@ -225,22 +216,6 @@ if(WIN32)
configure_file(${Anope_SOURCE_DIR}/src/win32/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32/win32.rc) configure_file(${Anope_SOURCE_DIR}/src/win32/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32/win32.rc)
endif() endif()
# Add the initial files to ignore which will be ignored regardless of if you are building in-source or out-of-source
add_to_cpack_ignored_files(".git\;config.cache\;CMakeFiles\;sysconf.h$\;build" TRUE)
# Add the files we don't want the periods converted for
add_to_cpack_ignored_files(".\\\\\\\\.so$;.\\\\\\\\.o$;.\\\\\\\\.s$;${Anope_SOURCE_DIR}/Makefile$")
# If the two directories are the same, we are building in-source, thus we need to ignore more files from the build
if(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR})
# Add the files that need their periods converted
add_to_cpack_ignored_files("Makefile\;cmake_install.cmake\;sysconf.h$\;CMakeCache.txt\;install_manifest.txt" TRUE)
# Add the files we don't want the periods converted for
add_to_cpack_ignored_files(".\\\\\\\\.so$;CPack.;anope-${VERSION_FULL_NOBUILD}-source\\\\\\\\..")
# If using Visual Studio, add these files as well
if(MSVC)
add_to_cpack_ignored_files(".vcproj$\;.sln$\;.ncb$\;.suo$\;.dir$\;.ilk$\;.exp$\;.pdb$\;.lib$\;/debug$;/release$;/relwithdebinfo$;/minsizerel$" TRUE)
endif()
endif()
# Get the filename of the Anope binary, to use later # Get the filename of the Anope binary, to use later
set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>") set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>")
cmake_path(GET SERVICES_BINARY FILENAME SERVICES_BINARY) cmake_path(GET SERVICES_BINARY FILENAME SERVICES_BINARY)
@@ -309,7 +284,6 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
endif() endif()
set(CPACK_SOURCE_PACKAGE_FILE_NAME "anope-${VERSION_FULL_NOBUILD}-source") set(CPACK_SOURCE_PACKAGE_FILE_NAME "anope-${VERSION_FULL_NOBUILD}-source")
set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "$ENV{CPACK_IGNORED_FILES}")
set(CPACK_MONOLITHIC_INSTALL TRUE) set(CPACK_MONOLITHIC_INSTALL TRUE)
include(CPack) include(CPack)
endif() endif()
-48
View File
@@ -1,48 +0,0 @@
###############################################################################
# add_to_cpack_ignored_files(<item> [TRUE])
#
# A macro to update the environment variable CPACK_IGNORED_FILES which
# contains a list of files for CPack to ignore. If the optional 2nd argument
# of TRUE is given, periods will be converted to \\. for CPack.
###############################################################################
macro(add_to_cpack_ignored_files ITEM)
# Temporary copy of the original item
set(REAL_ITEM "${ITEM}")
# If we have 2+ arguments, assume that the second one was something like TRUE (doesn't matter really) and convert periods so they will be \\. for CPack
if(${ARGC} GREATER 1)
string(REPLACE "." "\\\\." REAL_ITEM ${REAL_ITEM})
endif()
# If the environment variable is already defined, just tack the item to the end
if(DEFINED ENV{CPACK_IGNORED_FILES})
set(ENV{CPACK_IGNORED_FILES} "$ENV{CPACK_IGNORED_FILES};${REAL_ITEM}")
# Otherwise set the environment variable to the item
else()
set(ENV{CPACK_IGNORED_FILES} "${REAL_ITEM}")
endif()
endmacro()
###############################################################################
# inline_cmake(TARGET FILE)
#
# A macro to execute inline CMake instructions from within a module source.
###############################################################################
macro(inline_cmake TARGET FILE)
file(STRINGS ${FILE} SRC)
set(CODE "")
set(IN_CODE OFF)
foreach(LINE IN LISTS SRC)
if(IN_CODE)
string(REGEX REPLACE "/// " "" CLEAN_LINE ${LINE})
if(CLEAN_LINE MATCHES "^END CMAKE$")
cmake_language(EVAL CODE "${CODE}")
set(CODE "")
set(IN_CODE OFF)
else()
set(CODE "${CODE}\n${CLEAN_LINE}")
endif()
elseif(LINE MATCHES "^/// BEGIN CMAKE$")
message(STATUS "Executing inline CMake code for ${TARGET}")
set(IN_CODE ON)
endif()
endforeach()
endmacro()
-825
View File
@@ -1,825 +0,0 @@
; CPack install script designed for a nmake build
;--------------------------------
; You must define these values
!define VERSION "@CPACK_PACKAGE_VERSION@"
!define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
;--------------------------------
;Variables
Var MUI_TEMP
Var STARTMENU_FOLDER
Var SV_ALLUSERS
Var START_MENU
Var DO_NOT_ADD_TO_PATH
Var ADD_TO_PATH_ALL_USERS
Var ADD_TO_PATH_CURRENT_USER
Var INSTALL_DESKTOP
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;Default installation folder
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
;--------------------------------
;General
;Name and file
Name "@CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
;Set compression
SetCompressor @CPACK_NSIS_COMPRESSOR@
@CPACK_NSIS_DEFINES@
!include Sections.nsh
;--- Component support macros: ---
; The code for the add/remove functionality is from:
; http://nsis.sourceforge.net/Add/Remove_Functionality
; It has been modified slightly and extended to provide
; inter-component dependencies.
Var AR_SecFlags
Var AR_RegFlags
@CPACK_NSIS_SECTION_SELECTED_VARS@
; Loads the "selected" flag for the section named SecName into the
; variable VarName.
!macro LoadSectionSelectedIntoVar SecName VarName
SectionGetFlags ${${SecName}} $${VarName}
IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
!macroend
; Loads the value of a variable... can we get around this?
!macro LoadVar VarName
IntOp $R0 0 + $${VarName}
!macroend
; Sets the value of a variable
!macro StoreVar VarName IntValue
IntOp $${VarName} 0 + ${IntValue}
!macroend
!macro InitSection SecName
; This macro reads component installed flag from the registry and
;changes checked state of the section on the components page.
;Input: section index constant name specified in Section command.
ClearErrors
;Reading component status from registry
ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" "Installed"
IfErrors "default_${SecName}"
;Status will stay default if registry value not found
;(component was never installed)
IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
; Note whether this component was installed before
!insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
IntOp $R0 $AR_RegFlags & $AR_RegFlags
;Writing modified flags
SectionSetFlags ${${SecName}} $AR_SecFlags
"default_${SecName}:"
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
!macroend
!macro FinishSection SecName
; This macro reads section flag set by user and removes the section
;if it is not selected.
;Then it writes component installed flag to registry
;Input: section index constant name specified in Section command.
SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
;Checking lowest bit:
IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
IntCmp $AR_SecFlags 1 "leave_${SecName}"
;Section is not selected:
;Calling Section uninstall macro and writing zero installed flag
!insertmacro "Remove_${${SecName}}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \
"Installed" 0
Goto "exit_${SecName}"
"leave_${SecName}:"
;Section is selected:
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \
"Installed" 1
"exit_${SecName}:"
!macroend
!macro RemoveSection_CPack SecName
; This macro is used to call section's Remove_... macro
;from the uninstaller.
;Input: section index constant name specified in Section command.
!insertmacro "Remove_${${SecName}}"
!macroend
; Determine whether the selection of SecName changed
!macro MaybeSelectionChanged SecName
!insertmacro LoadVar ${SecName}_selected
SectionGetFlags ${${SecName}} $R1
IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
; See if the status has changed:
IntCmp $R0 $R1 "${SecName}_unchanged"
!insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
!insertmacro "Deselect_required_by_${SecName}"
goto "${SecName}_unchanged"
"${SecName}_was_selected:"
!insertmacro "Select_${SecName}_depends"
"${SecName}_unchanged:"
!macroend
;--- End of Add/Remove macros ---
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;----------------------------------------
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
;----------------------------------------
!verbose 3
!include "WinMessages.NSH"
!verbose 4
;====================================================
; get_NT_environment
; Returns: the selected environment
; Output : head of the stack
;====================================================
!macro select_NT_profile UN
Function ${UN}select_NT_profile
StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
DetailPrint "Selected environment for all users"
Push "all"
Return
environment_single:
DetailPrint "Selected environment for current user only."
Push "current"
Return
FunctionEnd
!macroend
!insertmacro select_NT_profile ""
!insertmacro select_NT_profile "un."
;----------------------------------------------------
!define NT_current_env 'HKCU "Environment"'
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!ifndef WriteEnvStr_RegKey
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif
!endif
; AddToPath - Adds the given dir to the search path.
; Input - head of the stack
; Note - Win9x systems requires reboot
Function AddToPath
Exch $0
Push $1
Push $2
Push $3
# don't add if the path doesn't exist
IfFileExists "$0\*.*" "" AddToPath_done
ReadEnvStr $1 PATH
Push "$1;"
Push "$0;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$0\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
GetFullPathName /SHORT $3 $0
Push "$1;"
Push "$3;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$3\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Call IsNT
Pop $1
StrCmp $1 1 AddToPath_NT
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" a
FileSeek $1 -1 END
FileReadByte $1 $2
IntCmp $2 26 0 +2 +2 # DOS EOF
FileSeek $1 -1 END # write over EOF
FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
FileClose $1
SetRebootFlag true
Goto AddToPath_done
AddToPath_NT:
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
StrCmp $1 "" AddToPath_NTdoIt
Push $1
Call Trim
Pop $1
StrCpy $0 "$1;$0"
AddToPath_NTdoIt:
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
AddToPath_done:
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
; RemoveFromPath - Remove a given dir from the path
; Input: head of the stack
Function un.RemoveFromPath
Exch $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
IntFmt $6 "%c" 26 # DOS EOF
Call un.IsNT
Pop $1
StrCmp $1 1 unRemoveFromPath_NT
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" r
GetTempFileName $4
FileOpen $2 $4 w
GetFullPathName /SHORT $0 $0
StrCpy $0 "SET PATH=%PATH%;$0"
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoop:
FileRead $1 $3
StrCpy $5 $3 1 -1 # read last char
StrCmp $5 $6 0 +2 # if DOS EOF
StrCpy $3 $3 -1 # remove DOS EOF so we can compare
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
FileWrite $2 $3
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopRemoveLine:
SetRebootFlag true
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopEnd:
FileClose $2
FileClose $1
StrCpy $1 $WINDIR 2
Delete "$1\autoexec.bat"
CopyFiles /SILENT $4 "$1\autoexec.bat"
Delete $4
Goto unRemoveFromPath_done
unRemoveFromPath_NT:
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
StrCpy $5 $1 1 -1 # copy last char
StrCmp $5 ";" +2 # if last char != ;
StrCpy $1 "$1;" # append ;
Push $1
Push "$0;"
Call un.StrStr ; Find `$0;` in $1
Pop $2 ; pos of our dir
StrCmp $2 "" unRemoveFromPath_done
; else, it is in path
# $0 - path to add
# $1 - path var
StrLen $3 "$0;"
StrLen $4 $2
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
StrCpy $3 $5$6
StrCpy $5 $3 1 -1 # copy last char
StrCmp $5 ";" 0 +2 # if last char == ;
StrCpy $3 $3 -1 # remove last char
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
unRemoveFromPath_done:
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstall stuff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
###########################################
# Utility Functions #
###########################################
;====================================================
; IsNT - Returns 1 if the current system is NT, 0
; otherwise.
; Output: head of the stack
;====================================================
; IsNT
; no input
; output, top of the stack = 1 if NT or 0 if not
;
; Usage:
; Call IsNT
; Pop $R0
; ($R0 at this point is 1 or 0)
!macro IsNT un
Function ${un}IsNT
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCmp $0 "" 0 IsNT_yes
; we are not NT.
Pop $0
Push 0
Return
IsNT_yes:
; NT!!!
Pop $0
Push 1
FunctionEnd
!macroend
!insertmacro IsNT ""
!insertmacro IsNT "un."
; StrStr
; input, top of stack = string to search for
; top of stack-1 = string to search in
; output, top of stack (replaces with the portion of the string remaining)
; modifies no other variables.
;
; Usage:
; Push "this is a long ass string"
; Push "ass"
; Call StrStr
; Pop $R0
; ($R0 at this point is "ass string")
!macro StrStr un
Function ${un}StrStr
Exch $R1 ; st=haystack,old$R1, $R1=needle
Exch ; st=old$R1,haystack
Exch $R2 ; st=old$R1,old$R2, $R2=haystack
Push $R3
Push $R4
Push $R5
StrLen $R3 $R1
StrCpy $R4 0
; $R1=needle
; $R2=haystack
; $R3=len(needle)
; $R4=cnt
; $R5=tmp
loop:
StrCpy $R5 $R2 $R3 $R4
StrCmp $R5 $R1 done
StrCmp $R5 "" done
IntOp $R4 $R4 + 1
Goto loop
done:
StrCpy $R1 $R2 "" $R4
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Exch $R1
FunctionEnd
!macroend
!insertmacro StrStr ""
!insertmacro StrStr "un."
Function Trim ; Added by Pelaca
Exch $R1
Push $R2
Loop:
StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " RTrim
StrCmp "$R2" "$\n" RTrim
StrCmp "$R2" "$\r" RTrim
StrCmp "$R2" ";" RTrim
GoTo Done
RTrim:
StrCpy $R1 "$R1" -1
Goto Loop
Done:
Pop $R2
Exch $R1
FunctionEnd
Function ConditionalAddToRegistry
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegistry_EmptyString
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" \
"$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegistry_EmptyString:
FunctionEnd
;--------------------------------
!ifdef CPACK_USES_DOWNLOAD
Function DownloadFile
IfFileExists $INSTDIR\* +2
CreateDirectory $INSTDIR
Pop $0
; Skip if already downloaded
IfFileExists $INSTDIR\$0 0 +2
Return
StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
try_again:
NSISdl::download "$1/$0" "$INSTDIR\$0"
Pop $1
StrCmp $1 "success" success
StrCmp $1 "Cancelled" cancel
MessageBox MB_OK "Download failed: $1"
cancel:
Return
success:
FunctionEnd
!endif
;--------------------------------
; Installation types
@CPACK_NSIS_INSTALLATION_TYPES@
;--------------------------------
; Component sections
@CPACK_NSIS_COMPONENT_SECTIONS@
;--------------------------------
; Define some macro setting for the gui
@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
@CPACK_NSIS_INSTALLER_ICON_CODE@
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
;--------------------------------
;Pages
!define MUI_LANGDLL_REGISTRY_ROOT "SHCTX"
!define MUI_LANGDLL_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
!insertmacro MUI_PAGE_DIRECTORY
;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
@CPACK_NSIS_PAGE_COMPONENTS@
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\doc\README.txt"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "Spanish"
;--------------------------------
;Installer Sections
Section "-Core installation"
;Use the entire tree produced by the INSTALL target. Keep the
;list of directories here in sync with the RMDir commands below.
SetOutPath "$INSTDIR"
@CPACK_NSIS_FULL_INSTALL@
;Store installation folder
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
Push "DisplayName"
Push "@CPACK_NSIS_DISPLAY_NAME@"
Call ConditionalAddToRegistry
Push "DisplayVersion"
Push "@CPACK_PACKAGE_VERSION@"
Call ConditionalAddToRegistry
Push "Publisher"
Push "@CPACK_PACKAGE_VENDOR@"
Call ConditionalAddToRegistry
Push "UninstallString"
Push "$INSTDIR\Uninstall.exe"
Call ConditionalAddToRegistry
Push "NoRepair"
Push "1"
Call ConditionalAddToRegistry
!ifdef CPACK_NSIS_ADD_REMOVE
;Create add/remove functionality
Push "ModifyPath"
Push "$INSTDIR\AddRemove.exe"
Call ConditionalAddToRegistry
!else
Push "NoModify"
Push "1"
Call ConditionalAddToRegistry
!endif
; Optional registration
Push "DisplayIcon"
Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
Call ConditionalAddToRegistry
Push "HelpLink"
Push "@CPACK_NSIS_HELP_LINK@"
Call ConditionalAddToRegistry
Push "URLInfoAbout"
Push "@CPACK_NSIS_URL_INFO_ABOUT@"
Call ConditionalAddToRegistry
Push "Contact"
Push "@CPACK_NSIS_CONTACT@"
Call ConditionalAddToRegistry
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
@CPACK_NSIS_CREATE_ICONS@
@CPACK_NSIS_CREATE_ICONS_EXTRA@
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
; Write special uninstall registry entries
Push "StartMenu"
Push "$STARTMENU_FOLDER"
Call ConditionalAddToRegistry
Push "DoNotAddToPath"
Push "$DO_NOT_ADD_TO_PATH"
Call ConditionalAddToRegistry
Push "AddToPathAllUsers"
Push "$ADD_TO_PATH_ALL_USERS"
Call ConditionalAddToRegistry
Push "AddToPathCurrentUser"
Push "$ADD_TO_PATH_CURRENT_USER"
Call ConditionalAddToRegistry
Push "InstallToDesktop"
Push "$INSTALL_DESKTOP"
Call ConditionalAddToRegistry
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;--------------------------------
; determine admin versus local install
Function un.onInit
ClearErrors
UserInfo::GetName
IfErrors noLM
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
SetShellVarContext all
;MessageBox MB_OK 'User "$0" is in the Admin group'
Goto done
StrCmp $1 "Power" 0 +3
SetShellVarContext all
;MessageBox MB_OK 'User "$0" is in the Power Users group'
Goto done
noLM:
;Get installation folder from registry if available
done:
!insertmacro MUI_UNGETLANGUAGE
FunctionEnd
;--- Add/Remove callback functions: ---
!macro SectionList MacroName
;This macro used to perform operation on multiple sections.
;List all of your components in following manner here.
@CPACK_NSIS_COMPONENT_SECTION_LIST@
!macroend
Section -FinishComponents
;Removes unselected components and writes component status to registry
!insertmacro SectionList "FinishSection"
!ifdef CPACK_NSIS_ADD_REMOVE
; Get the name of the installer executable
System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
StrCpy $R3 $R0
; Strip off the last 13 characters, to see if we have AddRemove.exe
StrLen $R1 $R0
IntOp $R1 $R0 - 13
StrCpy $R2 $R0 13 $R1
StrCmp $R2 "AddRemove.exe" addremove_installed
; We're not running AddRemove.exe, so install it
CopyFiles $R3 $INSTDIR\AddRemove.exe
addremove_installed:
!endif
SectionEnd
;--- End of Add/Remove callback functions ---
;--------------------------------
; Component dependencies
Function .onSelChange
!insertmacro SectionList MaybeSelectionChanged
FunctionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
ReadRegStr $START_MENU SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "StartMenu"
;MessageBox MB_OK "Start menu is in: $START_MENU"
ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "DoNotAddToPath"
ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathAllUsers"
ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathCurrentUser"
;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
ReadRegStr $INSTALL_DESKTOP SHCTX \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "InstallToDesktop"
;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
;Remove files we installed.
;Keep the list of directories here in sync with the File commands above.
@CPACK_NSIS_DELETE_FILES@
@CPACK_NSIS_DELETE_DIRECTORIES@
!ifdef CPACK_NSIS_ADD_REMOVE
;Remove the add/remove program
Delete "$INSTDIR\AddRemove.exe"
!endif
;Remove the uninstaller itself.
Delete "$INSTDIR\Uninstall.exe"
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@"
;Remove the installation directory if it is empty.
RMDir "$INSTDIR"
; Remove the registry entries.
DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
; Removes all optional components
!insertmacro SectionList "RemoveSection_CPack"
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
@CPACK_NSIS_DELETE_ICONS@
@CPACK_NSIS_DELETE_ICONS_EXTRA@
;Delete empty start menu parent directories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
startMenuDeleteLoop:
ClearErrors
RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors startMenuDeleteLoopDone
StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
; If the user changed the shortcut, then uninstall may not work. This should
; try to fix it.
StrCpy $MUI_TEMP "$START_MENU"
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
@CPACK_NSIS_DELETE_ICONS_EXTRA@
;Delete empty start menu parent directories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
secondStartMenuDeleteLoop:
ClearErrors
RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors secondStartMenuDeleteLoopDone
StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
secondStartMenuDeleteLoopDone:
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
Push $INSTDIR\bin
StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
Call un.RemoveFromPath
doNotRemoveFromPath:
SectionEnd
;--------------------------------
; determine admin versus local install
; Is install for "AllUsers" or "JustMe"?
; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
; This function is used for the very first "custom page" of the installer.
; This custom page does not show up visibly, but it executes prior to the
; first visible page and sets up $INSTDIR properly...
; Choose different default installation folder based on SV_ALLUSERS...
; "Program Files" for AllUsers, "My Documents" for JustMe...
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
; Reads components status for registry
!insertmacro SectionList "InitSection"
StrCpy $SV_ALLUSERS "JustMe"
StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
ClearErrors
UserInfo::GetName
IfErrors noLM
Pop $0
UserInfo::GetAccountType
Pop $1
StrCmp $1 "Admin" 0 +3
SetShellVarContext all
;MessageBox MB_OK 'User "$0" is in the Admin group'
StrCpy $SV_ALLUSERS "AllUsers"
Goto done
StrCmp $1 "Power" 0 +3
SetShellVarContext all
;MessageBox MB_OK 'User "$0" is in the Power Users group'
StrCpy $SV_ALLUSERS "AllUsers"
Goto done
noLM:
StrCpy $SV_ALLUSERS "AllUsers"
;Get installation folder from registry if available
done:
StrCmp $SV_ALLUSERS "AllUsers" 0 +2
StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
FunctionEnd
-4
View File
@@ -3,10 +3,6 @@ if(WIN32)
# Only install given files from this directory # Only install given files from this directory
# NOTE: I would've had this just find all files in the directory, but that would include files not needed (like this file) # NOTE: I would've had this just find all files in the directory, but that would include files not needed (like this file)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_BINARY_DIR}/README.txt) execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/README ${CMAKE_CURRENT_BINARY_DIR}/README.txt)
if(IN_SOURCE)
# Add README.txt to list of files for CPack to ignore
add_to_cpack_ignored_files("README.txt$" TRUE)
endif()
set(DOCS CHANGES.md DEFCON FAQ INSTALL LANGUAGE MODULES ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt) set(DOCS CHANGES.md DEFCON FAQ INSTALL LANGUAGE MODULES ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt)
install(FILES ${DOCS} install(FILES ${DOCS}
DESTINATION ${DOC_DIR} DESTINATION ${DOC_DIR}
+6 -10
View File
@@ -1,8 +1,11 @@
# Set version.cpp to use C++ as well as set its compile flags # Generate sysconf.h from the earlier configuration
set_source_files_properties(version.cpp PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/sysconf.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/sysconf.h"
)
# Generate version-bin executable to modify version.h, setting it's linker flags as well # Generate version-bin executable to modify version.h, setting it's linker flags as well
add_executable(version-bin version.cpp) add_executable(version-bin version.cpp)
set_target_properties(version-bin PROPERTIES LINK_FLAGS "${LDFLAGS}")
set(version_BINARY "$<TARGET_FILE:version-bin>") set(version_BINARY "$<TARGET_FILE:version-bin>")
# Modify version.h from the above executable, with dependencies to version.cpp # Modify version.h from the above executable, with dependencies to version.cpp
# and all of the source files in the main build # and all of the source files in the main build
@@ -10,13 +13,6 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_
COMMAND version-bin ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h COMMAND version-bin ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h
DEPENDS version-bin ${SRC_SRCS} DEPENDS version-bin ${SRC_SRCS}
) )
# Add version-bin to list of files for CPack to ignore
cmake_path(GET version_BINARY FILENAME version_BINARY)
add_to_cpack_ignored_files("${version_BINARY}$" TRUE)
if(NOT WIN32)
add_to_cpack_ignored_files("version.h$" TRUE)
add_to_cpack_ignored_files("build.h$" TRUE)
endif()
# Add a custom target to the above file # Add a custom target to the above file
add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h) add_custom_target(headers DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/version.h ${CMAKE_CURRENT_BINARY_DIR}/build.h)
-4
View File
@@ -23,10 +23,6 @@ if(HAVE_LOCALIZATION)
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_PO} -o ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_PO} -o ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO}
MAIN_DEPENDENCY ${LANG_PO} MAIN_DEPENDENCY ${LANG_PO}
) )
# Add to cpack ignored files if not on Windows.
if(NOT WIN32)
add_to_cpack_ignored_files("${LANG_MO}")
endif()
# Install the new language file # Install the new language file
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS})
+25 -22
View File
@@ -32,6 +32,27 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../conanbuildinfo.cmake")
install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR})
endif() endif()
macro(inline_cmake TARGET FILE)
file(STRINGS ${FILE} SRC)
set(CODE "")
set(IN_CODE OFF)
foreach(LINE IN LISTS SRC)
if(IN_CODE)
string(REGEX REPLACE "^/// " "" CLEAN_LINE ${LINE})
if(CLEAN_LINE MATCHES "^END CMAKE$")
cmake_language(EVAL CODE "${CODE}")
set(CODE "")
set(IN_CODE OFF)
else()
set(CODE "${CODE}\n${CLEAN_LINE}")
endif()
elseif(LINE MATCHES "^/// BEGIN CMAKE$")
message(STATUS "Executing inline CMake code for ${TARGET}")
set(IN_CODE ON)
endif()
endforeach()
endmacro()
macro(build_module SRC MODULE_SRC) macro(build_module SRC MODULE_SRC)
string(REGEX MATCH "\\.c$" ANOPE18MODULE ${MODULE_SRC}) string(REGEX MATCH "\\.c$" ANOPE18MODULE ${MODULE_SRC})
if(ANOPE18MODULE) if(ANOPE18MODULE)
@@ -39,17 +60,9 @@ macro(build_module SRC MODULE_SRC)
endif() endif()
string(REGEX MATCH "\\.cpp$" CPP ${MODULE_SRC}) string(REGEX MATCH "\\.cpp$" CPP ${MODULE_SRC})
if(CPP) if(CPP)
set_source_files_properties(${MODULE_SRC} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
file(RELATIVE_PATH FNAME ${SRC} ${MODULE_SRC}) file(RELATIVE_PATH FNAME ${SRC} ${MODULE_SRC})
# Convert the real source file extension to have a library extension # Convert the real source file extension to have a library extension
string(REGEX REPLACE "\\.cpp$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" SO ${FNAME}) string(REGEX REPLACE "\\.cpp$" "${CMAKE_SHARED_LIBRARY_SUFFIX}" SO ${FNAME})
# 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 # 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}) add_library(${SO} MODULE ${MODULE_SRC})
# Execute inline CMake code for the module # Execute inline CMake code for the module
@@ -65,9 +78,9 @@ macro(build_module SRC MODULE_SRC)
if(HAVE_LOCALIZATION) if(HAVE_LOCALIZATION)
add_dependencies(${SO} module_language) add_dependencies(${SO} module_language)
endif() endif()
# For Windows only, have the module link to the export library of Anope as well as Winsock (most of the modules probably don't need this, but this is to be on the safe side) # For Windows only, have the module link to the export library of Anope.
if(WIN32) if(WIN32)
target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME} "Ws2_32" ${WIN32_MEMORY}) target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
elseif(APPLE) elseif(APPLE)
target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME}) target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME})
@@ -101,16 +114,6 @@ macro(build_subdir)
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME FOLDER_NAME) cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME FOLDER_NAME)
set(SO "${FOLDER_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") set(SO "${FOLDER_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# 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}")
# 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 # 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}) add_library(${SO} MODULE ${MODULES_SUBDIR_SRCS})
set_target_properties(${SO} PROPERTIES set_target_properties(${SO} PROPERTIES
@@ -124,9 +127,9 @@ macro(build_subdir)
if(HAVE_LOCALIZATION) if(HAVE_LOCALIZATION)
add_dependencies(${SO} module_language) add_dependencies(${SO} module_language)
endif() endif()
# For Windows only, have the module link to the export library of Anope as well Winsock (most of the modules probably don't need this, but this is to be on the safe side) # For Windows only, have the module link to the export library of Anope .
if(WIN32) if(WIN32)
target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME} PUBLIC "Ws2_32" ${WIN32_MEMORY}) target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME})
set_target_properties(${SO} PROPERTIES VERSION "${VERSION_DOTTED}") set_target_properties(${SO} PROPERTIES VERSION "${VERSION_DOTTED}")
elseif(APPLE) elseif(APPLE)
target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME}) target_link_libraries(${SO} PUBLIC ${PROGRAM_NAME})
+1
View File
@@ -15,6 +15,7 @@
/// BEGIN CMAKE /// BEGIN CMAKE
/// pkg_check_modules("TRE" IMPORTED_TARGET REQUIRED "tre") /// pkg_check_modules("TRE" IMPORTED_TARGET REQUIRED "tre")
/// target_link_libraries(${SO} PRIVATE PkgConfig::TRE) /// target_link_libraries(${SO} PRIVATE PkgConfig::TRE)
/// target_compile_options(${SO} PRIVATE "-Wno-error=date-time") # Workaround for TRE bug 117
/// END CMAKE /// END CMAKE
#include "module.h" #include "module.h"
-4
View File
@@ -23,10 +23,6 @@ if(HAVE_LOCALIZATION)
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_PO} -o ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -c ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_PO} -o ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO}
MAIN_DEPENDENCY ${LANG_PO} MAIN_DEPENDENCY ${LANG_PO}
) )
# Add to cpack ignored files if not on Windows.
if(NOT WIN32)
add_to_cpack_ignored_files("${LANG_MO}")
endif()
# Install the new language file # Install the new language file
install(CODE "FILE(MAKE_DIRECTORY ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/)") install(CODE "FILE(MAKE_DIRECTORY ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/)")
+12 -44
View File
@@ -1,3 +1,9 @@
# If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators
if(MSVC)
add_library("win32_memory" STATIC "win32/win32_memory.cpp")
set_target_properties("win32_memory" PROPERTIES LINK_LIBRARIES "")
endif()
# Find all the *.cpp files within the current source directory, and sort the list # Find all the *.cpp files within the current source directory, and sort the list
file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
@@ -19,28 +25,9 @@ else()
list(APPEND SRC_SRCS socketengines/select.cpp) list(APPEND SRC_SRCS socketengines/select.cpp)
endif() endif()
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}")
# Under Windows, we also include a resource file to the build # Under Windows, we also include a resource file to the build
if(WIN32) 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/win32.rc LANGUAGE RC)
# Add the resource file to the list of sources
list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc) list(APPEND SRC_SRCS ${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/win32/win32.rc COMPILE_FLAGS "/i\"${Anope_SOURCE_DIR}/include\"")
endif()
# If compiling with Visual Studio, create a static library out of win32/win32_memory.cpp to be included with everything else, needed to override its override of new/delete operators
if(MSVC)
set_source_files_properties(win32/win32_memory.cpp PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
add_library(win32_memory STATIC win32/win32_memory.cpp)
set(WIN32_MEMORY win32_memory)
else()
set(WIN32_MEMORY)
endif() endif()
# 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 # 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
@@ -49,45 +36,26 @@ set_target_properties(${PROGRAM_NAME} PROPERTIES
BUILD_WITH_INSTALL_RPATH ON BUILD_WITH_INSTALL_RPATH ON
ENABLE_EXPORTS ON ENABLE_EXPORTS ON
INSTALL_RPATH_USE_LINK_PATH ON INSTALL_RPATH_USE_LINK_PATH ON
LINK_FLAGS "${LDFLAGS}"
) )
# On Windows, also link Anope to the Winsock library
if(WIN32) if(WIN32)
target_link_libraries(${PROGRAM_NAME} PUBLIC "Ws2_32" ${LINK_LIBS} ${WIN32_MEMORY})
set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}") set_target_properties(${PROGRAM_NAME} PROPERTIES VERSION "${VERSION_DOTTED}")
else()
target_link_libraries(${PROGRAM_NAME} PUBLIC ${LINK_LIBS})
endif()
# If being built with localisation we might need to link against libintl.
if(HAVE_LOCALIZATION AND Intl_LIBRARY)
target_link_libraries(${PROGRAM_NAME} PUBLIC ${Intl_LIBRARY})
endif() endif()
# Building the Anope executable requires the version.h header to be generated # Building the Anope executable requires the version.h header to be generated
add_dependencies(${PROGRAM_NAME} headers) add_dependencies(${PROGRAM_NAME} headers)
# Also require the language files if we have gettext # Also require the language files if we have gettext
if(HAVE_LOCALIZATION) if(HAVE_LOCALIZATION)
add_dependencies(${PROGRAM_NAME} language) add_dependencies(${PROGRAM_NAME} language)
endif() endif()
# Get the filename of the Anope executable as it is in on this system
set(SERVICES_BINARY "$<TARGET_FILE:${PROGRAM_NAME}>")
cmake_path(GET SERVICES_BINARY FILENAME SERVICES_BINARY)
# Add the Anope executable to the list of files for CPack to ignore
add_to_cpack_ignored_files("${SERVICES_BINARY}$" TRUE)
# Generate sysconf.h from the earlier configuration
configure_file(${Anope_SOURCE_DIR}/include/sysconf.h.cmake ${Anope_BINARY_DIR}/include/sysconf.h)
# Go into the following directories and run their CMakeLists.txt as well
if(NOT DISABLE_TOOLS)
add_subdirectory(tools)
endif()
# Set Anope to be installed to the bin directory # Set Anope to be installed to the bin directory
install(TARGETS ${PROGRAM_NAME} install(TARGETS ${PROGRAM_NAME}
DESTINATION ${BIN_DIR} DESTINATION ${BIN_DIR}
RUNTIME RUNTIME
) )
# Go into the following directories and run their CMakeLists.txt as well
if(NOT DISABLE_TOOLS)
add_subdirectory(tools)
endif()
+8 -10
View File
@@ -2,9 +2,6 @@
file(GLOB TOOLS_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") file(GLOB TOOLS_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp")
list(SORT TOOLS_SRCS) 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}")
# Iterate through all the source files # Iterate through all the source files
foreach(SRC ${TOOLS_SRCS}) foreach(SRC ${TOOLS_SRCS})
# Convert the source file extension to have no extension # Convert the source file extension to have no extension
@@ -13,31 +10,32 @@ foreach(SRC ${TOOLS_SRCS})
if(NOT SKIP) if(NOT SKIP)
# Generate the executable and set its linker flags, also set it to depend on the main Anope executable to be built beforehand # Generate the executable and set its linker flags, also set it to depend on the main Anope executable to be built beforehand
add_executable(${EXE} ${SRC}) add_executable(${EXE} ${SRC})
set_target_properties(${EXE} PROPERTIES LINK_FLAGS "${LDFLAGS}")
add_dependencies(${EXE} ${PROGRAM_NAME}) add_dependencies(${EXE} ${PROGRAM_NAME})
# Set the executable to be installed to the bin directory under the main directory # Set the executable to be installed to the bin directory under the main directory
install(TARGETS ${EXE} install(TARGETS ${EXE}
DESTINATION ${BIN_DIR} DESTINATION ${BIN_DIR}
RUNTIME RUNTIME
) )
# Add the executable to the list of files for CPack to ignore
set(EXE_BINARY "$<TARGET_FILE:${EXE}>")
cmake_path(GET EXE_BINARY FILENAME EXE_BINARY)
add_to_cpack_ignored_files("${EXE_BINARY}$" TRUE)
endif() endif()
endforeach() endforeach()
# If not on Windows, generate anope.service and anoperc # If not on Windows, generate anope.service and anoperc
if(NOT WIN32) if(NOT WIN32)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
configure_file(${Anope_SOURCE_DIR}/src/tools/anope.service.in ${Anope_BINARY_DIR}/src/tools/anope.service) configure_file(
${Anope_SOURCE_DIR}/src/tools/anope.service.in
${Anope_BINARY_DIR}/src/tools/anope.service
)
install( install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anope.service PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anope.service
DESTINATION ${BIN_DIR} DESTINATION ${BIN_DIR}
) )
endif() endif()
configure_file(${Anope_SOURCE_DIR}/src/tools/anoperc.in ${Anope_BINARY_DIR}/src/tools/anoperc) configure_file(
${Anope_SOURCE_DIR}/src/tools/anoperc.in
${Anope_BINARY_DIR}/src/tools/anoperc
)
install( install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/anoperc
DESTINATION ${BIN_DIR} DESTINATION ${BIN_DIR}