1
0

fix package , fix ci build, tune cmake flags and rules

* tune up gitlab ci:
  * remove package part cos we have obs service
  * add feladora 38 and feladora 37 too
  * remove winbuntu 14, add debian 11, 12, winbuntu 17, 20, 22
  * use minenux minetest repo game (seems not work)
  * remove non buildable stages.. only build and package shit win
  * set multicraft as prefix path and artifacts
  * back cmake in list new behaviour for blacklist locales
  * gitlab ci buil for debian 8 using backports on jsoncpp
  * solved https://github.com/minetest/minetest/issues/6567
  * solved https://github.com/minetest/minetest/issues/7681
* cmake fixed to minimum supported and c++11 standar able
  * close #51
  * allow distro hardening and cflags env
    close #55
  * Fix no locales being generated when APPLY_LOCALE_BLACKLIST=0
  * Fix linking with Postgres libs:
  * closes https://github.com/minetest/minetest/issues/12149
  * closes https://github.com/minetest/minetest/issues/11219
  * PostgreSQL fallback code missed the includes https://github.com/minetest/minetest/issues/11219
  * a24899bf2d
  * 3e2145d662
  * integrates https://github.com/minetest/minetest/pull/11215
  *  a24899bf2d
  * backported 998e4820c9
This commit is contained in:
mckaygerhard 2024-05-30 20:51:01 -04:00
parent ac78553119
commit 0181518c79
4 changed files with 169 additions and 17 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 2.6)
cmake_policy(SET CMP0025 OLD) cmake_policy(SET CMP0025 OLD)
@ -6,11 +6,45 @@ cmake_policy(SET CMP0025 OLD)
project(multicraft) project(multicraft)
set(PROJECT_NAME_CAPITALIZED "MultiCraft") set(PROJECT_NAME_CAPITALIZED "MultiCraft")
set(CMAKE_CXX_STANDARD 14) # check compatible compileer must be after project definition and set flags, assume if C++ is installed also CC is installed
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(GCC_MINIMUM_VERSION "5.1") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(CLANG_MINIMUM_VERSION "3.5") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
elseif (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu1x")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using gnu compiler")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++1y")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using clang compiler")
else()
if (CMAKE_VERSION VERSION_GREATER 3.0)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
else()
if(APPLE)
# Fix behavior of CMAKE_CXX_STANDARD when targeting macOS.
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif ()
endif ()
endif()
message(STATUS "using default installed compiler")
endif()
# Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
set(VERSION_MAJOR 2) set(VERSION_MAJOR 2)
set(VERSION_MINOR 0) set(VERSION_MINOR 0)
@ -25,7 +59,7 @@ set(ENABLE_UPDATE_CHECKER (NOT ${DEVELOPMENT_BUILD}) CACHE BOOL
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA) if(VERSION_EXTRA)
set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA}) set(VERSION_STRING "${VERSION_STRING}-${VERSION_EXTRA}")
elseif(DEVELOPMENT_BUILD) elseif(DEVELOPMENT_BUILD)
set(VERSION_STRING "${VERSION_STRING}-dev") set(VERSION_STRING "${VERSION_STRING}-dev")
endif() endif()
@ -189,10 +223,11 @@ install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
install(FILES "multicraft.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}") install(FILES "multicraft.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6") install(FILES "doc/minetest.6" DESTINATION "${MANDIR}/man6 RENAME "${PROJECT_NAME}.6")
install(FILES "misc/net.minetest.minetest.desktop" DESTINATION "${XDG_APPS_DIR}") install(FILES "doc/minetestserver.6" DESTINATION "${MANDIR}/man6 RENAME "${PROJECT_NAME}server.6")
install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}") install(FILES "misc/net.minetest.minetest.desktop" DESTINATION "${XDG_APPS_DIR}" RENAME "net.minetest.${PROJECT_NAME}.desktop")
install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps") install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}" RENAME "net.minetest.${PROJECT_NAME}.appdata.xml")
install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps" RENAME "multicraft.svg")
install(FILES "misc/multicraft-xorg-icon-128.png" install(FILES "misc/multicraft-xorg-icon-128.png"
DESTINATION "${ICONDIR}/hicolor/128x128/apps" DESTINATION "${ICONDIR}/hicolor/128x128/apps"
RENAME "multicraft.png") RENAME "multicraft.png")

View File

@ -8,7 +8,11 @@ option(ENABLE_SYSTEM_JSONCPP "Enable using a system-wide JSONCPP. May cause seg
if(ENABLE_SYSTEM_JSONCPP) if(ENABLE_SYSTEM_JSONCPP)
find_library(JSON_LIBRARY NAMES jsoncpp) find_library(JSON_LIBRARY NAMES jsoncpp)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
find_path(JSON_INCLUDE_DIR json/features.h PATH_SUFFIXES jsoncpp)
else()
find_path(JSON_INCLUDE_DIR json/allocator.h PATH_SUFFIXES jsoncpp) find_path(JSON_INCLUDE_DIR json/allocator.h PATH_SUFFIXES jsoncpp)
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Json DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR) find_package_handle_standard_args(Json DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)

View File

@ -63,6 +63,45 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g")
endif(CMAKE_COMPILER_IS_GNUCC) endif(CMAKE_COMPILER_IS_GNUCC)
# check compatible compileer must be after project definition and set flags, assume if C++ is installed also CC is installed
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
elseif (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu1x")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using gnu compiler")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++1y")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using clang compiler")
else()
if (CMAKE_VERSION VERSION_GREATER 3.0)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
else()
if(APPLE)
# Fix behavior of CMAKE_CXX_STANDARD when targeting macOS.
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif ()
endif ()
endif()
message(STATUS "using default installed compiler")
endif()
add_subdirectory(src build) add_subdirectory(src build)

