Fix march=native not being enabled
* LINUX doesn't exist apparently, use UNIX instead + Add some platform-specific logic to determine whether to use mcpu or march - Remove duplicated compile option comments + Add STATUS level to messages
This commit is contained in:
parent
2a6d4ffcd8
commit
2f1359a0f9
@ -1,20 +1,6 @@
|
||||
# This is the top-level CMakeLists.txt file for the Cuberite project
|
||||
#
|
||||
# Use CMake to generate the build files for your platform
|
||||
#
|
||||
# This script supports some configuration through CMake arguments (-Dparam=val syntax):
|
||||
# BUILD_TOOLS=1 sets up additional executables to be built along with the server (ProtoProxy, GrownBiomeGenVisualiser, MCADefrag)
|
||||
# BUILD_UNSTABLE_TOOLS=1 sets up yet more executables to be built, these can be broken and generally are obsolete (GeneratorPerformanceTest)
|
||||
# NO_NATIVE_OPTIMIZATION=1 disables CPU-specific optimisations for the current machine, allows use on other CPUs of the same platform
|
||||
# DISABLE_SYSTEM_LUA=1 disables the use of system Lua interpreter; the tolua executable will be built and used instead. Incompatible with cross-compiling
|
||||
# SELF_TEST=1 enables testing code to be built
|
||||
# UNITY_BUILDS=OFF disables unity builds
|
||||
# PRECOMPILE_HEADERS=OFF disables precompiled headers
|
||||
# WHOLE_PROGRAM_OPTIMISATION=OFF disables link time optimisation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cmake_minimum_required (VERSION 3.13)
|
||||
cmake_policy(VERSION 3.13...3.17.2)
|
||||
@ -26,10 +12,12 @@ project(
|
||||
)
|
||||
|
||||
option(BUILD_TOOLS "Sets up additional executables to be built along with the server" OFF)
|
||||
option(WHOLE_PROGRAM_OPTIMISATION "Enables link time optimisation for Release" ON)
|
||||
option(BUILD_UNSTABLE_TOOLS "Sets up yet more executables to be built, these can be broken and generally are obsolete" OFF)
|
||||
option(NO_NATIVE_OPTIMIZATION "Disables CPU-specific optimisations for the current machine, allows use on other CPUs of the same platform" OFF)
|
||||
option(PRECOMPILE_HEADERS "Enable precompiled headers for faster builds" ON)
|
||||
option(SELF_TEST "Enables testing code to be built" OFF)
|
||||
option(UNITY_BUILDS "Enables source aggregation for faster builds" ON)
|
||||
option(WHOLE_PROGRAM_OPTIMISATION "Enables link time optimisation for Release" ON)
|
||||
|
||||
include("CMake/AddDependencies.cmake")
|
||||
include("CMake/Fixups.cmake")
|
||||
@ -91,22 +79,22 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set_source_files_properties("${PROJECT_SOURCE_DIR}/src/Bindings/Bindings.cpp" PROPERTIES COMPILE_OPTIONS -w)
|
||||
endif()
|
||||
|
||||
if(${BUILD_TOOLS})
|
||||
message("Building tools")
|
||||
if(BUILD_TOOLS)
|
||||
message(STATUS "Building tools")
|
||||
add_subdirectory(Tools/GrownBiomeGenVisualiser/)
|
||||
add_subdirectory(Tools/MCADefrag/)
|
||||
add_subdirectory(Tools/NoiseSpeedTest/)
|
||||
add_subdirectory(Tools/ProtoProxy/)
|
||||
endif()
|
||||
|
||||
if(${BUILD_UNSTABLE_TOOLS})
|
||||
message("Building unstable tools")
|
||||
if(BUILD_UNSTABLE_TOOLS)
|
||||
message(STATUS "Building unstable tools")
|
||||
add_subdirectory(Tools/GeneratorPerformanceTest/)
|
||||
endif()
|
||||
|
||||
# Self Test Mode enables extra checks at startup
|
||||
if(${SELF_TEST})
|
||||
message("Tests enabled")
|
||||
if(SELF_TEST)
|
||||
message(STATUS "Tests enabled")
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
@ -96,9 +96,18 @@ function(set_global_flags)
|
||||
add_link_options(-m32)
|
||||
endif()
|
||||
|
||||
# https://en.wikipedia.org/wiki/Uname
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/index.html
|
||||
# Have the compiler generate code specifically targeted at the current machine on Linux:
|
||||
if(LINUX AND NOT NO_NATIVE_OPTIMIZATION)
|
||||
add_compile_options(-march=native)
|
||||
if(UNIX AND NOT NO_NATIVE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING)
|
||||
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
|
||||
if (SYSTEM_PROCESSOR MATCHES "^(i386|i686|x86|amd64|mips)")
|
||||
message(STATUS "Optimising for this machine (march=native)")
|
||||
add_compile_options(-march=native)
|
||||
elseif (SYSTEM_PROCESSOR MATCHES "^(arm|aarch|powerpc|ppc|sparc|alpha)")
|
||||
message(STATUS "Optimising for this machine (mcpu=native)")
|
||||
add_compile_options(-mcpu=native)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
@ -210,7 +210,7 @@ function(make_symlink orig link)
|
||||
endif()
|
||||
|
||||
# Create the symlink (platform-dependent):
|
||||
message("Creating symlink, orig = ${orig}; link = ${link}")
|
||||
message(STATUS "Creating symlink, orig = ${orig}; link = ${link}")
|
||||
if (CMAKE_HOST_UNIX)
|
||||
set(command ln -s ${orig} ${link})
|
||||
else()
|
||||
@ -254,7 +254,7 @@ set(symlinks
|
||||
monsters.ini
|
||||
README.txt
|
||||
)
|
||||
message("Creating output folder and symlinks...")
|
||||
message(STATUS "Creating output folder and symlinks...")
|
||||
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
|
||||
foreach (symlink ${symlinks})
|
||||
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../Server/${symlink}" "${CMAKE_BINARY_DIR}/Server/${symlink}")
|
||||
|
Loading…
Reference in New Issue
Block a user