fix compilaton and ci/build due luajit module package process
* fix CFLAGS/CXXFLAGS from env for pacakgers in this branch dont override or over set again the flags
This commit is contained in:
parent
e36906f5ba
commit
0375e89047
@ -6,16 +6,56 @@
|
|||||||
#
|
#
|
||||||
# This module is similar to FindLua51.cmake except that it finds LuaJit instead.
|
# This module is similar to FindLua51.cmake except that it finds LuaJit instead.
|
||||||
|
|
||||||
find_package (PkgConfig REQUIRED)
|
FIND_PATH(LUA_INCLUDE_DIR luajit.h
|
||||||
pkg_check_modules (LuaJIT QUIET REQUIRED luajit)
|
HINTS
|
||||||
set (LUA_LIBRARY ${LuaJIT_LIBRARIES})
|
$ENV{LUA_DIR}
|
||||||
set (LUA_INCLUDE_DIR ${LuaJIT_INCLUDE_DIRS})
|
PATH_SUFFIXES include/luajit-2.1 include/luajit-2.0 include/luajit-5_1-2.1 include/luajit-5_1-2.0 include luajit
|
||||||
set (LUA_VERSION_STRING ${LuaJIT_VERSION})
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw # Fink
|
||||||
|
/opt/local # DarwinPorts
|
||||||
|
/opt/csw # Blastwave
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test if running on vcpkg toolchain
|
||||||
|
if(DEFINED VCPKG_TARGET_TRIPLET AND DEFINED VCPKG_APPLOCAL_DEPS)
|
||||||
|
# On vcpkg luajit is 'lua51' and normal lua is 'lua'
|
||||||
|
FIND_LIBRARY(LUA_LIBRARY
|
||||||
|
NAMES lua51
|
||||||
|
HINTS
|
||||||
|
$ENV{LUA_DIR}
|
||||||
|
PATH_SUFFIXES lib
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
FIND_LIBRARY(LUA_LIBRARY
|
||||||
|
NAMES luajit-5.1
|
||||||
|
HINTS
|
||||||
|
$ENV{LUA_DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/sw
|
||||||
|
/opt/local
|
||||||
|
/opt/csw
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/luajit.h")
|
||||||
|
FILE(STRINGS "${LUA_INCLUDE_DIR}/luajit.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT .+\"")
|
||||||
|
|
||||||
|
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"LuaJIT ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||||
|
UNSET(lua_version_str)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJit
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LuaJIT
|
||||||
REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR
|
REQUIRED_VARS LUA_LIBRARY LUA_INCLUDE_DIR
|
||||||
VERSION_VAR LUA_VERSION_STRING)
|
VERSION_VAR LUA_VERSION_STRING)
|
||||||
|
|
||||||
|
@ -181,19 +181,6 @@ option(ENABLE_POSTGRESQL "Enable PostgreSQL backend" TRUE)
|
|||||||
set(USE_POSTGRESQL FALSE)
|
set(USE_POSTGRESQL FALSE)
|
||||||
|
|
||||||
if(ENABLE_POSTGRESQL)
|
if(ENABLE_POSTGRESQL)
|
||||||
find_program(POSTGRESQL_CONFIG_EXECUTABLE pg_config DOC "pg_config")
|
|
||||||
find_library(POSTGRESQL_LIBRARY pq)
|
|
||||||
if(POSTGRESQL_CONFIG_EXECUTABLE)
|
|
||||||
execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE} --includedir-server
|
|
||||||
OUTPUT_VARIABLE POSTGRESQL_SERVER_INCLUDE_DIRS
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE}
|
|
||||||
OUTPUT_VARIABLE POSTGRESQL_CLIENT_INCLUDE_DIRS
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
# This variable is case sensitive for the cmake PostgreSQL module
|
|
||||||
set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${POSTGRESQL_SERVER_INCLUDE_DIRS} ${POSTGRESQL_CLIENT_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.20")
|
if(CMAKE_VERSION VERSION_LESS "3.20")
|
||||||
find_package(PostgreSQL QUIET)
|
find_package(PostgreSQL QUIET)
|
||||||
# Before CMake 3.20 FindPostgreSQL.cmake always looked for server includes
|
# Before CMake 3.20 FindPostgreSQL.cmake always looked for server includes
|
||||||
@ -207,7 +194,7 @@ if(ENABLE_POSTGRESQL)
|
|||||||
find_package(PostgreSQL)
|
find_package(PostgreSQL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(POSTGRESQL_FOUND)
|
if(PostgreSQL_FOUND)
|
||||||
set(USE_POSTGRESQL TRUE)
|
set(USE_POSTGRESQL TRUE)
|
||||||
message(STATUS "PostgreSQL backend enabled")
|
message(STATUS "PostgreSQL backend enabled")
|
||||||
# This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
|
# This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
|
||||||
@ -222,7 +209,7 @@ option(ENABLE_LEVELDB "Enable LevelDB backend" TRUE)
|
|||||||
set(USE_LEVELDB FALSE)
|
set(USE_LEVELDB FALSE)
|
||||||
|
|
||||||
if(ENABLE_LEVELDB)
|
if(ENABLE_LEVELDB)
|
||||||
find_library(LEVELDB_LIBRARY leveldb)
|
find_library(LEVELDB_LIBRARY NAMES leveldb libleveldb)
|
||||||
find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb)
|
find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb)
|
||||||
if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
|
if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
|
||||||
set(USE_LEVELDB TRUE)
|
set(USE_LEVELDB TRUE)
|
||||||
@ -272,6 +259,12 @@ if(NOT MSVC)
|
|||||||
set(USE_GPROF FALSE CACHE BOOL "Use -pg flag for g++")
|
set(USE_GPROF FALSE CACHE BOOL "Use -pg flag for g++")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Haiku endian support
|
||||||
|
if(HAIKU)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_BSD_SOURCE")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Use cmake_config.h
|
# Use cmake_config.h
|
||||||
add_definitions(-DUSE_CMAKE_CONFIG_H)
|
add_definitions(-DUSE_CMAKE_CONFIG_H)
|
||||||
|
|
||||||
@ -315,7 +308,9 @@ if(WIN32)
|
|||||||
else()
|
else()
|
||||||
# Unix probably
|
# Unix probably
|
||||||
if(BUILD_CLIENT)
|
if(BUILD_CLIENT)
|
||||||
find_package(X11 REQUIRED)
|
if(NOT HAIKU AND NOT APPLE)
|
||||||
|
find_package(X11 REQUIRED)
|
||||||
|
endif(NOT HAIKU AND NOT APPLE)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(JPEG REQUIRED)
|
find_package(JPEG REQUIRED)
|
||||||
find_package(BZip2 REQUIRED)
|
find_package(BZip2 REQUIRED)
|
||||||
@ -343,12 +338,15 @@ else()
|
|||||||
endif(HAVE_LIBRT)
|
endif(HAVE_LIBRT)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
|
||||||
if(NOT APPLE)
|
# The following dependencies are transitive dependencies from Irrlicht.
|
||||||
# This way Xxf86vm is found on OpenBSD too
|
# Minetest itself does not use them, but we link them so that statically
|
||||||
|
# linking Irrlicht works.
|
||||||
|
if(NOT HAIKU AND NOT APPLE)
|
||||||
|
# This way Xxf86vm is found on OpenBSD too
|
||||||
find_library(XXF86VM_LIBRARY Xxf86vm)
|
find_library(XXF86VM_LIBRARY Xxf86vm)
|
||||||
mark_as_advanced(XXF86VM_LIBRARY)
|
mark_as_advanced(XXF86VM_LIBRARY)
|
||||||
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
|
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
|
||||||
endif(NOT APPLE)
|
endif(NOT HAIKU AND NOT APPLE)
|
||||||
|
|
||||||
# Prefer local iconv if installed
|
# Prefer local iconv if installed
|
||||||
find_library(ICONV_LIBRARY iconv)
|
find_library(ICONV_LIBRARY iconv)
|
||||||
@ -356,6 +354,10 @@ else()
|
|||||||
if (ICONV_LIBRARY)
|
if (ICONV_LIBRARY)
|
||||||
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY})
|
set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
if (HAIKU)
|
||||||
|
set(PLATFORM_LIBS ${PLATFORM_LIBS} intl network)
|
||||||
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_include_files(endian.h HAVE_ENDIAN_H)
|
check_include_files(endian.h HAVE_ENDIAN_H)
|
||||||
@ -649,7 +651,7 @@ if(BUILD_CLIENT)
|
|||||||
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR} ${CURSES_LIBRARIES})
|
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR} ${CURSES_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
if (USE_POSTGRESQL)
|
if (USE_POSTGRESQL)
|
||||||
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR} ${POSTGRESQL_LIBRARY})
|
target_link_libraries(${PROJECT_NAME} ${PostgreSQL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
if (USE_LEVELDB)
|
if (USE_LEVELDB)
|
||||||
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR} ${LEVELDB_LIBRARY})
|
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR} ${LEVELDB_LIBRARY})
|
||||||
@ -724,6 +726,8 @@ if (GETTEXT_FOUND AND APPLY_LOCALE_BLACKLIST)
|
|||||||
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 (GETTEXT_FOUND)
|
||||||
|
set(GETTEXT_USED_LOCALES ${GETTEXT_AVAILABLE_LOCALES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set some optimizations and tweaks
|
# Set some optimizations and tweaks
|
||||||
@ -761,12 +765,13 @@ else()
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||||
endif()
|
endif()
|
||||||
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
|
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=gnu99")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||||
elseif (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.6)
|
elseif (CMAKE_C_COMPILER_VERSION VERSION_EQUAL 4.6)
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=gnu1x")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu1x")
|
||||||
else()
|
else()
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=gnu11")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "using gnu compiler")
|
||||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++1y")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++1y")
|
||||||
@ -776,6 +781,7 @@ else()
|
|||||||
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
|
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 3.5)
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "using clang compiler")
|
||||||
else()
|
else()
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.0)
|
if (CMAKE_VERSION VERSION_GREATER 3.0)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
@ -788,6 +794,7 @@ else()
|
|||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "using default installed compiler")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WARN_ALL)
|
if(WARN_ALL)
|
||||||
@ -845,14 +852,26 @@ else()
|
|||||||
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} -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} ${CMAKE_CXX_FLAGS} -Os")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -Os")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -O3 -ffast-math -fomit-frame-pointer")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux"
|
||||||
|
AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||||
|
AND CMAKE_CXX_COMPILER_VERSION MATCHES "^9\\.")
|
||||||
|
# Clang 9 has broken -ffast-math on glibc
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -ffast-math -fomit-frame-pointer")
|
||||||
|
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 -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS} ${CMAKE_CXX_FLAGS}")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS} ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_FLAGS} $ENV{CPPFLAGS}")
|
||||||
|
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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user