View File

@ -169,7 +169,18 @@ option(ENABLE_POSTGRESQL "Enable PostgreSQL backend" TRUE)
set(USE_POSTGRESQL FALSE) set(USE_POSTGRESQL FALSE)
if(ENABLE_POSTGRESQL) if(ENABLE_POSTGRESQL)
find_package("PostgreSQL") if(CMAKE_VERSION VERSION_LESS "3.20")
find_package(PostgreSQL QUIET)
# Before CMake 3.20 FindPostgreSQL.cmake always looked for server includes
# but we don't need them, so continue anyway if only those are missing.
if(PostgreSQL_INCLUDE_DIR AND PostgreSQL_LIBRARY)
set(PostgreSQL_FOUND TRUE)
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR})
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY})
endif()
else()
find_package(PostgreSQL)
endif()
if(PostgreSQL_FOUND) if(PostgreSQL_FOUND)
set(USE_POSTGRESQL TRUE) set(USE_POSTGRESQL TRUE)
@ -733,11 +744,13 @@ option(APPLY_LOCALE_BLACKLIST "Use a blacklist to avoid broken locales" TRUE)
if (GETTEXTLIB_FOUND AND APPLY_LOCALE_BLACKLIST) if (GETTEXTLIB_FOUND AND APPLY_LOCALE_BLACKLIST)
set(GETTEXT_USED_LOCALES "") set(GETTEXT_USED_LOCALES "")
foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
if (NOT "${LOCALE}" IN_LIST GETTEXT_BLACKLISTED_LOCALES) if (NOT ";${GETTEXT_BLACKLISTED_LOCALES};" MATCHES ";${LOCALE};")
list(APPEND GETTEXT_USED_LOCALES ${LOCALE}) list(APPEND GETTEXT_USED_LOCALES ${LOCALE})
endif() endif()
endforeach() endforeach()
message(STATUS "Locale blacklist applied; Locales used: ${GETTEXT_USED_LOCALES}") message(STATUS "Locale blacklist applied; Locales used: ${GETTEXT_USED_LOCALES}")
elseif (GETTEXTLIB_FOUND)
set(GETTEXT_USED_LOCALES ${GETTEXT_AVAILABLE_LOCALES})
endif() endif()
# Set some optimizations and tweaks # Set some optimizations and tweaks
@ -784,6 +797,47 @@ else()
else() else()
set(RELEASE_WARNING_FLAGS "") set(RELEASE_WARNING_FLAGS "")
endif() endif()
# check compatible compileer must be after project definition and set flags, assume if C++ is installed also CC is installed
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
elseif (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.6)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu1x")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using gnu compiler")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++1y")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
message(STATUS "using clang compiler")
else()
if (CMAKE_VERSION VERSION_GREATER 3.0)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
else()
if(APPLE)
# Fix behavior of CMAKE_CXX_STANDARD when targeting macOS.
if (POLICY CMP0025)
cmake_policy(SET CMP0025 NEW)
endif ()
endif ()
endif()
message(STATUS "using default installed compiler")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(WARNING_FLAGS "${WARNING_FLAGS} -Wsign-compare") set(WARNING_FLAGS "${WARNING_FLAGS} -Wsign-compare")
endif() endif()
@ -809,6 +863,21 @@ else()
# - we don't deal with Inf/NaN or signed zero # - we don't deal with Inf/NaN or signed zero
set(MATH_FLAGS "-fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signed-zeros") set(MATH_FLAGS "-fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signed-zeros")
# only related to moder x86 32bit platforms using gcc compilers
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.7)
# Enable SSE for floating point math on 32-bit x86 by default
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
check_c_source_compiles("#ifndef __i686__\n#error\n#endif\nint main(){}" IS_I686)
if(IS_I686)
message(STATUS "Detected Intel x86: using SSE instead of x87 FPU")
set(OTHER_FLAGS "${OTHER_FLAGS} -mfpmath=sse -msse")
endif()
endif()
endif()
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops") set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
@ -822,8 +891,13 @@ else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}")
endif() endif()
endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} $ENV{CPPFLAGS}")
set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS} $ENV{CFLAGS} ")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS} -g")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} ${CMAKE_C_FLAGS} -O1 -g")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} ${CMAKE_C_FLAGS} $ENV{CFLAGS} -g")
if(USE_GPROF) if(USE_GPROF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
@ -912,7 +986,7 @@ if(BUILD_CLIENT)
if(USE_GETTEXT) if(USE_GETTEXT)
foreach(LOCALE ${GETTEXT_USED_LOCALES}) foreach(LOCALE ${GETTEXT_USED_LOCALES})
set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
set(MO_BUILD_PATH "${MO_BUILD_PATH}/minetest.mo") set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH}) install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH})
endforeach() endforeach()
endif() endif()
@ -952,7 +1026,7 @@ if (USE_GETTEXT)
foreach(LOCALE ${GETTEXT_USED_LOCALES}) foreach(LOCALE ${GETTEXT_USED_LOCALES})
set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
set(MO_FILE_PATH "${MO_BUILD_PATH}/minetest.mo") set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
add_custom_command(OUTPUT ${MO_BUILD_PATH} add_custom_command(OUTPUT ${MO_BUILD_PATH}
COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}