diff options
author | Sadie Powell <sadie@witchery.services> | 2021-04-27 17:49:06 +0100 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2021-04-27 17:49:21 +0100 |
commit | e2aeab970bcbd94ea3531b345d2ec4df111f0d60 (patch) | |
tree | fab4021c9e78bf9a63045d7d0e5cd9ea9acb60ab /CMakeLists.txt | |
parent | ef4fd869ae634b546a882b1741303705fa216fc7 (diff) |
Remove the repeated conditions in cmake endif/else statements.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f56ae9bc..2ec1bdfaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,11 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) if(POLICY CMP0026) cmake_policy(SET CMP0026 OLD) - endif(POLICY CMP0026) + endif() if(POLICY CMP0007) cmake_policy(SET CMP0007 OLD) - endif(POLICY CMP0007) -endif(COMMAND cmake_policy) + endif() +endif() # Set the project as C++ primarily, but have C enabled for the checks required later project(Anope CXX) @@ -21,21 +21,21 @@ string(REGEX MATCH "-patch .*$" HAS_PATCH "${ONLY_VERSION}") if(HAS_PATCH) string(REGEX REPLACE "(.*)-patch .*" "\\1" MINOR_VERSION "${ONLY_VERSION}") string(REGEX REPLACE ".*-patch (.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}") -else(HAS_PATCH) +else() string(REGEX MATCH "\\." HAS_DOT "${ONLY_VERSION}") if(HAS_DOT) string(REGEX REPLACE "(.*)\\..*" "\\1" MINOR_VERSION "${ONLY_VERSION}") string(REGEX REPLACE ".*\\.(.*)" "\\1" PATCH_VERSION "${ONLY_VERSION}") - else(HAS_DOT) + else() string(REGEX REPLACE "(.*)-beta" "\\1" MINOR_VERSION "${ONLY_VERSION}") if(MINOR_VERSION STREQUAL "4-1\n") set(PATCH_VERSION 1) - else(MINOR_VERSION STREQUAL "4-1\n") + else() set(PATCH_VERSION 0) - endif(MINOR_VERSION STREQUAL "4-1\n") + endif() set(MINOR_VERSION 4) - endif(HAS_DOT) -endif(HAS_PATCH) + endif() +endif() # Detect is we are using CMake 2.6 or better, these versions include functions that require less work than CMake 2.4 does if(MINOR_VERSION GREATER 5) @@ -43,30 +43,30 @@ if(MINOR_VERSION GREATER 5) set(CMAKE248_OR_BETTER TRUE) set(CMAKE244_OR_BETTER TRUE) set(CMAKE242_OR_BETTER TRUE) -else(MINOR_VERSION GREATER 5) +else() set(CMAKE26_OR_BETTER FALSE) # Also detect if we are using CMake 2.4.8 or better, the FIND sub-command of list() is nonexistent in earlier versions if(PATCH_VERSION GREATER 7) set(CMAKE248_OR_BETTER TRUE) set(CMAKE244_OR_BETTER TRUE) set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 7) + else() set(CMAKE248_OR_BETTER FALSE) # Also detect if we are using CMake 2.4.4 or better, the CheckCXXCompilerFlag module and SORT sub-command of list() are nonexistent in earlier versions if(PATCH_VERSION GREATER 3) set(CMAKE244_OR_BETTER TRUE) set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 3) + else() set(CMAKE244_OR_BETTER FALSE) # ALSO detect if we are using CMake 2.4.2 or better, the APPEND sub-command of list() is nonexistent in earlier versions if(PATCH_VERSION GREATER 1) set(CMAKE242_OR_BETTER TRUE) - else(PATCH_VERSION GREATER 1) + else() set(CMAKE242_OR_BETTER FALSE) - endif(PATCH_VERSION GREATER 1) - endif(PATCH_VERSION GREATER 3) - endif(PATCH_VERSION GREATER 7) -endif(MINOR_VERSION GREATER 5) + endif() + endif() + endif() +endif() # 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) @@ -86,11 +86,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) string(REGEX REPLACE "^(\\d+\\.\\d+)" "\\1" GCC_VERSION ${GCC_FULL_VERSION}) if(GCC_VERSION LESS 4.2) message(FATAL_ERROR "Your compiler is too old to build Anope. Upgrade to GCC 4.2 or newer!") - endif(GCC_VERSION LESS 4.2) + endif() if(GCC_VERSION GREATER 6.0 OR GCC_VERSION EQUAL 6.0) set(CXXFLAGS "${CXXFLAGS} -fno-delete-null-pointer-checks") - endif(GCC_VERSION GREATER 6.0 OR GCC_VERSION EQUAL 6.0) -endif(CMAKE_COMPILER_IS_GNUCXX) + endif() +endif() # If we are using a GNU compiler (have to use CXX because it seems to fail on C), we will be able to determine it's default paths for libraries and includes if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") @@ -101,9 +101,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") # Replace the colons in the list with semicolons (only when not on MinGW, which uses semicolons already), and if on MinGW, just copy the line if(NOT MINGW) string(REGEX REPLACE ":" ";" LIBRARIES ${LINE}) - else(NOT MINGW) + else() set(LIBRARIES "${LINE}") - endif(NOT MINGW) + endif() # Iterate through the libraries foreach(LIBRARY ${LIBRARIES}) # Check if the first character is an equal sign, and skip that library directory as it is (I believe) the primary default and shows up later in the list anyways @@ -112,12 +112,12 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") # If the directory had no = in front of it, make sure it's absolute and add it to the list of default library directories get_filename_component(LIBRARY ${LIBRARY} ABSOLUTE) append_to_list(DEFAULT_LIBRARY_DIRS ${LIBRARY}) - endif(NOT FIRST_CHAR STREQUAL "=") - endforeach(LIBRARY) + endif() + endforeach() # Remove duplicate entries from the list if(DEFAULT_LIBRARY_DIRS) remove_list_duplicates(DEFAULT_LIBRARY_DIRS) - endif(DEFAULT_LIBRARY_DIRS) + endif() # Create a temporary file to test for the default include directories FILE(WRITE empty.cpp "") # Next, we look for the compiler's default include directories @@ -134,11 +134,11 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") # If the line has the following on it, the next lines will contain directory names if(LINE STREQUAL "#include <...> search starts here:") set(IN_SEARCH TRUE) - else(LINE STREQUAL "#include <...> search starts here:") + else() # If the line has the following on it, we hit the end of the list if(LINE STREQUAL "End of search list.") set(IN_SEARCH FALSE) - else(LINE STREQUAL "End of search list.") + else() # If we are within the block between the above two lines... if(IN_SEARCH) # Get everything but the first character of the line @@ -151,15 +151,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") get_filename_component(INCLUDE ${INCLUDE} ABSOLUTE) # Add that directory to the list of default include directories append_to_list(DEFAULT_INCLUDE_DIRS ${INCLUDE}) - endif(IN_SEARCH) - endif(LINE STREQUAL "End of search list.") - endif(LINE STREQUAL "#include <...> search starts here:") - endforeach(LINE) + endif() + endif() + endif() + endforeach() # Remove duplicate entries from the list if(DEFAULT_INCLUDE_DIRS) remove_list_duplicates(DEFAULT_INCLUDE_DIRS) - endif(DEFAULT_INCLUDE_DIRS) -endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$") + endif() +endif() # If we are using Visual Studio, locate the path of the Windows Server 2008 SDK or Windows Server 2003 Platform SDK, depending on which is installed if(MSVC) @@ -178,19 +178,19 @@ if(MSVC) if(WSDK2003_PATH STREQUAL "/registry") # The SDK was never found, set the path to nothing set(WSDK_PATH "") - else(WSDK2003_PATH STREQUAL "/registry") + else() set(WSDK_PATH "${WSDK2003_PATH}") - endif(WSDK2003_PATH STREQUAL "/registry") - else(WSDK2008_PATH STREQUAL "/registry") + endif() + else() set(WSDK_PATH "${WSDK2008_PATH}") - endif(WSDK2008_PATH STREQUAL "/registry") - else(WSDK2003_PATH STREQUAL "/registry") + endif() + else() set(WSDK_PATH "${WSDK2003_PATH}") - endif(WSDK2003_PATH STREQUAL "/registry") - else(WSDK2008_PATH STREQUAL "/registry") + endif() + else() set(WSDK_PATH "${WSDK2008_PATH}") - endif(WSDK2008_PATH STREQUAL "/registry") -endif(MSVC) + endif() +endif() # If the user specifies -DCMAKE_BUILD_TYPE on the command line, take their definition # and dump it in the cache along with proper documentation, otherwise set CMAKE_BUILD_TYPE @@ -199,17 +199,17 @@ endif(MSVC) if(NOT MSVC) if(CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - else(CMAKE_BUILD_TYPE) + else() set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") - endif(CMAKE_BUILD_TYPE) -endif(NOT MSVC) + endif() +endif() # If running under MinGW, we have to force the resource compiler settings (hopefully this will be fixed in a later version of CMake) if(MINGW) set(CMAKE_RC_COMPILER_INIT windres) enable_language(RC) set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>") -endif(MINGW) +endif() # Include the checking functions used later in this CMakeLists.txt include(CheckFunctionExists) @@ -218,19 +218,19 @@ include(CheckTypeSize) include(CheckLibraryExists) if(CMAKE244_OR_BETTER) include(CheckCXXCompilerFlag) -else(CMAKE244_OR_BETTER) +else() include(TestCXXAcceptsFlag) -endif(CMAKE244_OR_BETTER) +endif() # If extra include directories were specified, tell cmake about them. if(EXTRA_INCLUDE) include_directories(${EXTRA_INCLUDE}) -endif(EXTRA_INCLUDE) +endif() # If extra library directories were specified, tell cmake about them. if(EXTRA_LIBS) link_directories(${EXTRA_LIBS}) -endif(EXTRA_LIBS) +endif() # Find gettext find_package(Gettext) @@ -245,14 +245,14 @@ include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${An # Pass on REPRODUCIBLE_BUILD if(REPRODUCIBLE_BUILD) add_definitions(-DREPRODUCIBLE_BUILD) -endif(REPRODUCIBLE_BUILD) +endif() # If using Windows, always add the _WIN32 define if(WIN32) add_definitions(-D_WIN32) # And include the windows specific folder for our anope_windows.h include_directories(${Anope_SOURCE_DIR}/src/win32) -endif(WIN32) +endif() # If using Visual Studio, set the C++ flags accordingly if(MSVC) @@ -264,7 +264,7 @@ if(MSVC) set(CXXFLAGS "${CXXFLAGS} /W4 /wd4100 /wd4127 /wd4250 /wd4251 /wd4355 /wd4706 /wd4800 /wd4996 /EHs") add_definitions(-DMSVCPP -D_CRT_SECURE_NO_WARNINGS) # Otherwise, we're not using Visual Studio -else(MSVC) +else() # 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 (only on GNU compiler) @@ -272,29 +272,29 @@ else(MSVC) set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic ${CMAKE_CXX_FLAGS}") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore") - endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + endif() # If we aren't on a *nix system, we are using MinGW - else(UNIX) + else() # Also, if we are building under MinGW, add another define for MinGW if(MINGW) add_definitions(-DMINGW) - endif(MINGW) - endif(UNIX) -endif(MSVC) + endif() + 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_DL_LIBS) append_to_list(LINK_LIBS ${CMAKE_DL_LIBS}) -endif(CMAKE_DL_LIBS) +endif() # Under MinGW, the -shared flag isn't properly set in the module-specific linker flags, add it from the C flags for shared libraries if(MINGW) set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") -endif(MINGW) +endif() if(NOT PROGRAM_NAME) set(PROGRAM_NAME anope) -endif(NOT PROGRAM_NAME) +endif() # If we are not using Visual Studio, we'll run the following checks if(NOT MSVC) @@ -302,14 +302,14 @@ if(NOT MSVC) if(CMAKE244_OR_BETTER) # If using CMake 2.4.4 or better, we can use check_cxx_compiler_flag check_cxx_compiler_flag(-pipe HAVE_PIPE_FLAG) - else(CMAKE244_OR_BETTER) + else() # If using CMake 2.4.3 or older, we will use check_cxx_accepts_flags instead check_cxx_accepts_flag(-pipe HAVE_PIPE_FLAG) - endif(CMAKE244_OR_BETTER) + endif() # If the flag was accepted, add it to the list of flags if(HAVE_PIPE_FLAG) set(CXXFLAGS "${CXXFLAGS} -pipe") - endif(HAVE_PIPE_FLAG) + endif() # The following are additional library checks, they are not required for Windows if(NOT WIN32) @@ -317,37 +317,37 @@ if(NOT MSVC) check_library_exists(socket socket "" HAVE_SOCKET_LIB) if(HAVE_SOCKET_LIB) append_to_list(LINK_LIBS socket) - endif(HAVE_SOCKET_LIB) + endif() # Check if inet_addr is within the nsl library (if the library exists), and add it to the linker flags if needed check_library_exists(nsl inet_addr "" HAVE_NSL_LIB) if(HAVE_NSL_LIB) append_to_list(LINK_LIBS nsl) - endif(HAVE_NSL_LIB) + endif() # Check if pthread_create is within the pthread library (if the library exists), and add it to the linker flags if needed check_library_exists(pthread pthread_create "" HAVE_PTHREAD) if(HAVE_PTHREAD) if(NOT APPLE) set(LDFLAGS "${LDFLAGS} -pthread") - endif(NOT APPLE) - else(HAVE_PTHREAD) + endif() + else() message(FATAL_ERROR "The pthread library is required to build Anope") - endif(HAVE_PTHREAD) - endif(NOT WIN32) -endif(NOT MSVC) + endif() + endif() +endif() # If DEFUMASK wasn't passed to CMake, set a default depending on if RUNGROUP was passed in or not if(NOT DEFUMASK) if(RUNGROUP) set(DEFUMASK "007") - else(RUNGROUP) + else() set(DEFUMASK "077") - endif(RUNGROUP) -endif(NOT DEFUMASK) + endif() +endif() # Set the DEBUG_BUILD for sysconf.h if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") set(DEBUG_BUILD TRUE) -endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") +endif() # Check for the existence of the following include files check_include_file(cstdint HAVE_CSTDINT) @@ -364,11 +364,11 @@ check_function_exists(kqueue HAVE_KQUEUE) # Strip the leading and trailing spaces from the compile flags if(CXXFLAGS) strip_string(${CXXFLAGS} CXXFLAGS) -endif(CXXFLAGS) +endif() # Strip the leading and trailing spaces from the linker flags if(LDFLAGS) strip_string(${LDFLAGS} LDFLAGS) -endif(LDFLAGS) +endif() # Search for the following programs find_program(GREP grep) @@ -381,30 +381,30 @@ if(INSTDIR) set(CMAKE_INSTALL_PREFIX "${INSTDIR}") elseif(NOT CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/anope") -endif(INSTDIR) +endif() # Set default paths for various directories if not already defined if(NOT BIN_DIR) set(BIN_DIR "bin") -endif(NOT BIN_DIR) +endif() if(NOT DB_DIR) set(DB_DIR "data") -endif(NOT DB_DIR) +endif() if(NOT DOC_DIR) set(DOC_DIR "doc") -endif(NOT DOC_DIR) +endif() if(NOT CONF_DIR) set(CONF_DIR "conf") -endif(NOT CONF_DIR) +endif() if(NOT LIB_DIR) set(LIB_DIR "lib") -endif(NOT LIB_DIR) +endif() if(NOT LOCALE_DIR) set(LOCALE_DIR "locale") -endif(NOT LOCALE_DIR) +endif() if(NOT LOGS_DIR) set(LOGS_DIR "logs") -endif(NOT LOGS_DIR) +endif() # Version number processing # Find all lines in src/version.sh that start with VERSION_ @@ -418,8 +418,8 @@ foreach(VERSION_STR ${VERSIONS}) if(${VERSION_LEN} GREATER 1) list(GET VERSION_OUT 1 VERSION_DATA) set(VERSION_${VERSION_TYPE} ${VERSION_DATA}) - endif(${VERSION_LEN} GREATER 1) -endforeach(VERSION_STR ${VERSIONS}) + endif() +endforeach() # Default build version to 0 set(VERSION_BUILD 0) @@ -437,8 +437,8 @@ if(EXISTS "${Anope_SOURCE_DIR}/include/version.h") string(SUBSTRING ${VERSION_STR} 22 ${VERSION_NUM_LEN} VERSION) # Set VERSION_BUILD correctly set(VERSION_BUILD ${VERSION}) - endforeach(VERSION_STR ${VERSIONS}) -endif(EXISTS "${Anope_SOURCE_DIR}/include/version.h") + endforeach() +endif() # Set the version variables based on what was found above set(VERSION_COMMA "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_BUILD}") @@ -451,7 +451,7 @@ set(VERSION_FULL_NOBUILD "${VERSION_DOTTED_NOBUILD}${VERSION_EXTRA}") if(WIN32) # Generate the win32.rc file using the above variables configure_file(${Anope_SOURCE_DIR}/src/win32/win32.rc.cmake ${Anope_BINARY_DIR}/src/win32/win32.rc) -endif(WIN32) +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) @@ -466,8 +466,8 @@ if(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR}) # 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(MSVC) -endif(${Anope_SOURCE_DIR} STREQUAL ${Anope_BINARY_DIR}) + endif() +endif() # Go into the following directories and run their CMakeLists.txt as well add_subdirectory(data) @@ -486,13 +486,13 @@ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${DB_ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LOGS_DIR}\")") if(WIN32) install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${DB_DIR}/runtime\")") -endif(WIN32) +endif() # On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory if(NOT WIN32 AND RUNGROUP) install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${DB_DIR}/backups\")") install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${LOGS_DIR}\")") install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\")") -endif(NOT WIN32 AND RUNGROUP) +endif() # On Windows platforms, install extra files if(WIN32) install(FILES ${Anope_SOURCE_DIR}/src/win32/anope.bat @@ -502,7 +502,7 @@ if(WIN32) # Package any DLLs in src/win/ file(GLOB EXTRA_DLLS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${Anope_SOURCE_DIR}/src/win32/*.dll") install(FILES ${EXTRA_DLLS} DESTINATION ${BIN_DIR}) -endif(WIN32) +endif() install(CODE "file(REMOVE_RECURSE \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${LIB_DIR}/modules\")") @@ -543,10 +543,10 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") set(CPACK_NSIS_INSTALLED_ICON_NAME "${SERVICES_BINARY}") set(CPACK_NSIS_URL_INFO_ABOUT "https://www.anope.org/") set(CPACK_NSIS_COMPRESSOR "/SOLID lzma") - endif(WIN32) + endif() set(CPACK_SOURCE_PACKAGE_FILE_NAME "anope-${VERSION_FULL_NOBUILD}-source") set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_IGNORE_FILES "$ENV{CPACK_IGNORED_FILES}") set(CPACK_MONOLITHIC_INSTALL TRUE) include(CPack) -endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") +endif() |