Update to use universal build flags and fix cmake deprecations
parent
635c34a17b
commit
51ed6b5424
|
|
@ -155,46 +155,40 @@ if (LINUX)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
|
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
endif (LINUX)
|
endif (LINUX)
|
||||||
|
|
||||||
|
|
||||||
if (DARWIN)
|
if (DARWIN)
|
||||||
|
# Use rpath loading on macos
|
||||||
|
set(CMAKE_MACOSX_RPATH TRUE)
|
||||||
|
|
||||||
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
|
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
|
||||||
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
|
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
|
||||||
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
|
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
||||||
set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations")
|
|
||||||
# Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format --
|
|
||||||
# see Variables.cmake.
|
|
||||||
string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}"
|
|
||||||
CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}")
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DARWIN_extra_cstar_flags}")
|
|
||||||
# NOTE: it's critical that the optimization flag is put in front.
|
|
||||||
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
|
|
||||||
## Really?? On developer machines too?
|
|
||||||
##set(ENABLE_SIGNING TRUE)
|
|
||||||
##set(SIGNING_IDENTITY "Developer ID Application: Linden Research, Inc.")
|
|
||||||
|
|
||||||
# required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function
|
# Ensure debug symbols are always generated
|
||||||
# see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library
|
add_compile_options(-g --debug) # --debug is a clang synonym for -g that bypasses cmake behaviors
|
||||||
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
|
|
||||||
|
# Silence GL deprecation warnings
|
||||||
|
add_compile_definitions(GL_SILENCE_DEPRECATION=1)
|
||||||
endif(DARWIN)
|
endif(DARWIN)
|
||||||
|
|
||||||
if (LINUX OR DARWIN)
|
if (LINUX OR DARWIN)
|
||||||
set(GCC_WARNINGS -Wall -Wno-sign-compare -Wno-trigraphs)
|
add_compile_options(-Wall -Wno-sign-compare -Wno-trigraphs -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable)
|
||||||
|
|
||||||
if (NOT GCC_DISABLE_FATAL_WARNINGS)
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
list(APPEND GCC_WARNINGS -Werror)
|
# libstdc++ headers contain deprecated declarations that fail on clang
|
||||||
endif (NOT GCC_DISABLE_FATAL_WARNINGS)
|
# macOS currently has many deprecated calls
|
||||||
|
add_compile_options(-Wno-unused-local-typedef -Wno-deprecated-declarations)
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND GCC_WARNINGS -Wno-reorder -Wno-non-virtual-dtor )
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
add_compile_options(-Wno-stringop-truncation -Wno-parentheses -Wno-maybe-uninitialized)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
|
if (NOT GCC_DISABLE_FATAL_WARNINGS AND NOT CLANG_DISABLE_FATAL_WARNINGS)
|
||||||
list(APPEND GCC_WARNINGS -Wno-unused-but-set-variable -Wno-unused-variable )
|
add_compile_options(-Werror)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_compile_options(${GCC_WARNINGS})
|
add_compile_options(${GCC_WARNINGS})
|
||||||
add_compile_options(-m${ADDRESS_SIZE})
|
add_compile_options(-m${ADDRESS_SIZE})
|
||||||
endif (LINUX OR DARWIN)
|
endif (LINUX OR DARWIN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ elseif (WINDOWS)
|
||||||
legacy_stdio_definitions
|
legacy_stdio_definitions
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
include(CMakeFindFrameworks)
|
|
||||||
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||||
find_library(CARBON_LIBRARY Carbon)
|
find_library(CARBON_LIBRARY Carbon)
|
||||||
find_library(COCOA_LIBRARY Cocoa)
|
find_library(COCOA_LIBRARY Cocoa)
|
||||||
|
|
|
||||||
|
|
@ -147,49 +147,29 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
|
||||||
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'")
|
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'")
|
||||||
|
|
||||||
string(REGEX MATCH "-stdlib=([^ ]+)" scratch "$ENV{LL_BUILD}")
|
# Use dwarf symbols for most libraries for compilation speed
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "${CMAKE_MATCH_1}")
|
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
|
||||||
message(STATUS "CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY = '${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}'")
|
|
||||||
|
|
||||||
string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}")
|
|
||||||
# -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt.
|
|
||||||
# However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g
|
|
||||||
# switch, producing no symbols at all! The same thing happens if we specify
|
|
||||||
# plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is
|
|
||||||
# the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a
|
|
||||||
# different CMake behavior: it substitutes plain -g. As of 2017-09-19,
|
|
||||||
# viewer-build-variables/variables still passes -gdwarf-2, which is the
|
|
||||||
# no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g --
|
|
||||||
# at least that way we should get symbols, albeit mangled ones. It Would Be
|
|
||||||
# Nice if CMake's behavior could be predicted from a consistent mental
|
|
||||||
# model, instead of only observed experimentally.
|
|
||||||
string(REPLACE "dwarf-2" "dwarf"
|
|
||||||
CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT
|
|
||||||
"${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}")
|
|
||||||
message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'")
|
|
||||||
|
|
||||||
string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")
|
string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")
|
||||||
message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'")
|
message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'")
|
||||||
|
|
||||||
# allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var
|
# allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var
|
||||||
set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
|
# set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
|
||||||
if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
|
# if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
|
||||||
string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
|
# string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
|
||||||
list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
|
# list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
|
||||||
if ("${sysroot_idx}" LESS 0)
|
# if ("${sysroot_idx}" LESS 0)
|
||||||
message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
|
# message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
|
||||||
endif ()
|
# endif ()
|
||||||
math(EXPR sysroot_idx "${sysroot_idx} + 1")
|
# math(EXPR sysroot_idx "${sysroot_idx} + 1")
|
||||||
list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
|
# list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
|
||||||
endif()
|
# endif()
|
||||||
message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
|
# message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
|
||||||
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
|
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS ssse3)
|
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2)
|
||||||
# we must hard code this to off for now. xcode's built in signing does not
|
# we must hard code this to off for now. xcode's built in signing does not
|
||||||
# handle embedded app bundles such as CEF and others. Any signing for local
|
# handle embedded app bundles such as CEF and others. Any signing for local
|
||||||
# development must be done after the build as we do in viewer_manifest.py for
|
# development must be done after the build as we do in viewer_manifest.py for
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,5 @@
|
||||||
# -*- cmake -*-
|
# -*- cmake -*-
|
||||||
|
|
||||||
# cmake_minimum_required should appear before any
|
|
||||||
# other commands to guarantee full compatibility
|
|
||||||
# with the version specified
|
|
||||||
## prior to 2.8, the add_custom_target commands used in setting the version did not work correctly
|
|
||||||
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
|
|
||||||
|
|
||||||
set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
|
|
||||||
"The root project/makefile/solution name. Defaults to SecondLife.")
|
|
||||||
project(${ROOT_PROJECT_NAME})
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
|
||||||
|
|
||||||
include(Variables)
|
|
||||||
|
|
||||||
# add a target to generate API documentation with Doxygen
|
# add a target to generate API documentation with Doxygen
|
||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
if(DOXYGEN_FOUND)
|
if(DOXYGEN_FOUND)
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,6 @@ endif (SDL_FOUND)
|
||||||
target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if (DARWIN)
|
if (DARWIN)
|
||||||
include(CMakeFindFrameworks)
|
|
||||||
find_library(CARBON_LIBRARY Carbon)
|
find_library(CARBON_LIBRARY Carbon)
|
||||||
target_link_libraries(llwindow ${CARBON_LIBRARY})
|
target_link_libraries(llwindow ${CARBON_LIBRARY})
|
||||||
endif (DARWIN)
|
endif (DARWIN)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue